[{"data":1,"prerenderedAt":498},["ShallowReactive",2],{"docs-\u002Fdocs\u002Fv2\u002Fconcepts\u002Fagent-output":3},{"id":4,"title":5,"body":6,"description":17,"extension":492,"meta":493,"navigation":227,"path":494,"seo":495,"stem":496,"__hash__":497},"docs\u002Fdocs\u002Fv2\u002Fconcepts\u002Fagent-output.md","Agent Output",{"type":7,"value":8,"toc":484},"minimark",[9,14,18,21,24,29,37,46,54,57,61,67,90,97,101,108,266,273,276,280,283,403,409,412,416,427,435,439,451,458,461,464,473,480],[10,11,13],"h1",{"id":12},"the-agent-speaks-typescript","The agent speaks TypeScript",[15,16,17],"p",{},"Most tool-calling systems use a structured protocol: the model emits a JSON object with a\nfunction name and arguments, the framework deserializes it, looks the function up in a\nregistry, calls it, and serializes the result back. There's a translation layer at every\nstep.",[15,19,20],{},"Axon does not work this way.",[15,22,23],{},"The model emits TypeScript. The capsule runs it. The stdout comes back as the next entry\nin the timeline.",[25,26,28],"h2",{"id":27},"the-output-surface","The output surface",[15,30,31,32,36],{},"The agent has exactly two output variants, both defined in the ",[33,34,35],"code",{},"\u003Ccontract>"," block of the\nAIR context window:",[15,38,39,45],{},[40,41,42],"strong",{},[33,43,44],{},"\u003Ctypescript>"," — executable code. Emitted when the agent needs to act on the\nenvironment. Runs immediately in the capsule. The runtime stops and waits for the result\nbefore continuing the loop.",[15,47,48,53],{},[40,49,50],{},[33,51,52],{},"\u003Ctext>"," — plain language. Emitted when the agent is communicating with the user.\nNot executed. Streamed directly to output.",[15,55,56],{},"That's the entire surface. There is no third mode, no hybrid, no escape hatch.",[25,58,60],{"id":59},"what-happens-when-the-agent-acts","What happens when the agent acts",[15,62,63,64,66],{},"When the model emits a ",[33,65,44],{}," block:",[68,69,70,74,77,84,87],"ol",{},[71,72,73],"li",{},"The runtime passes the block to the capsule subprocess",[71,75,76],{},"The capsule runs the code against the declared tool namespaces",[71,78,79,80,83],{},"Stdout is captured and returned as a ",[33,81,82],{},"\u003Cstdout for=\"...\" ok=\"true|false\">"," entry",[71,85,86],{},"That entry is injected into the next tick's timeline",[71,88,89],{},"The loop continues — the model reads the result and decides what to do next",[15,91,92,93,96],{},"The model never calls functions directly. It writes code that calls functions. The capsule\nexecutes that code on the user's machine, in the user's filesystem, under the policy\ndeclared in ",[33,94,95],{},"axon.config.ts",".",[25,98,100],{"id":99},"tools-as-typescript-declarations","Tools as TypeScript declarations",[15,102,103,104,107],{},"Every tool available to the agent is declared as a TypeScript namespace in the ",[33,105,106],{},"\u003Cenv>","\nblock:",[109,110,115],"pre",{"className":111,"code":112,"language":113,"meta":114,"style":114},"language-xml shiki shiki-themes dark-plus","\u003Cenv>\n    \u003Cscope lang=\"ts\">\n        declare namespace fs {\n          export declare function read(path: string): Promise\u003Cstring>;\n          export declare function write(path: string, content: string): Promise\u003C{ bytes: number }>;\n          export declare function list(path: string): Promise\u003CArray\u003C{ name: string; type: \"file\" | \"directory\" }>>;\n        }\n\n        declare const process: {\n          run(command: string, opts?: { cwd?: string }): Promise\u003C{ ok: boolean; stdout: string; stderr: string }>\n        }\n    \u003C\u002Fscope>\n\u003C\u002Fenv>\n","xml","",[33,116,117,133,156,162,179,185,216,222,229,235,241,246,256],{"__ignoreMap":114},[118,119,122,126,130],"span",{"class":120,"line":121},"line",1,[118,123,125],{"class":124},"srRes","\u003C",[118,127,129],{"class":128},"scz_3","env",[118,131,132],{"class":124},">\n",[118,134,136,139,142,146,150,154],{"class":120,"line":135},2,[118,137,138],{"class":124},"    \u003C",[118,140,141],{"class":128},"scope",[118,143,145],{"class":144},"s3F5K"," lang",[118,147,149],{"class":148},"sTNBD","=",[118,151,153],{"class":152},"sKc5r","\"ts\"",[118,155,132],{"class":124},[118,157,159],{"class":120,"line":158},3,[118,160,161],{"class":148},"        declare namespace fs {\n",[118,163,165,168,170,173,176],{"class":120,"line":164},4,[118,166,167],{"class":148},"          export declare function read(path: string): Promise",[118,169,125],{"class":124},[118,171,172],{"class":128},"string",[118,174,175],{"class":124},">",[118,177,178],{"class":148},";\n",[118,180,182],{"class":120,"line":181},5,[118,183,184],{"class":148},"          export declare function write(path: string, content: string): Promise\u003C{ bytes: number }>;\n",[118,186,188,191,193,196,199,202,205,208,211,213],{"class":120,"line":187},6,[118,189,190],{"class":148},"          export declare function list(path: string): Promise",[118,192,125],{"class":124},[118,194,195],{"class":128},"Array",[118,197,198],{"class":148},"\u003C{ name: string; type: ",[118,200,201],{"class":152},"\"file\"",[118,203,204],{"class":148}," | ",[118,206,207],{"class":152},"\"directory\"",[118,209,210],{"class":148}," }",[118,212,175],{"class":124},[118,214,215],{"class":148},">;\n",[118,217,219],{"class":120,"line":218},7,[118,220,221],{"class":148},"        }\n",[118,223,225],{"class":120,"line":224},8,[118,226,228],{"emptyLinePlaceholder":227},true,"\n",[118,230,232],{"class":120,"line":231},9,[118,233,234],{"class":148},"        declare const process: {\n",[118,236,238],{"class":120,"line":237},10,[118,239,240],{"class":148},"          run(command: string, opts?: { cwd?: string }): Promise\u003C{ ok: boolean; stdout: string; stderr: string }>\n",[118,242,244],{"class":120,"line":243},11,[118,245,221],{"class":148},[118,247,249,252,254],{"class":120,"line":248},12,[118,250,251],{"class":124},"    \u003C\u002F",[118,253,141],{"class":128},[118,255,132],{"class":124},[118,257,259,262,264],{"class":120,"line":258},13,[118,260,261],{"class":124},"\u003C\u002F",[118,263,129],{"class":128},[118,265,132],{"class":124},[15,267,268,269,272],{},"The model sees typed declarations. It writes code against those types. When the code\nruns, the implementations behind the declarations are the actual tool functions you\ndefined in ",[33,270,271],{},"src\u002Ftools\u002F"," — plus any contributed by installed modules.",[15,274,275],{},"The type contract is structural, not bolted on. The model isn't guessing at argument\nshapes from a description. It has the exact signatures, return types, and JSDoc that you\nwrote.",[25,277,279],{"id":278},"high-bandwidth-composable-execution","High-bandwidth, composable execution",[15,281,282],{},"Because the output is code, the agent can compose freely within a single turn. Multiple\ntool calls in one block is the default — not the exception.",[109,284,288],{"className":285,"code":286,"language":287,"meta":114,"style":114},"language-typescript shiki shiki-themes dark-plus","\u002F\u002F One turn. One stdout. No round-trips.\nconst [src, pkg, config] = await Promise.all([\n    fs.read(\"src\u002Findex.ts\"),\n    fs.read(\"package.json\"),\n    fs.read(\"axon.config.ts\"),\n])\n\u002F\u002F Last expression is the stdout returned to the loop\nsrc\n","typescript",[33,289,290,296,339,358,373,388,393,398],{"__ignoreMap":114},[118,291,292],{"class":120,"line":121},[118,293,295],{"class":294},"sOLPB","\u002F\u002F One turn. One stdout. No round-trips.\n",[118,297,298,301,304,308,311,314,316,319,322,326,330,332,336],{"class":120,"line":135},[118,299,300],{"class":128},"const",[118,302,303],{"class":148}," [",[118,305,307],{"class":306},"s9McN","src",[118,309,310],{"class":148},", ",[118,312,313],{"class":306},"pkg",[118,315,310],{"class":148},[118,317,318],{"class":306},"config",[118,320,321],{"class":148},"] = ",[118,323,325],{"class":324},"sYbnZ","await",[118,327,329],{"class":328},"sNl3T"," Promise",[118,331,96],{"class":148},[118,333,335],{"class":334},"sCudf","all",[118,337,338],{"class":148},"([\n",[118,340,341,344,346,349,352,355],{"class":120,"line":158},[118,342,343],{"class":144},"    fs",[118,345,96],{"class":148},[118,347,348],{"class":334},"read",[118,350,351],{"class":148},"(",[118,353,354],{"class":152},"\"src\u002Findex.ts\"",[118,356,357],{"class":148},"),\n",[118,359,360,362,364,366,368,371],{"class":120,"line":164},[118,361,343],{"class":144},[118,363,96],{"class":148},[118,365,348],{"class":334},[118,367,351],{"class":148},[118,369,370],{"class":152},"\"package.json\"",[118,372,357],{"class":148},[118,374,375,377,379,381,383,386],{"class":120,"line":181},[118,376,343],{"class":144},[118,378,96],{"class":148},[118,380,348],{"class":334},[118,382,351],{"class":148},[118,384,385],{"class":152},"\"axon.config.ts\"",[118,387,357],{"class":148},[118,389,390],{"class":120,"line":187},[118,391,392],{"class":148},"])\n",[118,394,395],{"class":120,"line":218},[118,396,397],{"class":294},"\u002F\u002F Last expression is the stdout returned to the loop\n",[118,399,400],{"class":120,"line":224},[118,401,402],{"class":144},"src\n",[15,404,405,406,408],{},"Parallel reads, conditional logic, multi-step operations — all in one ",[33,407,44],{},"\nblock. The agent only splits into a new turn when the result of one operation genuinely\ndetermines what the next operation must be. Everything else can and should compose.",[15,410,411],{},"This is the high-bandwidth channel. A single turn can read dozens of files, run commands,\napply edits, and inspect results. The loop doesn't tick again until there's a real data\ndependency.",[25,413,415],{"id":414},"the-capsule-runs-on-the-users-machine","The capsule runs on the user's machine",[15,417,418,419,422,423,426],{},"The capsule is a subprocess on the machine running the agent — not a cloud sandbox, not\na remote interpreter. When the agent calls ",[33,420,421],{},"fs.read(\"src\u002Findex.ts\")",", that's a real file.\nWhen it calls ",[33,424,425],{},"process.run(\"bun test\")",", that's a real process.",[15,428,429,430,96],{},"For the full picture of what the capsule makes available — subprocesses, subagents, the\ncomplete Bun runtime — see ",[431,432,434],"a",{"href":433},"\u002Fdocs\u002Fv2\u002Fconcepts\u002Fagents-world","The Agent's World",[25,436,438],{"id":437},"format-violations-and-self-correction","Format violations and self-correction",[15,440,441,442,444,445,447,448,450],{},"The ",[33,443,35],{}," block is not a prompt instruction. It is the only output grammar the\nruntime accepts. If the model emits content outside a declared block — any text not\nwrapped in ",[33,446,44],{}," or ",[33,449,52],{}," — the runtime flags it as a format violation.",[15,452,453,454,457],{},"The violation is injected into the next tick's timeline as an ",[33,455,456],{},"\u003Cerror>"," entry. The model\nreads it and corrects. The loop does not break — self-correction is built into the cycle.",[15,459,460],{},"This is why the contract is part of every context window rather than a one-time setup\ninstruction. The model is reminded of its output grammar on every tick. Format discipline\nis structural, not reliant on the model following instructions it received earlier.",[462,463],"hr",{},[15,465,466,472],{},[40,467,468],{},[431,469,471],{"href":470},"\u002Fdocs\u002Fv2\u002Fconcepts\u002Fair-format","AIR Format"," — the full input side: what the model\nreceives on every tick, and how that context is assembled.",[15,474,475,479],{},[40,476,477],{},[431,478,434],{"href":433}," — the complete execution\nenvironment: tool namespaces, subprocesses, subagents, and the full Bun runtime.",[481,482,483],"style",{},"html pre.shiki code .srRes, html code.shiki .srRes{--shiki-default:#808080}html pre.shiki code .scz_3, html code.shiki .scz_3{--shiki-default:#569CD6}html pre.shiki code .s3F5K, html code.shiki .s3F5K{--shiki-default:#9CDCFE}html pre.shiki code .sTNBD, html code.shiki .sTNBD{--shiki-default:#D4D4D4}html pre.shiki code .sKc5r, html code.shiki .sKc5r{--shiki-default:#CE9178}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html pre.shiki code .sOLPB, html code.shiki .sOLPB{--shiki-default:#6A9955}html pre.shiki code .s9McN, html code.shiki .s9McN{--shiki-default:#4FC1FF}html pre.shiki code .sYbnZ, html code.shiki .sYbnZ{--shiki-default:#C586C0}html pre.shiki code .sNl3T, html code.shiki .sNl3T{--shiki-default:#4EC9B0}html pre.shiki code .sCudf, html code.shiki .sCudf{--shiki-default:#DCDCAA}",{"title":114,"searchDepth":135,"depth":135,"links":485},[486,487,488,489,490,491],{"id":27,"depth":135,"text":28},{"id":59,"depth":135,"text":60},{"id":99,"depth":135,"text":100},{"id":278,"depth":135,"text":279},{"id":414,"depth":135,"text":415},{"id":437,"depth":135,"text":438},"md",{},"\u002Fdocs\u002Fv2\u002Fconcepts\u002Fagent-output",{"title":5,"description":17},"docs\u002Fv2\u002Fconcepts\u002Fagent-output","yfUCnm_2_D7sfQu-2GCUCAMxBRPOt2aojMezlTRDTzI",1785671807749]