Skip to content

Restart notice: tell the model agy's "server restart" notice is about nothing of the client's - #36

Merged
ifccod merged 1 commit into
mainfrom
fix/restart-notice
Dec 2, 2026
Merged

ifccod merged 1 commit into
mainfrom
fix/restart-notice

Conversation

@ifccod

@ifccod ifccod commented Dec 2, 2026

Copy link
Copy Markdown
Owner

Problem

ZCode users on agy-cli/gemini-4-neon and agy-cli/claude-opus-5-5 saw this every few turns and dispatched their subagents again:

[Notice] All your subagents and background tasks have been stopped due to server restart. If you want a subagent to continue working, it needs to be revived by sending it a new message. If resuming work, please check on status and restart as needed.

It is a SYSTEM_MESSAGE step agy itself adds. Neither the client nor the gateway sends it.

When agy adds it

Measured with real agy 1.5.20:

case notice
second turn in the same process no
session/close then session/resume in the same process no
new process, session/resume (old one SIGTERMed, as the bridge does) yes
new process, session/resume (old one did session/close first) yes
new process, session/load yes

In production (jun, agy 1.5.22), conversation 7e43187d had 14 session_new resumed:true bridge events and 14 notices, each pair in the same second. The 11 turns that stayed on their process had none. The processes are replaced after AGY_BRIDGE_MAX_PROCS LRU eviction or IDLE_MS.

Fix (fallback)

agy has no flag, capability or _meta that turns the notice off, and a graceful close doesn't avoid it. With agy's own tools turned off, a bridged session never runs a subagent or background task of agy's own, so the notice is never true here. The bridge's workspace AGENTS.md now says so and tells the model not to restart, re-dispatch or mention anything because of it. The line is left out with AGY_BRIDGE_ALLOW_AGY_TOOLS=1, where agy's tasks really stop.

Limits:

  • The notice is still in the session. The model is only told to ignore it.
  • A/B with real agy (gemini-4-neon, one run per arm):
    • without the note, the model brought up the restart and hedged;
    • with the note, it answered "nothing was interrupted, no need to re-dispatch" and did not mention it.
  • agy rereads AGENTS.md on a resume in a new process, so existing sessions pick the note up. Their first resume after the upgrade reads uncached once (cachedReadTokens went from ~7.7k to 0), then the cache holds again.

Tests

  • fork/patch-e2e.mjs: a conversation evicted by another one (AGY_BRIDGE_MAX_PROCS=1) resumes in a new agy, and that agy's AGENTS.md carries the note. This test fails on the code before this change. With AGY_BRIDGE_ALLOW_AGY_TOOLS=1 the note is absent.
  • fork/fork.sh test locally: patch-e2e 18/18 pass. Upstream bun test has 3 failures; the pristine upstream snapshot fails the same 3 in the same environment, so they are environmental (re2-pattern-unit Go toolchain, catalog).
  • fork/swap-agy-cli.sh now counts 6 patch markers.

🤖 Generated with Claude Code

… nothing of the client's

agy adds a SYSTEM_MESSAGE step, "[Notice] All your subagents and background
tasks have been stopped due to server restart. ...", the first time a session
gets a prompt in an agy process other than the one that last ran it:
session/resume or session/load, whether the old process closed the session
first or not (agy 1.5.20 measured locally, 1.5.22 in production). The same
process going on, or closing and resuming in the same process, adds none.
The bridge resumes in a new process whenever the old one was evicted (a full
AGY_BRIDGE_MAX_PROCS pool, IDLE_MS) or its host restarted; on jun the 14
resumed turns of one ZCode conversation carried the 14 notices, to the
second, and the 11 turns on a kept process none. The model took it for the
client's own subagents and dispatched them again.

agy has no flag, capability or _meta that turns it off, and closing the
session first does not avoid it. With agy's own tools turned off, agy runs
no subagent or background task in a bridged session, so the notice is never
about anything that ran. The bridge's AGENTS.md now says so and tells the
model not to restart, re-dispatch or mention anything for it. Left out with
AGY_BRIDGE_ALLOW_AGY_TOOLS=1, where agy's background tasks really stop.

agy reads AGENTS.md again when it resumes in a new process, so sessions
opened before this take it too; their first resume after it reads uncached
once (cachedReadTokens ~7.7k -> 0), then stays cached.

patch-e2e: a conversation evicted by another (MAX_PROCS=1) resumes in a new
agy whose AGENTS.md has the note (fails on the code before this change), and
not with AGY_BRIDGE_ALLOW_AGY_TOOLS=1. swap-agy-cli.sh counts 6 markers.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ifccod
ifccod merged commit f9c19d2 into main Dec 2, 2026
2 checks passed
@ifccod
ifccod deleted the fix/restart-notice branch December 2, 2026 09:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant