# Context Canary

> A long agent session rarely breaks all at once: as the context fills, the model quietly drops a small instruction a turn or two before it invents a file, an API or a decision that never existed.

- Area: Desktop app
- Plans: All plans
- Last checked against the product: 2026-09-28
- Web page: https://agentsroom.dev/docs/context-drift-detection

## What it does

A long agent session rarely breaks all at once: as the context fills, the model quietly drops a small instruction a turn or two before it invents a file, an API or a decision that never existed. AgentsRoom turns that first silent omission into a visible alarm. Every agent is already asked to write a one-line status at the end of each turn (the summary shown under its name in the sidebar and in mobile notifications). When an agent stops updating that status for two consecutive turns, a warning banner appears above its terminal: the agent is probably losing context. The banner offers a one-click restart on a clean context, with the conversation carried over, and a tip to type `/compact`. It clears itself when the agent starts reporting again.

## Where to find it

- Above the composer of the concerned agent, an amber banner: "Agent may be losing context" with **Restart agent** and **Dismiss**, and, when the CLI reports it, "Context window: N% full".
- A milder variant, "Agent stopped updating its session file", when only the status file is stale.
- A separate banner, "Your agent has not reacted to your last message", when a message you sent got no reaction for 30 seconds (no status change, nothing printed): "It may be waiting on a question shown only in its terminal, or its CLI may have stopped." It offers **Show terminal** (from the conversation view) and **Restart agent**, and takes the slot over the drift banner. Closing it silences it for that message only; the next message you send can raise it again.
- Admin builds: the composer debug menu has a **Canary state** entry to inspect the counters and preview the banner.

## How to use it

1. Nothing to set up: launch an agent and the detection is on.
2. When the banner appears, either type `/compact` in the terminal (Claude Code and the CLIs that support it) to summarise the conversation and keep working, or click **Restart agent**.
3. **Restart agent** opens the **Context transfer** chooser, the same as a provider switch, with the CLI and model kept: **Agent summary** (the agent writes its own handoff, best continuity; a small "Summarizing" banner shows progress and can be cancelled), **Raw transcript** (the terminal is dumped to a file the new session reads), or **Light context** (modified files and last activity). The new session starts from that instead of the degraded context.
4. **Dismiss** hides the banner for this session; it comes back on its own only if the agent recovers and drifts again.

## Settings

None.

## Agent tools (MCP)

None. The signal is the per-turn status every agent writes to its session file; `agents_report_status` lets an agent declare states the app cannot observe (blocked, rate limited, degraded) but is not the canary.

## Providers

All providers, no difference: the detection relies on the session-file protocol every AgentsRoom agent follows, not on any CLI output. The `/compact` tip is only meaningful on CLIs that have such a command (Claude Code); the restart path works everywhere.

## Mobile

Not on the phone. The phone receives the same per-turn status (it is what feeds push notifications and the agent subtitle), but the drift banner and the restart chooser are desktop surfaces.

## Limits

- Two missed turns, not one: a short legitimate turn (the agent reads a file and answers briefly) can leave the status unchanged. The check runs about 45 seconds after a turn ends, to leave time for the status file to be written and read.
- A turn you start with a slash command (`/model`, `/help`, `/status`, `/compact`, a custom skill...) is neither a missed turn nor a successful one: the command is handled by the CLI itself, the model does not run, so the agent has no reason to write its status. Pressing Enter on an empty line inside a CLI menu (the `/model` picker, for example) does not change the count either.
- The "has not reacted" banner watches the 30 seconds after a message you send; an agent that was already thinking when you sent it, or that prints anything in its terminal, counts as having reacted.
- An agent that never adopted the status protocol (some third-party setups, silent or seed runs) will not trigger it; the banner is a signal about agents that used to report and stopped.
- A restart is a new CLI session: the conversation arrives as a handoff (summary, transcript or light context), not as the original context window.
- Dismissing is per session.

## Common questions

- **What does the warning actually detect?** That the agent stopped following an instruction it was following on every previous turn. It is the earliest observable symptom of context rot, usually before hallucinations show in the code.
- **Restart or compact?** `/compact` keeps the current session and summarises it in place; **Restart agent** starts a fresh session from a handoff you choose. Compact first if the CLI supports it; restart when the agent already misbehaves.
- **Will I lose my work?** No files are touched. The restart carries the conversation over as a summary or transcript, and your prompt history is preserved.
- **Is it useful with one agent?** It helps, but it shines with a fleet: nobody re-reads every reply of five parallel agents, and the banner does the watching.
- **Does it slow the agent down?** No. It reuses a one-line status the agent already writes; no extra prompt, no extra model call.
- **I typed `/model` and the "stopped updating its session file" banner appeared, why?** It no longer does. A slash command is a CLI command, not a turn of the model, so it is ignored by the count. If you still see the banner, two real questions went by without a status update.
- **The banner appeared right after an update or a resumed session, on a short conversation.** On macOS and Linux, a resumed Claude Code agent used to lose its AgentsRoom instructions, so it really stopped writing its status. Fixed on 2026-09-28: update AgentsRoom and restart the agent once.
- **I sent a message and nothing happens, is the agent lost?** Not necessarily. After 30 seconds without any reaction a banner says "Your agent has not reacted to your last message": click **Show terminal**, the agent is often waiting on a question drawn only in its terminal. If the terminal is dead, **Restart agent**.

## Related

- [Agent Status Tracking](https://agentsroom.dev/docs/agent-status-tracking.md): the per-turn status the canary reuses.
- [Claude Code Token Usage](https://agentsroom.dev/docs/claude-code-token-usage.md): the context window gauge and session size.
- [Multi-Provider Support](https://agentsroom.dev/docs/multi-provider.md): the Context transfer chooser shared with provider switching.
- [Restore Session](https://agentsroom.dev/docs/restore-session.md): resuming a conversation after a restart.
