Skip to main content

Module agent_context

Module agent_context 

Source
Expand description

Agents context and Agents compact (docs/specs/SPEC_AGENT_SELF_COMPACTION_2026_10_23.md §3.3): an agent reads how full its own context is, and compacts itself when its turn ends.

Both act on the caller’s own pane only, resolved from its agent token’s UID (actor::own_pane_by_token), never from a name: there is no target.

Structs§

SelfContextRequest 🔒

Constants§

EXIT_WAIT 🔒
The longest a fresh session waits for the old CLI to exit.
FOCUS_MAX_CHARS 🔒
The most focus text sent with /compact.
FRESH_ATTEMPTS 🔒
Tries a fresh session makes when a message queued behind the turn starts the next one before the old session can be ended.
FRESH_FAILED_NOTE_KEY 🔒
Held for the agent’s next turn when its fresh session couldn’t start.
HANDOFF_MAX_CHARS 🔒
The most handoff text a fresh session carries.
STOP_PENDING 🔒
TURN_END_POLL 🔒
TURN_END_WAIT 🔒
The longest a self-compaction waits for the caller’s turn to end.
TURN_RUNNING 🔒
What start_fresh_session says when the turn hasn’t ended, or the CLI is already being stopped: the two it is worth trying again after.

Functions§

acp_compact_message 🔒
The message that compacts the ACP agent in block_id, by what its harness announced: /compact with the focus when the command takes one, alone when it doesn’t, a refusal when the harness announced no compaction command. None when the pane is not an ACP agent.
compact_for_backstop 🔒
srv’s own compaction of a route agent whose context is far over its budget: the compaction Agents compact schedules, without a focus (the harness’s summarizer decides what to keep). Err(why) when it can’t be sent now.
compact_message 🔒
/compact with the focus, trimmed to FOCUS_MAX_CHARS and to one paragraph’s worth of whitespace.
compact_request 🔒
The message that compacts a provider agent, or why it can’t be: a Claude agent takes /compact (with its focus) as a turn wherever it runs, and a container’s turn is that same message on its per-turn exec controller.
compact_when_turn_ends 🔒
Send message as AgentMux’s own turn once block_id’s turn has ended. A container agent’s turn is not waited for: it runs one turn at a time from a queue, and the compaction is placed at the head of that queue, so it starts the moment the turn in flight ends and ahead of the messages already waiting. Waiting for a moment with no turn running could take as long as the queue stays full, and the compaction would then go behind it (the queue is never empty for a busy agent: the next waiting message starts the moment a turn ends).
end_session 🔒
End block_id’s provider session, so the next message starts a new one. An ACP agent’s old session id comes back, so the new session’s first message can name it.
fresh_refusal 🔒
Why the pane of a model change can’t start a fresh session, or nothing: the test Agents fresh applies to its own pane.
fresh_supported 🔒
Whether an agent of provider can start a fresh session, and why not. A container’s Claude or Codex agent runs one exec per turn on the same controller a host Codex agent does, so ending its session is forgetting its id, as there (blockcontroller/subprocess/codex_fresh.rs); the harnesses that speak ACP have no such controller in a container.
fresh_when_turn_ends 🔒
Wait for the turn to end, end the session, then send first_message as AgentMux’s own turn, which starts the new session.
handle_compact_self 🔒
POST /api/v1/agent/self/compact: scheduled (runs when the caller’s turn ends) or refused with why.
handle_context_self 🔒
POST /api/v1/agent/self/context
handle_fresh_self 🔒
POST /api/v1/agent/self/fresh: scheduled (when the caller’s turn ends, its session ends and a new one starts with the handoff) or refused. focus carries the handoff here.
handoff_message 🔒
The new session’s first message from AgentMux: the agent’s own handoff and a pointer to the old session. Nothing else of the conversation comes with it.
hint_kind 🔒
Which hint rules block_id‘s agent gets: an ACP harness has its window’s sizes and offers compaction only when it announced it (the same the turn-end note uses), every other agent the settings’ own.
no_pane 🔒
provider_of 🔒
claude or codex for a pane that can compact, with whether it runs in a container.
speaks_acp 🔒
Whether provider is an Agent Client Protocol harness (dsh, Gemini, Copilot, …): every one can open a new session.
start_fresh_after_switch 🔒
Start block_id’s fresh session after a model change: when its turn ends its session ends, and first_message starts the new one on the model the agent is set to now. false when there is no async runtime to run it on.
switch_message 🔒
The first message of the fresh session a model change starts (agent.model.switch and Agents update with fresh): where the agent was moved to, that the earlier conversation is in its record and not in its context, and what the caller said its next session must know (none: where to look for what it was doing).
wait_for_turn_end 🔒
Wait until block_id has no turn running; false after TURN_END_WAIT.
with_previous_session 🔒
first_message, naming the session it replaces when the harness had one, so a person can take it back from the harness.