Skip to content

Step 4 - LangGraph Todo Agent CLI

Overview

This step adds a minimal LangGraph + Microsoft Foundry CLI at scripts/langgraph/vanilla.py.

The agent talks to the Todo Web API through tools and supports:

  • one-shot mode: run
  • interactive mode: chat

Prerequisites

Start the Todo API in another terminal:

uv run todo-web

Make sure your .env contains Microsoft Foundry settings (same as previous steps).

Usage

One-shot mode

uv run python scripts/langgraph/vanilla.py run \
  --query "牛乳を買うタスクを追加して、その後一覧を見せて"

Interactive mode

uv run python scripts/langgraph/vanilla.py chat \
  --endpoint http://localhost:8080

Common options:

  • --endpoint/-e: Todo API base URL (CLI value > TODO_API_ENDPOINT > default)
  • --model/-M: model string for init_chat_model
  • --timeout: HTTP timeout seconds
  • --thread-id: LangGraph thread id

chat also supports --system for overriding the system prompt.

Slash commands (chat)

  • /exit, /quit: leave REPL
  • /reset: reset conversation thread id
  • /help: show commands and tools
  • /tools: show tool signatures
  • /thread: show current thread id

Observability

Like scripts/microsoft_foundry/vanilla.py, this CLI supports:

  • --tracing/-t: Azure Monitor / Foundry tracing
  • --mlflow/-m: MLflow autologging
  • --verbose/-v: DEBUG logs

Example:

uv run python scripts/langgraph/vanilla.py -t -m chat

Troubleshooting

If the Todo API is unreachable or returns 4xx/5xx, tools return structured error dictionaries (instead of throwing), so the agent can retry or recover.

Check:

  1. todo-web is running
  2. --endpoint points to the correct host/port
  3. request/response details under --verbose

Further Reading

The same LangGraph agent pattern can be integrated into the Cloud Agent service so that it runs as an async background task. The LangGraphAgent class in concierge/agents/infrastructure/langgraph_agent.py is a minimal reference implementation that follows the same create_agent API used in this tutorial; the langgraph preset registered in registry_factory.py wires it up with echo and generate_image_tool tool builders so the LLM can pick the right one per request. See the Cloud Agent CLI docs for a dispatch example.