---
title: "Objectives — Cadenya"
url: "https://cadenya.com/features/objectives"
description: "Follow every message and tool call. Debug the details, compact long conversations, and control the work through the TypeScript SDK."
---

![Trees on a ridge above a misty valley](/_astro/hero-landscape.R3jIjXof_dQ4U7.webp?dpl=dpl_HJa8gqwfz8xwjnF1PtXneJm7pNwR)

# 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.

[Get started](https://app.cadenya.com/signup)

![](/_astro/roots-code.COYxbGtk_1TbA5n.webp?dpl=dpl_HJa8gqwfz8xwjnF1PtXneJm7pNwR)

## 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.

![](/_astro/roots-timeline.D4JkQSh5_24Kmld.webp?dpl=dpl_HJa8gqwfz8xwjnF1PtXneJm7pNwR)

Timeline

1.  User message
2.  lookup\_order 180 ms
3.  get\_shipment 2.0 s
4.  get\_shipment 420 ms
5.  Approval received
6.  send\_customer\_update 310 ms
7.  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.

![](/_astro/roots-toolcalls.D-18AHrJ_ZY5gX7.webp?dpl=dpl_HJa8gqwfz8xwjnF1PtXneJm7pNwR)

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.

![](/_astro/roots-debugging.DLDlJeg3_12WTOi.webp?dpl=dpl_HJa8gqwfz8xwjnF1PtXneJm7pNwR)

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.

![](/_astro/roots-compaction.CXVIxMST_Z1uj4Hx.webp?dpl=dpl_HJa8gqwfz8xwjnF1PtXneJm7pNwR)

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.

![A bonsai on a small floating island](/_astro/floating-bonsai.DSSEyopx_29HCeH.webp?dpl=dpl_HJa8gqwfz8xwjnF1PtXneJm7pNwR)

## Give agents  
an objective.

Start a run. Stream its events. Keep control as it works.

[Get started](https://app.cadenya.com/signup) [See API docs](/docs)