## Compacts the conversation on request. ## ## The tool does no work itself: it returns a marker the agent acts on at the ## top of the next step, because replacing the history is an async operation ## (it needs a summarization call) and tool execution is synchronous. Same ## shape as resume_session and reload. class_name ClaudeGodotToolCompact extends ClaudeGodotTool func definition() -> Dictionary: return { "name": "compact", "description": "Compact the conversation: the earlier messages are replaced by a summary you write yourself, and the most recent turns are kept verbatim, so a long session can continue in a smaller context. Call it when the user asks to compact, clear or summarize the context, or when the session is getting long. Pass 'instruction' to focus the summary on something specific. This frees context but loses detail, so use it deliberately.", "input_schema": { "type": "object", "properties": { "instruction": {"type": "string", "description": "Optional: what the summary should focus on, e.g. 'keep the migration details'."} } } } func execute(input: Dictionary) -> Dictionary: return { "content": "Compacting the conversation now: your summary will replace the earlier messages, and the most recent turns are kept verbatim. Carry on from the summary on your next step.", "compact": true, "compact_instruction": str(input.get("instruction", "")).strip_edges(), }