## Compact an objective **post** `/v1/objectives/{objectiveId}/compact` Triggers compaction on a running objective. Optionally override the variation's compaction config. ### Path Parameters - `objectiveId: string` ### Body Parameters - `compactionConfig: optional AgentVariationSpecCompactionConfig` CompactionConfig defines how context window compaction behaves for objectives using this variation. - `summarization: optional CompactionConfigSummarizationStrategy` SummarizationStrategy configures LLM-powered summarization of older conversation turns. - `instructions: optional string` Custom instructions that guide what the summarizer preserves. Replaces the default summarization prompt entirely. Example: "Preserve all code snippets, variable names, and technical decisions." - `toolResultClearing: optional CompactionConfigToolResultClearingStrategy` ToolResultClearingStrategy configures clearing of older tool result content. - `preserveRecentResults: optional number` Number of most recent tool call results to keep intact. Older tool results have their content replaced with "[result cleared]" while preserving the assistant tool call message (function name, arguments). Default: 2 - `triggerThreshold: optional number` Trigger threshold as a percentage of the model's context window (0.0 to 1.0). When input tokens reach this percentage of the model's limit, compaction triggers. Default: 0.75 (75%) ### Returns - `contextWindow: optional ObjectiveContextWindowData` The new context window created by the compaction - `completionTokens: optional number` A calculated value for how many completion tokens (output tokens) have been used in this context window - `objectiveId: optional string` The objective's ID that this window belongs to - `previousWindowContinueInstructions: optional string` The instructions for this window to continue from a previous window's chat history. - `promptTokens: optional number` A calculated value for how many prompt tokens (input tokens) have been used in this context window - `sequence: optional number` sequence is a numeric representation of which context window this is. Sequences are useful to perform a max(sequence) on in order to calculate how many context windows an objective has. ### Example ```http curl https://api.cadenya.com/v1/objectives/$OBJECTIVE_ID/compact \ -H 'Content-Type: application/json' \ -H "Authorization: Bearer $CADENYA_API_KEY" \ -d '{}' ``` #### Response ```json { "contextWindow": { "completionTokens": 0, "objectiveId": "objectiveId", "previousWindowContinueInstructions": "previousWindowContinueInstructions", "promptTokens": 0, "sequence": 0 } } ```