Home / File/ _beta_compaction_control.py — anthropic-sdk-python Source File

_beta_compaction_control.py — anthropic-sdk-python Source File

Architecture documentation for _beta_compaction_control.py, a python file in the anthropic-sdk-python codebase. 2 imports, 1 dependents.

File python ExtensibilityTools 2 imports 1 dependents 1 classes

Entity Profile

Dependency Diagram

graph LR
  af98aab0_f1fc_18e5_6340_25ca580ef0d0["_beta_compaction_control.py"]
  89ddcdd7_3ae1_4c7b_41bb_9f1e25f16875["typing"]
  af98aab0_f1fc_18e5_6340_25ca580ef0d0 --> 89ddcdd7_3ae1_4c7b_41bb_9f1e25f16875
  37c05070_ca59_d596_7250_de9d1939227f["typing_extensions"]
  af98aab0_f1fc_18e5_6340_25ca580ef0d0 --> 37c05070_ca59_d596_7250_de9d1939227f
  34260b96_4096_ba59_bee2_0b2a94476dcc["_beta_runner.py"]
  34260b96_4096_ba59_bee2_0b2a94476dcc --> af98aab0_f1fc_18e5_6340_25ca580ef0d0
  style af98aab0_f1fc_18e5_6340_25ca580ef0d0 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

from typing import TypedDict
from typing_extensions import Required

DEFAULT_SUMMARY_PROMPT = """You have been working on the task described above but have not yet completed it. Write a continuation summary that will allow you (or another instance of yourself) to resume work efficiently in a future context window where the conversation history will be replaced with this summary. Your summary should be structured, concise, and actionable. Include:
1. Task Overview
The user's core request and success criteria
Any clarifications or constraints they specified
2. Current State
What has been completed so far
Files created, modified, or analyzed (with paths if relevant)
Key outputs or artifacts produced
3. Important Discoveries
Technical constraints or requirements uncovered
Decisions made and their rationale
Errors encountered and how they were resolved
What approaches were tried that didn't work (and why)
4. Next Steps
Specific actions needed to complete the task
Any blockers or open questions to resolve
Priority order if multiple steps remain
5. Context to Preserve
User preferences or style requirements
Domain-specific details that aren't obvious
Any promises made to the user
Be concise but complete—err on the side of including information that would prevent duplicate work or repeated mistakes. Write in a way that enables immediate resumption of the task.
Wrap your summary in <summary></summary> tags."""

DEFAULT_THRESHOLD = 100_000


class CompactionControl(TypedDict, total=False):
    context_token_threshold: int
    """The context token threshold at which to trigger compaction.

    When the cumulative token count (input + output) across all messages exceeds this threshold,
    the message history will be automatically summarized and compressed. Defaults to 100,000 tokens.
    """

    model: str
    """
    The model to use for generating the compaction summary.
    If not specified, defaults to the same model used for the tool runner.
    """

    summary_prompt: str
    """The prompt used to instruct the model on how to generate the summary."""

    enabled: Required[bool]

Dependencies

  • typing
  • typing_extensions

Frequently Asked Questions

What does _beta_compaction_control.py do?
_beta_compaction_control.py is a source file in the anthropic-sdk-python codebase, written in python. It belongs to the ExtensibilityTools domain.
What does _beta_compaction_control.py depend on?
_beta_compaction_control.py imports 2 module(s): typing, typing_extensions.
What files import _beta_compaction_control.py?
_beta_compaction_control.py is imported by 1 file(s): _beta_runner.py.
Where is _beta_compaction_control.py in the architecture?
_beta_compaction_control.py is located at src/anthropic/lib/tools/_beta_compaction_control.py (domain: ExtensibilityTools, directory: src/anthropic/lib/tools).

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free