Short-term memory is the conversation context of messages, replies and tool results. Learn its structure, key settings, multi-stage compression on overflow, and commands to inspect or clear it.
Conversation context is the Agent’s short-term memory, containing all messages in the current session (user input, Agent replies, tool calls and results). Proper context management is critical for the Agent’s reasoning quality and cost control.
User message → Agent thinking → Tool call → Tool result → ... → Agent final reply
A single turn may include multiple tool calls (controlled by agent_max_steps). All tool calls and results are retained in context until compressed or trimmed.
Before each decision loop, the system checks tool call results in historical turns. Results exceeding 20,000 characters are truncated, keeping only the beginning and end with a truncation notice. Current turn results are not affected.
When conversation turns exceed agent_max_context_turns:
The oldest half of complete turns is trimmed (preserving tool call chain integrity)
Trimmed messages are summarized by LLM and written to the daily memory file
Once the LLM summary is ready, it is also injected into the first user message of the retained context, helping the model maintain conversational continuity
Summary injection runs asynchronously in the background and takes effect from the next turn onward
After turn trimming, if tokens still exceed the budget:
Fewer than 5 turns: All turns undergo text compression — each turn keeps only the first user text and last Agent reply, removing intermediate tool call chains
5 or more turns: The first half of turns is trimmed again, with discarded content written to memory and a context summary injected
Besides the automatic strategies above, you can compact context on demand with the /compact command. It reuses the same logic as automatic trimming — older turns are summarized by the LLM and injected into the retained context, while the most recent turns are kept intact. Unlike auto-trim, it runs immediately regardless of current token usage, which is handy for freeing context before a long task.
View current context statistics (message count, role distribution, total characters)
/clear
Clear current session context (/context clear still works as an alias)
/compact
Summarize older turns to free up context, keeping recent turns intact
/config agent_max_context_tokens 80000
Adjust context token budget
/config agent_max_context_turns 30
Adjust context turn limit
After clearing context, the Agent “forgets” previous conversation content. Content that was already written to long-term memory can still be retrieved via memory search.
{"docsConfig":{"theme":"mint","$schema":"https://mintlify.com/docs.json","name":"CowAgent","description":"CowAgent - AI Super Assistant powered by LLMs, with autonomous task planning, long-term memory, skills system, and multi-channel deployment.","colors":{"primary":"#35A85B","light":"#4ABE6E","dark":"#228547"},"logo":{"light":"https://mintcdn.com/minimalfuture/kFr6XLKqkl319blp/images/logo.jpg?fit=max\u0026auto=format\u0026n=kFr6XLKqkl319blp\u0026q=85\u0026s=71578eed432dfbc8615e84af3b5f2eab","dark":"https://mintcdn.com/minimalfuture/kFr6XLKqkl319blp/images/logo.jpg?fit=max\u0026auto=format\u0026n=kFr6XLKqkl319blp\u0026q=85\u0026s=71578eed432dfbc8615e84af3b5f2eab"},"favicon":"https://mintcdn.com/minimalfuture/kFr6XLKqkl319blp/images/favicon.ico?fit=max\u0026auto=format\u0026n=kFr6XLKqkl319blp\u0026q=85\u0026s=38cedc5ca4e6be81dc0609fe0e9c11ba","appearance":{"default":"light"},"navbar":{"links":[{"href":"https://cowagent.ai/","label":"官网"},{"href":"https://cowagent.ai/download/","label":"下载"},{"href":"https://cowagent.ai/zh/blog/","label":"博客"},{"href":"https://github.com/zhayujie/CowAgent","label":"GitHub"}]},"footer":{"socials":{"github":"https://github.com/zhayujie/CowAgent"}},"styling":{"latex":false},"navigation":{"languages":[{"language":"en","default":true,"navbar":{"links":[{"href":"https://cowagent.ai/","label":"Website"},{"href":"https://cowagent.ai/download/","label":"Download"},{"href":"https://cowagent.ai/blog/","label":"Blog"},{"href":"https://github.com/zhayujie/CowAgent","label":"GitHub"}]},"href":"intro"},{"language":"zh","navbar":{"links":[{"href":"https://cowagent.ai/?lang=zh","label":"官网"},{"href":"https://cowagent.ai/zh/download/","label":"下载"},{"href":"https://cowagent.ai/zh/blog/","label":"博客"},{"href":"https://github.com/zhayujie/CowAgent","label":"GitHub"}]},"href":"zh/intro"},{"language":"ja","navbar":{"links":[{"href":"https://cowagent.ai/","label":"ウェブサイト"},{"href":"https://cowagent.ai/download/","label":"ダウンロード"},{"href":"https://cowagent.ai/blog/","label":"ブログ"},{"href":"https://github.com/zhayujie/CowAgent","label":"GitHub"}]},"href":"ja/intro"}]}},"deployment":{"deploymentMetadataValue":{"subdomain":"minimalfuture","hasAudioNarration":false,"actualSubdomain":"minimalfuture","customDomains":["docs.cowagent.ai"],"gitSource":{"type":"github","owner":"zhayujie","repo":"cowagent","deployBranch":"master","contentDirectory":"docs","isPrivate":true,"mountPath":"","label":""},"entitlements":{},"buildId":"6af191674fec639ad50e106f","clientVersion":"0.0.4102","searchFilterCounts":[{"language":"en","tag":"Releases","count":24},{"language":"en","tag":"Release Notes","count":24},{"language":"ja","tag":"リリース","count":24},{"language":"ja","tag":"リリースノート","count":24},{"language":"zh","tag":"版本","count":24},{"language":"zh","tag":"发布记录","count":24},{"language":"en","tag":"Tools","count":18},{"language":"ja","tag":"ツール","count":18},{"language":"zh","tag":"工具","count":18},{"language":"en","tag":"Models","count":15},{"language":"en","tag":"Model Configuration","count":15},{"language":"ja","tag":"モデル","count":15},{"language":"ja","tag":"モデル設定","count":15},{"language":"zh","tag":"模型","count":15},{"language":"zh","tag":"模型配置","count":15},{"language":"en","tag":"Channels","count":13},{"language":"en","tag":"Platforms","count":13},{"language":"en","tag":"Built-in Tools","count":13},{"language":"ja","tag":"チャネル","count":13},{"language":"ja","tag":"プラットフォーム","count":13},{"language":"ja","tag":"内蔵ツール","count":13},{"language":"zh","tag":"通道","count":13},{"language":"zh","tag":"接入渠道","count":13},{"language":"zh","tag":"内置工具","count":13},{"language":"en","tag":"Skills","count":7},{"language":"ja","tag":"スキル","count":7},{"language":"zh","tag":"技能","count":7},{"language":"en","tag":"CLI","count":6},{"language":"zh","tag":"命令","count":6},{"language":"ja","tag":"CLI","count":5}]},"assistantConfig":{"enableAskAiButton":false,"enableStarterQuestions":false,"enableAskAiSearchBar":true},"basePath":"","hasChatPermissions":false,"hasWebMcpPermissions":false,"toggles":[{"name":"kill-isr","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"custom-rbac-roles","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"agent-mintlify-slack","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"agent-integrations-settings","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"rbac-expansion","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automations-pr-grouping","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"custom-prefix","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"analytics-v7","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"user-flows-analytics","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"no-publish-flow","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-onboarding","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"llms-txt-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"snapshot-serving-live","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"stripTemperatureMiddleware","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"support-platform-pylon-zendesk","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"snapshot-serving","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"instant-rollback","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"granular-notifications-server","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"granular-notifications","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automations-fable","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"fixed-ai-action-pricing","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automation-resolve-merge-conflict","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"scoped-publishing","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"mintql","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"page-level-analytics","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"editor-version-history-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"billing-page-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"full-page-search","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workspace-projects","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"assistant-v5","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"fork-pr-previews","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"revalidation-jwt","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-sso-scim","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"hobby-abuse-scan","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"dashboard-inbox","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-signup","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"turbopuffer-dual-write","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-enabled","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"approve-review-flow","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"editor-metadata","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"sso-setup-deadline-banner","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"turbopuffer-serve","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"live-agents","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false}],"googleFontsInlined":false},"customCss":[],"page":{"pagePath":"memory/context","slug":"/memory/context","pageMetadata":{"title":"Short-term Memory","description":"Short-term memory is the conversation context of messages, replies and tool results. Learn its structure, key settings, multi-stage compression on overflow, and commands to inspect or clear it.","href":"/memory/context"},"description":{"compiledSource":"\"use strict\";\nconst {jsx: _jsx} = arguments[0];\nconst {useMDXComponents: _provideComponents} = arguments[0];\nfunction _createMdxContent(props) {\n const _components = {\n p: \"p\",\n ..._provideComponents(),\n ...props.components\n };\n return _jsx(_components.p, {\n children: \"Short-term memory is the conversation context of messages, replies and tool results. Learn its structure, key settings, multi-stage compression on overflow, and commands to inspect or clear it.\"\n });\n}\nfunction MDXContent(props = {}) {\n const {wrapper: MDXLayout} = {\n ..._provideComponents(),\n ...props.components\n };\n return MDXLayout ? _jsx(MDXLayout, {\n ...props,\n children: _jsx(_createMdxContent, {\n ...props\n })\n }) : _createMdxContent(props);\n}\nreturn {\n default: MDXContent\n};\n","frontmatter":{},"scope":{}},"pageType":"default","mdx":{"mdxSource":{"compiledSource":"\"use strict\";const{Fragment:_Fragment,jsx:_jsx,jsxs:_jsxs}=arguments[0];const{useMDXComponents:_provideComponents}=arguments[0];function _createMdxContent(props){const _components={code:`code`,li:`li`,ol:`ol`,p:`p`,pre:`pre`,span:`span`,strong:`strong`,tbody:`tbody`,td:`td`,th:`th`,thead:`thead`,tr:`tr`,ul:`ul`,..._provideComponents(),...props.components},{CodeBlock,Heading,Table,Tip}=_components;if(!CodeBlock)_missingMdxReference(`CodeBlock`,true);if(!Heading)_missingMdxReference(`Heading`,true);if(!Table)_missingMdxReference(`Table`,true);if(!Tip)_missingMdxReference(`Tip`,true);return _jsxs(_Fragment,{children:[_jsx(_components.p,{children:`Conversation context is the Agent’s short-term memory, containing all messages in the current session (user input, Agent replies, tool calls and results). Proper context management is critical for the Agent’s reasoning quality and cost control.`}),`\n`,_jsx(Heading,{level:`2`,id:`context-structure`,children:`Context Structure`}),`\n`,_jsx(_components.p,{children:`Each conversation turn consists of:`}),`\n`,_jsx(CodeBlock,{numberOfLines:`2`,language:`text`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`text`,children:_jsxs(_components.code,{language:`text`,numberOfLines:`2`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`User message → Agent thinking → Tool call → Tool result → ... → Agent final reply`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{})})]})})}),`\n`,_jsxs(_components.p,{children:[`A single turn may include multiple tool calls (controlled by `,_jsx(_components.code,{children:`agent_max_steps`}),`). All tool calls and results are retained in context until compressed or trimmed.`]}),`\n`,_jsx(Heading,{level:`2`,id:`key-configuration`,children:`Key Configuration`}),`\n`,_jsxs(Table,{children:[_jsx(_components.thead,{children:_jsxs(_components.tr,{children:[_jsx(_components.th,{children:`Parameter`}),_jsx(_components.th,{children:`Description`}),_jsx(_components.th,{children:`Default`})]})}),_jsxs(_components.tbody,{children:[_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`agent_max_context_tokens`})}),_jsx(_components.td,{children:`Maximum context token budget`}),_jsx(_components.td,{\"data-numeric\":`true`,children:_jsx(_components.code,{children:`200000`})})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`agent_max_context_turns`})}),_jsx(_components.td,{children:`Maximum conversation turns in context`}),_jsx(_components.td,{\"data-numeric\":`true`,children:_jsx(_components.code,{children:`30`})})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`agent_max_steps`})}),_jsx(_components.td,{children:`Maximum decision steps per turn (tool call count)`}),_jsx(_components.td,{\"data-numeric\":`true`,children:_jsx(_components.code,{children:`100`})})]}),_jsxs(_components.tr,{children:[_jsxs(_components.td,{children:[`Configurable via `,_jsx(_components.code,{children:`config.json`}),` or the `,_jsx(_components.code,{children:`/config`}),` chat command.`]}),_jsx(_components.td,{}),_jsx(_components.td,{})]})]})]}),`\n`,_jsx(Heading,{level:`2`,id:`compression-strategy`,children:`Compression Strategy`}),`\n`,_jsx(_components.p,{children:`When context exceeds limits, the system automatically compresses to free space. The process has multiple stages:`}),`\n`,_jsx(Heading,{level:`3`,id:`1-tool-result-truncation`,children:`1. Tool Result Truncation`}),`\n`,_jsxs(_components.p,{children:[`Before each decision loop, the system checks tool call results in historical turns. Results exceeding `,_jsx(_components.strong,{children:`20,000 characters`}),` are truncated, keeping only the beginning and end with a truncation notice. Current turn results are not affected.`]}),`\n`,_jsx(Heading,{level:`3`,id:`2-turn-trimming`,children:`2. Turn Trimming`}),`\n`,_jsxs(_components.p,{children:[`When conversation turns exceed `,_jsx(_components.code,{children:`agent_max_context_turns`}),`:`]}),`\n`,_jsxs(_components.ul,{children:[`\n`,_jsxs(_components.li,{children:[`The `,_jsx(_components.strong,{children:`oldest half`}),` of complete turns is trimmed (preserving tool call chain integrity)`]}),`\n`,_jsxs(_components.li,{children:[`Trimmed messages are summarized by LLM and `,_jsx(_components.strong,{children:`written to the daily memory file`})]}),`\n`,_jsxs(_components.li,{children:[`Once the LLM summary is ready, it is also `,_jsx(_components.strong,{children:`injected into the first user message`}),` of the retained context, helping the model maintain conversational continuity`]}),`\n`,_jsx(_components.li,{children:`Summary injection runs asynchronously in the background and takes effect from the next turn onward`}),`\n`]}),`\n`,_jsx(Heading,{level:`3`,id:`3-token-budget-trimming`,children:`3. Token Budget Trimming`}),`\n`,_jsx(_components.p,{children:`After turn trimming, if tokens still exceed the budget:`}),`\n`,_jsxs(_components.ul,{children:[`\n`,_jsxs(_components.li,{children:[_jsx(_components.strong,{children:`Fewer than 5 turns`}),`: All turns undergo `,_jsx(_components.strong,{children:`text compression`}),` — each turn keeps only the first user text and last Agent reply, removing intermediate tool call chains`]}),`\n`,_jsxs(_components.li,{children:[_jsx(_components.strong,{children:`5 or more turns`}),`: The `,_jsx(_components.strong,{children:`first half`}),` of turns is trimmed again, with discarded content written to memory and a context summary injected`]}),`\n`]}),`\n`,_jsx(Heading,{level:`3`,id:`4-overflow-emergency-handling`,children:`4. Overflow Emergency Handling`}),`\n`,_jsx(_components.p,{children:`When the model API returns a context overflow error:`}),`\n`,_jsxs(_components.ol,{children:[`\n`,_jsx(_components.li,{children:`All current messages are summarized and written to memory`}),`\n`,_jsx(_components.li,{children:`Aggressive trimming is applied (tool results limited to 10K chars, user text to 10K, max 5 turns)`}),`\n`,_jsx(_components.li,{children:`If still overflowing, the entire conversation context is cleared`}),`\n`]}),`\n`,_jsx(Heading,{level:`3`,id:`5-manual-compaction`,children:`5. Manual Compaction`}),`\n`,_jsxs(_components.p,{children:[`Besides the automatic strategies above, you can compact context on demand with the `,_jsx(_components.code,{children:`/compact`}),` command. It reuses the same logic as automatic trimming — older turns are summarized by the LLM and injected into the retained context, while the most recent turns are kept intact. Unlike auto-trim, it runs immediately regardless of current token usage, which is handy for freeing context before a long task.`]}),`\n`,_jsx(Heading,{level:`2`,id:`session-persistence`,children:`Session Persistence`}),`\n`,_jsx(_components.p,{children:`Conversation messages are persisted to a local database, automatically restored after service restart. Restore strategy:`}),`\n`,_jsxs(_components.ul,{children:[`\n`,_jsxs(_components.li,{children:[`Restores the most recent `,_jsx(_components.strong,{children:_jsx(_components.code,{children:`max(3, max_context_turns / 6)`})}),` turns`]}),`\n`,_jsxs(_components.li,{children:[`Only retains each turn’s `,_jsx(_components.strong,{children:`user text and Agent final reply`}),`, not intermediate tool call chains`]}),`\n`,_jsxs(_components.li,{children:[`Sessions older than `,_jsx(_components.strong,{children:`30 days`}),` are automatically cleaned up`]}),`\n`]}),`\n`,_jsx(Heading,{level:`2`,id:`commands`,children:`Commands`}),`\n`,_jsx(_components.p,{children:`Use these commands in chat to manage context:`}),`\n`,_jsxs(Table,{children:[_jsx(_components.thead,{children:_jsxs(_components.tr,{children:[_jsx(_components.th,{children:`Command`}),_jsx(_components.th,{children:`Description`})]})}),_jsxs(_components.tbody,{children:[_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`/context`})}),_jsx(_components.td,{children:`View current context statistics (message count, role distribution, total characters)`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`/clear`})}),_jsxs(_components.td,{children:[`Clear current session context (`,_jsx(_components.code,{children:`/context clear`}),` still works as an alias)`]})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`/compact`})}),_jsx(_components.td,{children:`Summarize older turns to free up context, keeping recent turns intact`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`/config agent_max_context_tokens 80000`})}),_jsx(_components.td,{children:`Adjust context token budget`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`/config agent_max_context_turns 30`})}),_jsx(_components.td,{children:`Adjust context turn limit`})]})]})]}),`\n`,_jsx(Tip,{children:_jsx(_components.p,{children:`After clearing context, the Agent “forgets” previous conversation content. Content that was already written to long-term memory can still be retrieved via memory search.`})})]})}function MDXContent(props={}){const{wrapper:MDXLayout}={..._provideComponents(),...props.components};return MDXLayout?_jsx(MDXLayout,{...props,children:_jsx(_createMdxContent,{...props})}):_createMdxContent(props)}return{default:MDXContent};function _missingMdxReference(id,component){throw new Error(`Expected `+(component?`component`:`object`)+\" `\"+id+\"` to be defined: you likely forgot to import, pass, or provide it.\")}","frontmatter":{},"scope":{"config":{},"pageMetadata":{"title":"Short-term Memory","description":"Short-term memory is the conversation context of messages, replies and tool results. Learn its structure, key settings, multi-stage compression on overflow, and commands to inspect or clear it.","href":"/memory/context"}}},"mdxSourceWithNoJs":null},"mdxExtracts":{"tableOfContents":[{"title":"Context Structure","slug":"context-structure","depth":2,"children":[]},{"title":"Key Configuration","slug":"key-configuration","depth":2,"children":[]},{"title":"Compression Strategy","slug":"compression-strategy","depth":2,"children":[{"title":"1. Tool Result Truncation","slug":"1-tool-result-truncation","depth":3,"children":[]},{"title":"2. Turn Trimming","slug":"2-turn-trimming","depth":3,"children":[]},{"title":"3. Token Budget Trimming","slug":"3-token-budget-trimming","depth":3,"children":[]},{"title":"4. Overflow Emergency Handling","slug":"4-overflow-emergency-handling","depth":3,"children":[]},{"title":"5. Manual Compaction","slug":"5-manual-compaction","depth":3,"children":[]}]},{"title":"Session Persistence","slug":"session-persistence","depth":2,"children":[]},{"title":"Commands","slug":"commands","depth":2,"children":[]}],"codeExamples":{}},"jsLinks":["/_mintlify/custom/minimalfuture/ddae7aac1b554a23/assistant-widget.js"],"subdomain":"minimalfuture","siteName":"CowAgent","title":"Short-term Memory - CowAgent","navMaps":{"firstHrefInVersion":{},"firstHrefInLanguage":{"en":{"href":"/memory/context","matchLevel":0},"zh":{"href":"/zh/memory/context","matchLevel":1},"ja":{"href":"/ja/memory/context","matchLevel":1}}},"lastModified":"2026-10-16T09:14:52.686Z","originalFileLocation":"memory/context.mdx","locale":"en"},"headHtml":"\u003cscript data-mint-head>(function(){var d=document.documentElement,p=null;if(!p){try{p=localStorage.getItem(\"isDarkMode\")}catch(e){}if(p==='true')p='dark';else if(p==='false')p='light';if(p!=='light'\u0026\u0026p!=='dark'\u0026\u0026p!=='system')p=\"light\"}var r=p==='system'?(matchMedia(\"(prefers-color-scheme: dark)\").matches?'dark':'light'):p;d.classList.remove(r==='dark'?'light':'dark');d.classList.add(r);d.setAttribute(\"data-theme-preference\",p)})();\u003c/script>\u003cmeta data-mint-head name=\"description\" content=\"Short-term memory is the conversation context of messages, replies and tool results. Learn its structure, key settings, multi-stage compression on overflow, and commands to inspect or clear it.\">\u003cmeta data-mint-head name=\"application-name\" content=\"CowAgent\">\u003cmeta data-mint-head name=\"generator\" content=\"Mintlify\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"192x192\" href=\"/mintlify-assets/_mintlify/favicons/minimalfuture/gk-TAsZO3835JLt2/_generated/favicon/android-chrome-192x192.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"apple-touch-icon\" type=\"image/png\" sizes=\"180x180\" href=\"/mintlify-assets/_mintlify/favicons/minimalfuture/gk-TAsZO3835JLt2/_generated/favicon/apple-touch-icon.png\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"16x16\" href=\"/mintlify-assets/_mintlify/favicons/minimalfuture/gk-TAsZO3835JLt2/_generated/favicon/favicon-16x16.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"32x32\" href=\"/mintlify-assets/_mintlify/favicons/minimalfuture/gk-TAsZO3835JLt2/_generated/favicon/favicon-32x32.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"shortcut icon\" type=\"image/x-icon\" href=\"/mintlify-assets/_mintlify/favicons/minimalfuture/gk-TAsZO3835JLt2/_generated/favicon/favicon.ico\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"192x192\" href=\"/mintlify-assets/_mintlify/favicons/minimalfuture/gk-TAsZO3835JLt2/_generated/favicon-dark/android-chrome-192x192.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"16x16\" href=\"/mintlify-assets/_mintlify/favicons/minimalfuture/gk-TAsZO3835JLt2/_generated/favicon-dark/favicon-16x16.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"32x32\" href=\"/mintlify-assets/_mintlify/favicons/minimalfuture/gk-TAsZO3835JLt2/_generated/favicon-dark/favicon-32x32.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"shortcut icon\" type=\"image/x-icon\" href=\"/mintlify-assets/_mintlify/favicons/minimalfuture/gk-TAsZO3835JLt2/_generated/favicon-dark/favicon.ico\" media=\"(prefers-color-scheme: dark)\">\u003cmeta data-mint-head property=\"og:title\" content=\"Short-term Memory - CowAgent\">\u003cmeta data-mint-head property=\"og:description\" content=\"Short-term memory is the conversation context of messages, replies and tool results. Learn its structure, key settings, multi-stage compression on overflow, and commands to inspect or clear it.\">\u003cmeta data-mint-head property=\"og:site_name\" content=\"CowAgent\">\u003cmeta data-mint-head property=\"og:url\" content=\"https://docs.cowagent.ai/memory/context\">\u003cmeta data-mint-head property=\"og:type\" content=\"website\">\u003cmeta data-mint-head property=\"og:image\" content=\"https://minimalfuture.mintlify.site/_mintlify/api/og/v2?division=Memory+System\u0026amp;title=Short-term+Memory\u0026amp;description=Short-term+memory+is+the+conversation+context+of+messages%2C+replies+and+tool+results.+Learn+its+structure%2C+key+settings%2C+multi-stage+compression+on+overflow%2C+and\u0026amp;theme=1c6a1c597400232a318b362c\u0026amp;signature=1ae472f3a33bbe90c9bc42c51dc164d7ea75e51e80525d73b8ff6b576baa9fa0\">\u003cmeta data-mint-head property=\"og:image:width\" content=\"1200\">\u003cmeta data-mint-head property=\"og:image:height\" content=\"630\">\u003cmeta data-mint-head name=\"twitter:card\" content=\"summary_large_image\">\u003cmeta data-mint-head name=\"twitter:title\" content=\"Short-term Memory - CowAgent\">\u003cmeta data-mint-head name=\"twitter:description\" content=\"Short-term memory is the conversation context of messages, replies and tool results. Learn its structure, key settings, multi-stage compression on overflow, and commands to inspect or clear it.\">\u003cmeta data-mint-head name=\"twitter:image\" content=\"https://minimalfuture.mintlify.site/_mintlify/api/og/v2?division=Memory+System\u0026amp;title=Short-term+Memory\u0026amp;description=Short-term+memory+is+the+conversation+context+of+messages%2C+replies+and+tool+results.+Learn+its+structure%2C+key+settings%2C+multi-stage+compression+on+overflow%2C+and\u0026amp;theme=1c6a1c597400232a318b362c\u0026amp;signature=1ae472f3a33bbe90c9bc42c51dc164d7ea75e51e80525d73b8ff6b576baa9fa0\">\u003cmeta data-mint-head name=\"twitter:image:width\" content=\"1200\">\u003cmeta data-mint-head name=\"twitter:image:height\" content=\"630\">\u003cmeta data-mint-head name=\"msapplication-config\" content=\"/mintlify-assets/_mintlify/favicons/minimalfuture/gk-TAsZO3835JLt2/_generated/favicon/browserconfig.xml\">\u003cmeta data-mint-head name=\"apple-mobile-web-app-title\" content=\"CowAgent\">\u003cmeta data-mint-head name=\"msapplication-TileColor\" content=\"#35A85B\">\u003clink data-mint-head rel=\"canonical\" href=\"https://docs.cowagent.ai/memory/context\">\u003clink data-mint-head rel=\"alternate\" type=\"application/xml\" href=\"/sitemap.xml\">\u003clink data-mint-head rel=\"alternate\" type=\"text/markdown\" href=\"/memory/context.md\">\u003clink data-mint-head rel=\"alternate\" hreflang=\"en\" href=\"https://docs.cowagent.ai/memory/context\">\u003clink data-mint-head rel=\"alternate\" hreflang=\"zh\" href=\"https://docs.cowagent.ai/zh/memory/context\">\u003clink data-mint-head rel=\"alternate\" hreflang=\"ja\" href=\"https://docs.cowagent.ai/ja/memory/context\">\u003clink data-mint-head rel=\"alternate\" hreflang=\"x-default\" href=\"https://docs.cowagent.ai/memory/context\">\u003cscript data-mint-head type=\"application/ld+json\">{\"@context\":\"https://schema.org\",\"@graph\":[{\"@type\":\"Organization\",\"@id\":\"https://docs.cowagent.ai/#organization\",\"name\":\"CowAgent\",\"url\":\"https://docs.cowagent.ai\",\"logo\":{\"@type\":\"ImageObject\",\"url\":\"https://mintcdn.com/minimalfuture/kFr6XLKqkl319blp/images/logo.jpg?fit=max\u0026auto=format\u0026n=kFr6XLKqkl319blp\u0026q=85\u0026s=71578eed432dfbc8615e84af3b5f2eab\"}},{\"@type\":\"WebSite\",\"@id\":\"https://docs.cowagent.ai#website\",\"name\":\"CowAgent\",\"url\":\"https://docs.cowagent.ai\",\"publisher\":{\"@id\":\"https://docs.cowagent.ai/#organization\"}},{\"@type\":\"WebPage\",\"@id\":\"https://docs.cowagent.ai/memory/context#webpage\",\"url\":\"https://docs.cowagent.ai/memory/context\",\"name\":\"Short-term Memory\",\"description\":\"Short-term memory is the conversation context of messages, replies and tool results. Learn its structure, key settings, multi-stage compression on overflow, and commands to inspect or clear it.\",\"dateModified\":\"2026-10-16T09:14:52.686Z\",\"isPartOf\":{\"@id\":\"https://docs.cowagent.ai#website\"},\"breadcrumb\":{\"@id\":\"https://docs.cowagent.ai/memory/context#breadcrumb\"}},{\"@type\":\"BreadcrumbList\",\"@id\":\"https://docs.cowagent.ai/memory/context#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Memory System\",\"item\":\"https://docs.cowagent.ai/memory\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Short-term Memory\",\"item\":\"https://docs.cowagent.ai/memory/context\"}]},{\"@type\":[\"Article\",\"TechArticle\"],\"@id\":\"https://docs.cowagent.ai/memory/context#article\",\"headline\":\"Short-term Memory\",\"name\":\"Short-term Memory\",\"description\":\"Short-term memory is the conversation context of messages, replies and tool results. Learn its structure, key settings, multi-stage compression on overflow, and commands to inspect or clear it.\",\"url\":\"https://docs.cowagent.ai/memory/context\",\"mainEntityOfPage\":{\"@id\":\"https://docs.cowagent.ai/memory/context#webpage\"},\"dateModified\":\"2026-10-16T09:14:52.686Z\",\"publisher\":{\"@id\":\"https://docs.cowagent.ai/#organization\"},\"isPartOf\":{\"@id\":\"https://docs.cowagent.ai#website\"}}]}\u003c/script>\u003cscript data-mint-head type=\"application/ld+json\">{\"@context\":\"https://schema.org\",\"@type\":\"WebSite\",\"name\":\"CowAgent\",\"publisher\":{\"@type\":\"Organization\",\"name\":\"CowAgent\"},\"provider\":{\"@type\":\"Organization\",\"name\":\"Mintlify\",\"url\":\"https://mintlify.com\"}}\u003c/script>","agentPointerHref":"/memory/context.md","siteName":"CowAgent","nav":{"global":null,"languages":[{"language":"en","default":true,"navbar":{"links":[{"href":"https://cowagent.ai/","label":"Website"},{"href":"https://cowagent.ai/download/","label":"Download"},{"href":"https://cowagent.ai/blog/","label":"Blog"},{"href":"https://github.com/zhayujie/CowAgent","label":"GitHub"}]},"tabs":[{"tab":"Introduction","pages":[{"title":"Introduction","href":"/intro"}]},{"tab":"Get Started","pages":[{"title":"Get Started","href":"/guide/quick-start"}]},{"tab":"Models","pages":[{"title":"Models","href":"/models"}]},{"tab":"Tools","pages":[{"title":"Tools","href":"/tools"}]},{"tab":"Skills","pages":[{"title":"Skills","href":"/skills"}]},{"tab":"Memory","groups":[{"group":"Memory System","pages":[{"title":"Long-term Memory","description":"CowAgent's long-term memory: core memory in MEMORY.md, daily memories and dream diaries stored as workspace files, written automatically when context is trimmed and recalled with hybrid search.","href":"/memory"},{"title":"Short-term Memory","href":"/memory/context"},{"title":"Deep Dream","description":"Deep Dream is CowAgent's memory consolidation: conversations become daily memories, which are distilled into MEMORY.md every day along with a dream diary. Covers triggers, the process and manual runs.","href":"/memory/deep-dream"},{"title":"Self-Evolution","href":"/memory/self-evolution"}]}]},{"tab":"Knowledge","pages":[{"title":"Knowledge","href":"/knowledge"}]},{"tab":"Channels","pages":[{"title":"Channels","href":"/channels"}]},{"tab":"CLI","pages":[{"title":"CLI","href":"/cli"}]},{"tab":"Multi-Agent","pages":[{"title":"Multi-Agent","href":"/multi-agent/team"}]},{"tab":"Extensions","pages":[{"title":"Extensions","href":"/extensions/chat-api"}]},{"tab":"Releases","pages":[{"title":"Releases","href":"/releases/overview"}]}]},{"language":"zh","navbar":{"links":[{"href":"https://cowagent.ai/?lang=zh","label":"官网"},{"href":"https://cowagent.ai/zh/download/","label":"下载"},{"href":"https://cowagent.ai/zh/blog/","label":"博客"},{"href":"https://github.com/zhayujie/CowAgent","label":"GitHub"}]},"pages":[{"title":"zh","href":"/zh/memory/context"}]},{"language":"ja","navbar":{"links":[{"href":"https://cowagent.ai/","label":"ウェブサイト"},{"href":"https://cowagent.ai/download/","label":"ダウンロード"},{"href":"https://cowagent.ai/blog/","label":"ブログ"},{"href":"https://github.com/zhayujie/CowAgent","label":"GitHub"}]},"pages":[{"title":"ja","href":"/ja/memory/context"}]}]},"basePath":"","title":"Short-term Memory - CowAgent","buildId":"dpl_596ePT575z4qnAFksq1biRW97aLY","deploymentId":"dpl_596ePT575z4qnAFksq1biRW97aLY","dynamics":[],"chunks":[]}