Skip to content

fix(server): ACP restart continuations no longer reopen a cut turn in a second session - #166

Draft
chrisohearn wants to merge 3 commits into
integration/mcp-events-20261109from
feat/inkling-transport-hermes-acp
Draft

chrisohearn wants to merge 3 commits into
integration/mcp-events-20261109from
feat/inkling-transport-hermes-acp

Conversation

@chrisohearn

Copy link
Copy Markdown
Owner

After a backend restart, a restart continuation calls session/load on the ACP agent. When that load fails, the fork falls back to session/new. Agents like Hermes keep the cut turn running agent-side, so the fallback can start the same work in a second native session that T3 can't see or cancel (NousResearch/hermes-agent#156173, pingdotgg#37287 part B).

This ports upstream's guard f948195 from the upstream branch factory/issue-37287. That commit is on neither upstream main nor this integration branch. When a restart continuation's resume fails on an agent that can restore sessions (canResumeAfterRestart, set only by the ACP adapter), the run now fails with a message saying the last turn may still be running there, instead of opening a fresh session. Agents that can't reload sessions, and other providers, keep the fresh-session fallback.

Scope note: this is not full containment. The next message the user sends still falls back to a fresh session as before, and an orphaned agent-side turn keeps running until the agent stops it. Agent-side containment is tracked separately.

Proof: the new paired test in ProviderTurnStartService.test.ts fails without the guard and passes with it (the file's suite: 114/114). vp run check:changed: format, lint, knip, typecheck (43 packages) and react compiler pass. Its 184-file test sweep hit the local 900 s timeout, so CI runs the full suite.

🤖 Generated with Claude Code

… a second session

When a restart continuation's session/load fails on an agent that can
restore sessions (canResumeAfterRestart, set only by the ACP adapter), the
old turn may still be running agent-side and the load error cannot tell busy
from gone. The continuation now fails with a message saying so instead of
replacing the native session; the next message the user sends falls back as
before. Agents that cannot reload sessions, and other providers, keep the
fresh-session fallback.

Refs pingdotgg#37287

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit f948195)
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Dec 1, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-12-01T03:22:21.198468Z 768335d New commits
🔒 Security Review ✅ Completed 2026-12-01T03:20:37.867031Z 768335d New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 9140db553a

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

…ttempt

A restart continuation whose native session lost the kept turns (a rolled-back
turn on an agent that cannot truncate) gets a synthetic resume failure without
calling resumeThread. The guard treated it as an ambiguous load error and
blocked the intended fresh-session recovery. It now fires only when the resume
was actually attempted.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 9d3b245122

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

…keeps actionable refusals

A restart continuation that only delivers a restart note has no cut turn to
repeat, so it keeps the fresh-session recovery. A resume refusal with a known
remedy (for example an unaccepted model) now reaches the user as is instead of
the generic restart message; neither case opens a second session.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@chrisohearn
chrisohearn marked this pull request as draft December 1, 2026 05:03
@chrisohearn

Copy link
Copy Markdown
Owner Author

Holding this as a draft after testing it against Hermes (Local ACP) on a dev server built from this branch.

On Linux hosts where T3 runs agents in systemd scopes, a restarted server stops the previous server's agent slice (agentScope.stopLeftoverAgents) before it spawns any agent. In every repro on this host, that stopped the old Hermes gateway before the restart continuation's session/load. Load then succeeded and the guard never fired. These were a graceful stop, a SIGKILL with a restart 1 s later, and a SIGKILL with a restart 40 s later.

So on those hosts the guard can't prevent a duplicate turn; it can only turn a recoverable load failure into a failed run. It only protects hosts without scope reaping (macOS, Windows, or Linux without user systemd). Before merging, gate it on reaping being unavailable, or leave it unmerged.

The real gap on this host is earlier: after a T3 crash, the old agent keeps working, unseen, until the restarted server spawns its first agent. This guard can't close that window.

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.

2 participants