Your First Graph
This tutorial uses the beginner-friendly builder API.
Goal
Create one agent, attach one built-in tool, run one query.
Example
import asyncio
from yggdrasil import GraphApp
async def main() -> None:
app = GraphApp(provider="compatible", api_key="sk-...")
agent = await app.add_agent(
"Assistant",
system_prompt="Use the echo tool when it helps.",
)
tool = await app.add_tool(
"echo",
callable_ref="yggdrasil.tools.echo.echo",
description="Echoes the input",
input_schema={
"type": "object",
"properties": {"text": {"type": "string"}},
"required": ["text"],
},
)
await app.connect_tool(agent, tool)
app.use_default_tools()
ctx = await app.run(agent, "Use the echo tool to repeat: hello graph")
print(ctx.outputs[agent.node_id]["text"])
asyncio.run(main())
What Happened
GraphAppcreated an in-memory graph store and executoradd_agent()inserted anAgentNodeadd_tool()inserted aToolNodeconnect_tool()created theHAS_TOOLedgeuse_default_tools()registered the built-in Python callablerun()executed the graph starting at that agent