Objectives
Every run.
In the open.
Follow every message and tool call. Debug the details, compact long conversations, and control the work through the TypeScript SDK.
Start an objective
const objective = await cadenya.objectives.create({
agentId,
firstUserMessage: "Update the customer on order 1042"
}); Follow it live
const events = await cadenya.objectives.streamEvents(objective.metadata.id);
for await (const event of events) {
console.log(event.data);
} Every step, in order.
Messages, tool calls, results, and status changes share one timeline. Stream events live or fetch the history from your application.
Timeline
- User message
- lookup_order 180 ms
- get_shipment 2.0 s
- get_shipment 420 ms
- Approval received
- send_customer_update 310 ms
- Assistant message 723 ms
Read the run and its events
const objective = await cadenya.objectives
.retrieve(objectiveId);
const events = await cadenya.objectives
.listEvents(objectiveId, { sinceEventId }); Inspect every tool call.
Inspect arguments, execution status, and returned content. Approve or deny gated calls through the TypeScript SDK.
send_customer_update
Approved · Completed
Arguments
{ "orderId": "1042",
"channel": "email" } Result
{ "delivered": true } Inspect a call. Approve it.
const call = await cadenya.objectives
.retrieveToolCall(objectiveId, toolCallId);
await cadenya.objectives
.approveToolCall(objectiveId, toolCallId); Track every tool call your agent makes
Get past the error message.
Trace requests, responses, timing, and attempts in the debugger. Read context composition and token usage through the diagnostics API.
get_shipment
Attempt 1 · 2.0 s
GET /shipments/SHP-1042
{ "shipmentId": "SHP-1042" }
HTTP 504 · Gateway timeout
UPSTREAM_TIMEOUT
Carrier request timed out.
Inspect context usage
const { diagnostics } = await cadenya.objectives
.retrieveDiagnostics(objectiveId); - Input tokens
- 1,529
- Cached input
- 1,408
Keep long tasks moving.
Compaction runs automatically as context fills. Summarize the conversation, clear older tool results, or combine both. Inspect each window or compact on demand.
Context windows
Automatic · 75% trigger
Window 01
Messages + tool results
Compaction
Summary / result clearing
Window 02
Order 1042 + shipment context
Compact. Keep going.
await cadenya.objectives.compact(objectiveId);
const windows = await cadenya.objectives
.listContextWindows(objectiveId); A few things
to know.
What does an objective keep?
An objective captures its configuration at creation and records its messages, tool calls, events, and context windows.
Can I send another instruction?
Yes. Continue a waiting objective, or enqueue a message while its agent loop is busy.
Does compaction happen automatically?
Yes. The default trigger is 75% of the model’s context limit. Configure summarization, older-result clearing, or both on the variation.
Give agents
an objective.
Start a run. Stream its events. Keep control as it works.