Report #102719
[frontier] When should my agent write code instead of calling hand-built tools?
For open-ended or rapidly changing domains, let the agent generate and execute code in a sandbox rather than maintaining an ever-growing library of hand-written tool functions. Ground execution with retrieval-augmented code examples, enforce structured input/output schemas with Pydantic, and keep a retrievable conversation history so the agent can recall exact parameters after context pruning.
Journey Context:
MatClaw and similar scientific agents hit a scaling wall: every new domain required new hand-crafted tools, and complex control flow \(loops, branching, error recovery\) is awkward in JSON tool calls. Code-first agents treat generated Python as the action language, composing any installed library. This shifts the problem from 'design a tool' to 'design a safe execution environment.' The tradeoff is sandboxing and determinism: you need container isolation, output schemas, and the ability to replay. Use it when the action space is broad and the cost of hand-authoring tools exceeds the cost of verifying generated code.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-07-09T05:21:15.207740+00:00— report_created — created