Context Management · Compaction

Compaction Server-side context compaction for managing long conversations that approaching context window limits 1 Server-side compaction is the recommended strategy for managing context in long-running conversations and agentic workflows. It handles context management automatically, without client-side summarization code. as a conversation grows, response quality degrades,Compaction extends the effective context length for long-running conversations and tasks compaction replaces older content with a concise summary. This is ideal for: Chat-based, multi-turn conversations where you want users to use one chat for a long period of time Task-oriented prompts that require a lot of follow-up work (often tool use) that might exceed the context window How compaction works four steps: ...

上下文工程
2026-09-065 分钟2022 字chenghaoning51

Context Management · Context Windows

Context windows Understand how the context window works, how extended thinking and tool use count toward it, and how to manage context as conversations grow. the primary strategy is server-side-compaction How the context window works what is the context window: The “context window” refers to all the text a language model can reference when generating a response, including the response itself. https://platform.claude.com/docs/images/context-window.svg As token count grows, accuracy and recall degrade, a phenomenon known as context rot. ...

上下文工程
2026-09-062 分钟860 字chenghaoning51

Context Management · Context Editing

Context editing Automatically manage conversation context as it grows with context editing 注意断句 Overview The strategies on this page are useful for specific scenarios where you need more fine-grained control over what content is cleared. 更适用于在特定场景中,你需要清楚哪些内容进行更加细粒度的控制 Context editing allows you to selectively clear specific content from conversation history as it grows. Beyond optimizing costs and staying within limits, this is about actively curating what Claude sees: context is a finite resource with diminishing returns, and irrelevant content degrades model focus. Context editing gives you fine-grained runtime control over that curation. For the broader principles behind context management, see Effective context engineering. ...

上下文工程
2026-09-062 分钟791 字chenghaoning51

Build An Orchestration Mode

Build an orchestration mode Build a session-level mode that grants standing consent for multiagent fan-out, switched on and off with mid-conversation system messages. 会话级别的;持续性凭证;multiagent;mid-conversation 编排模式(orchestration mode)是一种会话级开关:当他开启时,model will pay most efforts to every request,先自行见检查和分析任务,然后默认将工作拆分给几个并发的子智能体 It is not an API parameter. It is built entirely from documented pieces ...

上下文工程
6 分钟2609 字chenghaoning51

Mid-conversation-system-messages-and-tool-changes

Mid-conversation system messages and tool changes Change system instructions or tool availability partway through a conversation without invalidating the cached prefix that came before them. 在不使缓存失效的情况下,更改系统指令或者工具可用性 system instructions normally live in the top-level system field it is great for prompt caching: because it is stable prefix Mid-conversation system message will not change the cached prefix ,and you append a {“role”: “system”},and this instruction is still applied ad system instruction rather than as a ordinary user text ...

上下文工程
6 分钟2882 字chenghaoning51

Mid-conversation

Mid-conversation system messages and tool changes 原文:Mid-conversation system messages and tool changes 在对话进行到一半时更改 system 指令或工具可用性,同时不使此前已缓存的 prefix 失效。 关于 zero data retention (ZDR) 如何适用于本功能,参见 API and data retention。 System 指令通常放在顶层 system 字段中,位于对话里所有 message 之前。这个位置非常适合 prompt caching:system prompt 属于稳定的 prefix,因此后续 turn 可以命中 cache。但如果你是在会话进行到一半才发现需要某条指令,这个位置就不合适了——因为修改顶层 system 字段会改变 prompt 的最开头,从而使其后全部内容的 cache 失效。 ...

上下文工程
15 分钟7300 字chenghaoning51

Prompt Caching

Prompt Caching 使用cache_control来缓存提示词前缀,使用自动缓存或者使用显示缓存断点:具有5分钟或者1h的存活时间的断点 Prompt caching允许你从提示词中的特定前缀继续处理,来优化API的使用 ...

上下文工程
10 分钟4609 字chenghaoning51