From Core to Agent¶
Goal¶
Build a practical agent by inheriting core contracts, with clear implementation milestones.
Milestone 1: define state and agent shell¶
- create a
StateSchemasubclass with only essential fields - implement
init_state,prepare,reduce - return
Decision.final(...)first to verify loop plumbing
Milestone 2: wire tools and parser¶
- register one simple tool
- attach parser (for LLM output mode)
- run one
Decision.act(...)path and verify action result enters state
Milestone 3: switch to model-driven decisions¶
- implement
build_system_prompt - implement
prepare - set
decideto returnNone - verify model output can be parsed to valid
Decision
Milestone 4: add env + memory/history¶
- choose Env backend (
HostEnvfirst) - set
Engine(history_policy=...)for bounded model history - keep memory retrieval inside
prepare(state) - verify trace includes memory and env payload
Milestone 5: harden runtime¶
- configure budgets
- add hook-based observability
- add two or three regression tasks
Minimal production-ready run command¶
python examples/real/coding_agent.py \
--model-base-url "https://api.siliconflow.cn/v1/" \
--api-key "<your_api_key>" \
--model-name "Qwen/Qwen3-8B" \
--workspace ./playground