agent-echo
The smallest LLM-backed experience: one agent node reads a name from args and writes a one-sentence greeting.
What it demonstrates
- A single
agentnode with a prompt file - Prompt interpolation:
resolved from node args ANTHROPIC_API_KEYas the minimal LLM requirement- Structured output via the agent's
writescontract
The graph
graph:
nodes:
- id: greet
kind: agent
prompt: ./prompts/echo.md
args:
name: World
writes: [greeting]
edges: []State schema
| Field | Type | Direction | Description |
|---|---|---|---|
name | string | in (via node args) | Who to greet |
greeting | string | out | Model's one-sentence reply |
How it runs
Requires ANTHROPIC_API_KEY:
export ANTHROPIC_API_KEY=sk-...
oe run examples/agent-echoTo greet a specific name:
oe run examples/agent-echo --args '{"name":"Alice"}'LLM required
This is the first example that makes a real API call. Make sure your ANTHROPIC_API_KEY is set before running.
What happens
- The scheduler dispatches
greettoAgentDispatcher. - The dispatcher loads
prompts/echo.md, interpolates→"World"(or whatever was passed). - The model receives: "Say a friendly hello to World. Keep it short — one sentence."
- The model's text response is written to the
greetingfield in state.
$ oe state greeting
Hello, World! Wishing you a wonderful day ahead.The prompt
Say a friendly hello to {{name}}. Keep it short — one sentence.Prompt files live in prompts/ and use interpolation. This one is the simplest possible: a single sentence instruction with one variable.
Try it: variations
1. Change the prompt. Edit prompts/echo.md to ask for a different style — e.g., "Greet in the style of a pirate." No schema changes needed.
2. Add a second agent. Add a farewell agent node that reads greeting and writes goodbye. The node can reference in its prompt. Add edge { from: greet, to: farewell }.
3. Use a different model. By default the AgentDispatcher uses whatever model your client is configured for. Pass --model claude-3-5-haiku-20241022 (or the equivalent CLI flag) to use a faster/cheaper model for this toy example.
Compare with hello-tool
hello-tool does the same thing without a model call. Compare the two to understand exactly what the agent node kind adds.