## Compact an objective `client.Objectives.Compact(ctx, objectiveID, body) (*ObjectiveCompactResponse, error)` **post** `/v1/objectives/{objectiveId}/compact` Triggers compaction on a running objective. Optionally override the variation's compaction config. ### Parameters - `objectiveID string` - `body ObjectiveCompactParams` - `CompactionConfig param.Field[AgentVariationSpecCompactionConfig]` CompactionConfig defines how context window compaction behaves for objectives using this variation. ### Returns - `type ObjectiveCompactResponse struct{…}` Compact objective response - `ContextWindow ObjectiveContextWindowData` The new context window created by the compaction - `CompletionTokens int64` A calculated value for how many completion tokens (output tokens) have been used in this context window - `ObjectiveID string` The objective's ID that this window belongs to - `PreviousWindowContinueInstructions string` The instructions for this window to continue from a previous window's chat history. - `PromptTokens int64` A calculated value for how many prompt tokens (input tokens) have been used in this context window - `Sequence int64` 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 ```go package main import ( "context" "fmt" "github.com/cadenya/cadenya-go" "github.com/cadenya/cadenya-go/option" ) func main() { client := cadenya.NewClient( option.WithAPIKey("My API Key"), ) response, err := client.Objectives.Compact( context.TODO(), "objectiveId", cadenya.ObjectiveCompactParams{ }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", response.ContextWindow) } ``` #### Response ```json { "contextWindow": { "completionTokens": 0, "objectiveId": "objectiveId", "previousWindowContinueInstructions": "previousWindowContinueInstructions", "promptTokens": 0, "sequence": 0 } } ```