JavaScript
Objectives
List objective context windows
Every window an objective has burned through, with the token counts and the summary each one handed to the next.
GET
JavaScript
An objective starts with one context window. When it fills past the compaction threshold, Cadenya opens a fresh one and carries a summary forward. This endpoint is the record of that: what each window cost, and what survived the handoff.
It is also the only token history that outlives the objective.
Windows come back newest first, and the endpoint returns at most the last five. A long objective that compacted a dozen times has lost the early ones.
The first window’s
Reading a compaction
That output is a real compaction, and it tells the whole story. Window 1 grew to 8,718 prompt tokens. It crossed the threshold, so Cadenya summarized it, opened window 2, and window 2 restarted at 3,345 prompt tokens. The summary itself is on the new window, aspreviousWindowContinueInstructions:
previousWindowContinueInstructions is empty, because nothing preceded it. That is how you tell the original window from a compacted one: sequence: 1 with no instructions.
Read the summary when an agent seems to forget something mid-objective. Compaction is lossy by design, and this field is exactly what it chose to keep. If the thing the agent lost is missing here, tune summarization.instructions on the variation.
Use it for the post-mortem
Objective diagnostics gives a much richer breakdown, per component, but only while the objective is live. Every terminal objective reports zeros there. Context windows persist. The sameSTATE_TIMED_OUT objective that reports inputTokens: 0 from diagnostics still reports promptTokens: 34653 here.
totalContextWindows counts every window, including any the five-window cap has aged out of this list.
What each window carries
Sum
promptTokens and completionTokens across windows and multiply by the model’s inputPricePerMillionTokens and outputPricePerMillionTokens to price a run. That is the closest thing to a per-objective invoice the API offers.
Compaction itself costs a model call: the summarizer runs on the variation’s own model, and its usage is recorded as an iteration. A window’s
promptTokens is what the agent spent, not what compaction spent producing the summary that opened it.Related
Get objective diagnostics
The live, component-by-component breakdown of the current window.
Create a variation
triggerThreshold, summarization instructions, and tool result clearing.Compaction
Why an objective compacts instead of failing.
List models
The per-million-token prices you need to turn tokens into dollars.
Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Path Parameters
Example:
"workspace_01HXKD2E5NQM3T9AYWCF133E3Q"
The objective ID to return windows for
Example:
"obj_01HXKD2E5NQM3T9AYWCFQAZGFV"
Query Parameters
Maximum number of results to return
Pagination cursor from previous response
When set to true you may use more of your alloted API rate-limit
Filters by metadata labels. Comma-separated key=value pairs, e.g. "env=prod,team=ai". A resource matches only if every pair matches exactly (AND semantics).
Response
OK