Concepts

Context Management

The layered approach UnderOcean uses to keep long conversations coherent without unbounded token growth.

Long-running agent conversations can't simply keep growing the raw message history forever — token costs and latency scale badly, and models lose focus in very long contexts. UnderOcean addresses this with a layered, hybrid context strategy rather than a single technique.

The three layers

Layer 1 — Running summary

As a conversation grows, older turns are periodically compacted into a running summary rather than kept verbatim, bounding the size of what's sent to the model on each turn while preserving the gist of earlier exchanges. The summary itself isn't persisted server-side — the caller receives it via a summary SSE event and resends it as input.summary on the next turn (see Executions & Streaming → Multi-turn conversations).

Layer 2 — Key structure extraction

Structured facts are extracted from the conversation in the background (an "extracted profile") — durable, queryable information that doesn't need to be re-derived from raw message history on every turn.

Layer 3 — Long-term / recalled memory (disabled)

Long-term semantic recall across separate sessions is planned but not yet wired into agent execution — the underlying storage/retrieval code exists, but no execution path calls it, so it currently has no effect. The enable_long_term_memory option is disabled by default and hidden from the agent builder UI until this integration is completed.

Cross-agent context sharing

In a multi-agent flow, context is shared across every agent step, so a specialist agent invoked mid-flow can see the running summary and extracted profile built up by earlier steps — without needing the full raw message history replayed to it.

On this page