[{"data":1,"prerenderedAt":494},["ShallowReactive",2],{"docs-\u002Fdocs\u002Fv2\u002Fconcepts\u002Fstate-model":3},{"id":4,"title":5,"body":6,"description":487,"extension":488,"meta":489,"navigation":297,"path":490,"seo":491,"stem":492,"__hash__":493},"docs\u002Fdocs\u002Fv2\u002Fconcepts\u002Fstate-model.md","State & Memory",{"type":7,"value":8,"toc":475},"minimark",[9,13,22,89,93,100,109,112,115,163,174,177,187,195,198,201,204,208,211,216,223,227,233,405,411,415,425,429,432,468,471],[10,11,5],"h1",{"id":12},"state-memory",[14,15,16,17,21],"p",{},"An agent isn't a stateless function. Between a bare ",[18,19,20],"code",{},"axon.request(\"hello\")"," and a\nmulti-day project thread there are four layers of state, each with its own scope and\nlifetime. Knowing which layer holds what explains why the agent remembers some things\nand not others — and how to make it remember the things you want.",[23,24,25,41],"table",{},[26,27,28],"thead",{},[29,30,31,35,38],"tr",{},[32,33,34],"th",{},"Layer",[32,36,37],{},"Scope",[32,39,40],{},"Lifetime",[42,43,44,56,67,78],"tbody",{},[29,45,46,50,53],{},[47,48,49],"td",{},"Base state",[47,51,52],{},"All sessions",[47,54,55],{},"Changes when source changes",[29,57,58,61,64],{},[47,59,60],{},"Session state",[47,62,63],{},"One working session",[47,65,66],{},"Boot to shutdown",[29,68,69,72,75],{},[47,70,71],{},"Thread state",[47,73,74],{},"One conversation",[47,76,77],{},"Persists by name",[29,79,80,83,86],{},[47,81,82],{},"Request context",[47,84,85],{},"One invocation",[47,87,88],{},"Cleared when the loop completes",[90,91,49],"h2",{"id":92},"base-state",[14,94,95,96,99],{},"Base state is what the agent is when nothing is happening. It comes entirely from the\nagent folder: ",[18,97,98],{},"boot.vue",", tools, prompts, config, installed modules. Nothing that\nhappens during execution changes it — which is why identity and working practices don't\ndrift over a session. They come from source, not from conversation history.",[14,101,102,103,108],{},"In local development, ",[104,105,107],"a",{"href":106},"\u002Fdocs\u002Fv2\u002Fconcepts\u002Fhot-reload","hot reload"," applies source edits to\nfuture work without rewriting existing history.",[90,110,60],{"id":111},"session-state",[14,113,114],{},"A session is the agent's lifetime — from boot to shutdown. Everything in between —\nevery exchange, every tool call, every file written — belongs to it. The three session\nshapes have different lifetimes:",[116,117,122],"pre",{"className":118,"code":119,"language":120,"meta":121,"style":121},"language-bash shiki shiki-themes dark-plus","axon              # TUI — session lasts until you close it\naxon run scout    # Script — session lasts one script run\naxon deploy       # Cloud — session spans requests; restarts after idle periods\n","bash","",[18,123,124,137,152],{"__ignoreMap":121},[125,126,129,133],"span",{"class":127,"line":128},"line",1,[125,130,132],{"class":131},"sCudf","axon",[125,134,136],{"class":135},"sOLPB","              # TUI — session lasts until you close it\n",[125,138,140,142,146,149],{"class":127,"line":139},2,[125,141,132],{"class":131},[125,143,145],{"class":144},"sKc5r"," run",[125,147,148],{"class":144}," scout",[125,150,151],{"class":135},"    # Script — session lasts one script run\n",[125,153,155,157,160],{"class":127,"line":154},3,[125,156,132],{"class":131},[125,158,159],{"class":144}," deploy",[125,161,162],{"class":135},"       # Cloud — session spans requests; restarts after idle periods\n",[14,164,165,166,169,170],{},"The cloud shape is the one that surprises people: a deployed agent's session can end\nand restart with scaling events. What never restarts is ",[18,167,168],{},"data\u002F"," — thread history,\nknowledge files, and anything the agent has written survive cold starts and redeploys.\n",[171,172,173],"strong",{},"The session is ephemeral. The folder is not.",[90,175,71],{"id":176},"thread-state",[14,178,179,180,183,184,186],{},"A thread is a scoped slice of working memory for one conversation. The agent sees the\nfull history of a thread on every call to it, and nothing from other threads. Named\nthreads persist: ",[18,181,182],{},"\"project-alpha\""," on Monday is still ",[18,185,182],{}," on Tuesday,\nprior context intact.",[14,188,189,190,194],{},"The composition patterns — side threads, parallel branches, persistence — are covered\nin ",[104,191,193],{"href":192},"\u002Fdocs\u002Fv2\u002Fagent\u002Fbuild\u002Fthreads","Threads",".",[90,196,82],{"id":197},"request-context",[14,199,200],{},"Request context is what you pass to a single invocation — rendered prompts, policy\nnarrowing, inline data. It's consumed and cleared when the loop completes. Loading a\nsupport ticket for one invocation doesn't permanently teach the agent about that\nticket; the next invocation starts clean.",[14,202,203],{},"This is what makes agents predictable: a hundred tasks in a day, no cross-contamination\nbetween them.",[90,205,207],{"id":206},"what-persists-and-where","What persists, and where",[14,209,210],{},"Three mechanisms, from automatic to deliberate:",[212,213,215],"h3",{"id":214},"thread-history-automatic","Thread history — automatic",[14,217,218,219,222],{},"The runtime writes every session to ",[18,220,221],{},"data\u002Fsessions\u002F"," as a JSONL trace — every entry,\nevery tool call, every result. Named threads resume by loading it. You don't manage\nthis and there's no persistence API to call.",[212,224,226],{"id":225},"knowledge-files-deliberate","Knowledge files — deliberate",[14,228,229,232],{},[18,230,231],{},"data\u002Fknowledge\u002F"," is yours by convention: scripts write here during execution, the boot\nprompt reads here at render time. It's accumulated memory the agent builds on purpose —\nwhat it has learned about a domain, a codebase, a set of rules.",[116,234,238],{"className":235,"code":236,"language":237,"meta":121,"style":121},"language-ts shiki shiki-themes dark-plus","\u002F\u002F src\u002Fscripts\u002Flearn.ts\nconst result = await axon.request({ prompt: [context, learnPrompt] })\n\nconst match = result.text.match(\u002F```knowledge\\n([\\s\\S]*?)```\u002F)\nif (match) {\n    await writeFile(\"data\u002Fknowledge\u002Fdomains\u002Ftracing.md\", match[1].trim())\n}\n","ts",[18,239,240,245,293,299,351,365,399],{"__ignoreMap":121},[125,241,242],{"class":127,"line":128},[125,243,244],{"class":135},"\u002F\u002F src\u002Fscripts\u002Flearn.ts\n",[125,246,247,251,255,259,263,267,269,272,275,278,281,284,287,290],{"class":127,"line":139},[125,248,250],{"class":249},"scz_3","const",[125,252,254],{"class":253},"s9McN"," result",[125,256,258],{"class":257},"sTNBD"," = ",[125,260,262],{"class":261},"sYbnZ","await",[125,264,266],{"class":265},"s3F5K"," axon",[125,268,194],{"class":257},[125,270,271],{"class":131},"request",[125,273,274],{"class":257},"({ ",[125,276,277],{"class":265},"prompt:",[125,279,280],{"class":257}," [",[125,282,283],{"class":265},"context",[125,285,286],{"class":257},", ",[125,288,289],{"class":265},"learnPrompt",[125,291,292],{"class":257},"] })\n",[125,294,295],{"class":127,"line":154},[125,296,298],{"emptyLinePlaceholder":297},true,"\n",[125,300,302,304,307,309,312,314,317,319,322,325,329,332,335,338,342,345,348],{"class":127,"line":301},4,[125,303,250],{"class":249},[125,305,306],{"class":253}," match",[125,308,258],{"class":257},[125,310,311],{"class":265},"result",[125,313,194],{"class":257},[125,315,316],{"class":265},"text",[125,318,194],{"class":257},[125,320,321],{"class":131},"match",[125,323,324],{"class":257},"(",[125,326,328],{"class":327},"sxaxS","\u002F```knowledge\\n",[125,330,331],{"class":144},"([",[125,333,334],{"class":327},"\\s\\S",[125,336,337],{"class":144},"]",[125,339,341],{"class":340},"svVle","*?",[125,343,344],{"class":144},")",[125,346,347],{"class":327},"```\u002F",[125,349,350],{"class":257},")\n",[125,352,354,357,360,362],{"class":127,"line":353},5,[125,355,356],{"class":261},"if",[125,358,359],{"class":257}," (",[125,361,321],{"class":265},[125,363,364],{"class":257},") {\n",[125,366,368,371,374,376,379,381,383,386,390,393,396],{"class":127,"line":367},6,[125,369,370],{"class":261},"    await",[125,372,373],{"class":131}," writeFile",[125,375,324],{"class":257},[125,377,378],{"class":144},"\"data\u002Fknowledge\u002Fdomains\u002Ftracing.md\"",[125,380,286],{"class":257},[125,382,321],{"class":265},[125,384,385],{"class":257},"[",[125,387,389],{"class":388},"sDGX8","1",[125,391,392],{"class":257},"].",[125,394,395],{"class":131},"trim",[125,397,398],{"class":257},"())\n",[125,400,402],{"class":127,"line":401},7,[125,403,404],{"class":257},"}\n",[14,406,407,408,410],{},"Next boot, ",[18,409,98],{}," loads the file. The agent arrives pre-oriented — it starts from\nwhere it left off, not from scratch.",[212,412,414],{"id":413},"the-folder-durable-everywhere","The folder — durable everywhere",[14,416,417,418,420,421,424],{},"In cloud deployments, ",[18,419,168],{}," is backed by durable storage transparently. The agent\ncalls ",[18,422,423],{},"writeFile"," the same way locally and in production; no storage SDK, no\nenvironment checks. The folder is not just source — it is live runtime state.",[90,426,428],{"id":427},"the-progression","The progression",[14,430,431],{},"Most agents are stateless execution units. Axon agents can compound:",[433,434,435,442,448,454],"ol",{},[436,437,438,441],"li",{},[171,439,440],{},"Passive persistence"," — traces written automatically; the agent remembers what happened.",[436,443,444,447],{},[171,445,446],{},"Active accumulation"," — scripts write knowledge; memory grows deliberately.",[436,449,450,453],{},[171,451,452],{},"Capability expansion"," — policy permitting, the agent writes a new tool or installs\na module. Next session it can do something it couldn't before.",[436,455,456,459,460,467],{},[171,457,458],{},"Shared state"," — the ",[104,461,463,466],{"href":462},"\u002Fdocs\u002Fv2\u002Fworkspace",[18,464,465],{},".agents\u002F"," workspace standard"," lets\nknowledge and tools be shared across every agent working the same repo.",[14,469,470],{},"None of these require implementing anything. The folder is the interface; the agent\nwrites files; the runtime handles the rest.",[472,473,474],"style",{},"html pre.shiki code .sCudf, html code.shiki .sCudf{--shiki-default:#DCDCAA}html pre.shiki code .sOLPB, html code.shiki .sOLPB{--shiki-default:#6A9955}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 .scz_3, html code.shiki .scz_3{--shiki-default:#569CD6}html pre.shiki code .s9McN, html code.shiki .s9McN{--shiki-default:#4FC1FF}html pre.shiki code .sTNBD, html code.shiki .sTNBD{--shiki-default:#D4D4D4}html pre.shiki code .sYbnZ, html code.shiki .sYbnZ{--shiki-default:#C586C0}html pre.shiki code .s3F5K, html code.shiki .s3F5K{--shiki-default:#9CDCFE}html pre.shiki code .sxaxS, html code.shiki .sxaxS{--shiki-default:#D16969}html pre.shiki code .svVle, html code.shiki .svVle{--shiki-default:#D7BA7D}html pre.shiki code .sDGX8, html code.shiki .sDGX8{--shiki-default:#B5CEA8}",{"title":121,"searchDepth":139,"depth":139,"links":476},[477,478,479,480,481,486],{"id":92,"depth":139,"text":49},{"id":111,"depth":139,"text":60},{"id":176,"depth":139,"text":71},{"id":197,"depth":139,"text":82},{"id":206,"depth":139,"text":207,"children":482},[483,484,485],{"id":214,"depth":154,"text":215},{"id":225,"depth":154,"text":226},{"id":413,"depth":154,"text":414},{"id":427,"depth":139,"text":428},"An agent isn't a stateless function. Between a bare axon.request(\"hello\") and a\nmulti-day project thread there are four layers of state, each with its own scope and\nlifetime. Knowing which layer holds what explains why the agent remembers some things\nand not others — and how to make it remember the things you want.","md",{},"\u002Fdocs\u002Fv2\u002Fconcepts\u002Fstate-model",{"title":5,"description":487},"docs\u002Fv2\u002Fconcepts\u002Fstate-model","zx3UiFVR_Ja9GhpZJT2CHPJG5s3iNlSN882kpRcFVco",1785671807788]