Documentation

Search documentation

Manage context

Inspect what reaches the model, compact a long conversation, and work with oversized tool output.

Keep a long conversation focused by inspecting its context before changing it. These controls operate on the current conversation; they do not roll back files or undo commands. Start with an open Orek session and at least one completed turn.

Inspect the current context

In Orek · command

/context
Command What it shows
/context (/context show) Full context overview for the latest request: retrieved items that were included or left out, the conversation’s token count (reported or estimated), the input window, the automatic compaction threshold, and what happened to earlier reasoning (after a model switch)
/context summary One line with current token usage, the input window, the reasoning replay setting, and how much earlier reasoning was resent and dropped
/context breakdown Token split across the system prompt, tool definitions, conversation history, retrieved context, and free space
/context raw Exact retrieved context block sent to the model
/usage Reported token usage, reasoning tokens, and cost estimates for the session, by segment and by model
/detail Output from the latest tool call (/detail list for earlier calls)

The ctx gauge in the status bar shows the conversation’s share of the model’s input window (the context window minus the model’s output limit).

Automatic compaction

When the conversation reaches 90% of the model’s input window (or compaction.auto_compact_threshold when set lower), Orek summarizes the history before sending the next request and shows ⇅ compacting… in the status bar.

  • On the first request of a turn, the summary covers the conversation before your new message, and your message follows it.
  • On a later request of the same turn, the summary covers everything so far, including the turn’s tool calls, and the model continues the turn from it.

A request compacts at most once. If compaction fails, the turn ends with the error and the conversation is left as it was, including your message. Set compaction.auto_compact_threshold = 0 to turn automatic compaction off.

Compact a long conversation

To compact the whole conversation yourself:

In Orek · command

/compact

/compact takes no arguments and uses the active model to summarize the conversation, which costs normal provider tokens. If you run /compact while a turn is active, it waits as Compact in the pending tray until the turn finishes. If the summary request fails, the conversation stays unchanged.

After compaction, earlier messages stay visible in your scrollback above a Context compacted marker, while the model receives only the summary plus your most recent messages (up to about 20,000 tokens). Mention any $skill again if you still need its instructions, or run /clear to start fresh when a session has been compacted several times.

Switching to a smaller model

When you pick a model in /model whose limit the conversation already reaches, Orek asks before switching:

  • Compact and switch: the current model summarizes the conversation, then the session switches to the model you picked.
  • Cancel: the session stays on the current model.

A switch Orek makes without asking, such as /model during a turn, routing, a provider fallback, or a model change from your editor, compacts at the next request. The previous model writes that summary when its window is larger, so it can summarize everything it held; if its request fails, the new model writes the summary instead.

After a model switch

Each model switch starts a new segment: the run of requests to one model. The new model receives the whole conversation, but how much of the earlier models’ reasoning it receives depends on the agent.reasoning_replay setting in effect when the segment started; see Switching models and providers. Orek shows what happened in four places:

  • The routing line. The line under your message names the new model and says what happened to earlier reasoning, with the setting in parentheses: openai/gpt-6-luna · earlier reasoning dropped (drop), earlier reasoning resent (preserve), earlier reasoning translated (preserve), or 3 earlier thinking blocks retired (drop) when Claude’s earlier thinking will no longer be sent. A routing or fallback switch keeps its route text and adds the outcome. A resumed session that continues on another model reads resumed on <model>.
  • Transcript warnings. Orek can also stop resending Claude’s earlier thinking, or its earlier turns exactly as Claude wrote them, for another reason, such as a change in available tools after you connect an MCP server. The conversation itself still reaches the model. The transcript shows a one-line warning, for example “earlier native Anthropic history is no longer replayed after a tool-set change”, and orek run prints it on standard error. The warning appears once, with the answer Orek keeps; a retried response or a fallback does not repeat it. Compaction can cause the same warning, for example when you resume with web search turned on; it then follows the compaction marker, and the saved session records the cause.
  • /context. The Reasoning Replay section shows the latest request’s segment and setting, then one line per outcome and producing model, with item counts and estimated tokens. /context summary adds replay: <method>, R resent / D dropped.
    • Resent: sent again unchanged.
    • Translated: moved into the new model’s own reasoning field.
    • Filled: tool calls given the empty reasoning value some models require; this line gives only a count.
    • Dropped: left out, with the reason. not verified yet means Orek has not yet confirmed that the receiving model accepts that reasoning.
  • /usage. A By segment table comes first, one row per segment with its model, setting, requests, input, cache-read, output and reasoning tokens, and cost. The rows cover the main conversation, including compaction summaries, so they add up to its share of the total. Subagent requests appear only in the table by model that follows, which also has a reasoning column.

To change the setting, save it with /config set agent.reasoning_replay preserve (or drop). The current segment keeps its setting, and the new one applies from the next model switch. If Orek was started with --reasoning-replay, that flag decides for the running process, and the saved value applies to new ones.

Recover from context overflow

When a provider reports that a request exceeds the model’s context window, Orek compacts the conversation as automatic compaction would and sends the request again. Only the provider’s own error triggers this, not text from your prompt or files that the provider quotes back, so a request refused for another reason is not compacted. If the request was already compacted, still does not fit, the summary fails, there is nothing to summarize, or automatic compaction is off (compaction.auto_compact_threshold = 0), the turn ends with “The conversation no longer fits the model’s context window.” Start a new session, or switch to a model with a larger window.

To bring back information a summary left out, add an @ reference to re-read a current workspace file. Check the active context with /context.

Oversized tool output

Each tool applies its own output limit first (for example, read_file reads up to 44 KB per call by default so the agent can page through line ranges). Any tool result that still exceeds 12,000 tokens (about 48 KB) keeps its beginning and end, with an [... omitted N bytes / M lines ...] marker in the middle. Ask the agent to read a narrower range or command output if it needs the omitted part.

A provider’s own web search and fetch results follow that provider’s limits, not this one.

Separate display, conversation, and project changes

Action Effect
/collapse Changes what the interface displays.
/compact Summarizes the active conversation context.
/undo Removes the latest exchange from the display only; model history, saved history, and file edits remain unchanged.
/clear Starts a fresh conversation session; leaves project files in place.
/retrieval off Turns off automatic retrieval for this session; @ references still work.
/export Saves a Markdown transcript (use orek session export in your shell for an archive you can restore).

Use Manage sessions to resume or export recorded work. See compaction configuration for saved settings. Restart Orek to apply a saved change.