Use this file to discover all available pages before exploring further.
This tutorial takes you from zero to a working agent with tool use, streaming, and state persistence. By the end, you’ll have a running Aegra server with an agent you can talk to through the SDK and any Agent Protocol frontend.
A thread represents a conversation. Each run executes the agent within a thread, and state is persisted between runs.
import asynciofrom langgraph_sdk import get_clientasync def main(): client = get_client(url="http://localhost:2026") # Create a thread thread = await client.threads.create() print(f"Thread ID: {thread['thread_id']}") # Run the agent with streaming async for chunk in client.runs.stream( thread_id=thread["thread_id"], assistant_id="agent", # graph ID works as assistant ID input={"messages": [{"type": "human", "content": "What is Aegra?"}]}, stream_mode=["messages-tuple"], ): if hasattr(chunk, "data") and chunk.data: print(chunk.data)asyncio.run(main())
The agent processes your message, potentially uses tools, and streams the response back as Server-Sent Events.
Because state is persisted in the thread, you can send follow-up messages:
async def continue_conversation(): client = get_client(url="http://localhost:2026") thread_id = "your-thread-id-from-step-5" # Follow-up — the agent remembers the previous exchange async for chunk in client.runs.stream( thread_id=thread_id, assistant_id="agent", input={"messages": [{"type": "human", "content": "Tell me more about its features"}]}, stream_mode=["messages-tuple"], ): if hasattr(chunk, "data") and chunk.data: print(chunk.data)asyncio.run(continue_conversation())
The agent has full access to the conversation history from the thread’s checkpoint.
You can inspect the full state of any thread at any point:
async def inspect_state(): client = get_client(url="http://localhost:2026") thread_id = "your-thread-id" # Get current state state = await client.threads.get_state(thread_id) print("Current values:", state["values"]) print("Next nodes:", state["next"]) # Get history (all checkpoints) history = await client.threads.get_history(thread_id) print(f"Total checkpoints: {len(history)}") for entry in history: print(f" Checkpoint: {entry['checkpoint']['checkpoint_id']}")asyncio.run(inspect_state())