Skip to content
Get started

Compact an objective

$ cadenya objectives compact
POST/v1/objectives/{objectiveId}/compact

Triggers compaction on a running objective. Optionally override the variation's compaction config.

ParametersExpand Collapse
--objective-id: string

Objective ID (from path)

--compaction-config: optional object { summarization, toolResultClearing, triggerThreshold }

CompactionConfig defines how context window compaction behaves for objectives using this variation.

ReturnsExpand Collapse
ObjectiveCompactResponse: object { contextWindow }

Compact objective response

contextWindow: optional object { completionTokens, objectiveId, previousWindowContinueInstructions, 2 more }

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.

Compact an objective

cadenya objectives compact \
  --api-key 'My API Key' \
  --objective-id objectiveId
{
  "contextWindow": {
    "completionTokens": 0,
    "objectiveId": "objectiveId",
    "previousWindowContinueInstructions": "previousWindowContinueInstructions",
    "promptTokens": 0,
    "sequence": 0
  }
}
Returns Examples
{
  "contextWindow": {
    "completionTokens": 0,
    "objectiveId": "objectiveId",
    "previousWindowContinueInstructions": "previousWindowContinueInstructions",
    "promptTokens": 0,
    "sequence": 0
  }
}