Skip to content

[Bug]: ACP threads: handoffs of failed runs are re-sent to every new native session, and a failed session/load starts a second session while the old turn still runs #37287

Closed

Description

@FranciscoJSBarragan

Before submitting

  • I searched existing issues and did not find a duplicate.
  • I included enough detail to reproduce or investigate the problem.

Area

Server: orchestration-v2 provider turn start and context handoffs, with a Local ACP provider (Hermes Agent)

Steps to reproduce

This comes from one real Hermes ACP thread on 2026-11-14, read back from statev2.sqlite, the provider event log and the desktop trace. I did not build a scratch repro.

Part A (stale handoffs):

  1. In an ACP thread, let a few turns fail or get interrupted. Here runs 197 and 198 failed and 199 was interrupted while the model was switched, at 00:45–00:47Z. Run 199's start saved a delta_since_target_last_seen handoff covering runs 197–198.
  2. Keep using the thread normally for hours. Runs 201–239 completed.
  3. Make T3 open a fresh native session for the thread. For example, install a desktop update while a turn runs, so the restart continuation's session/load fails. See part B.

Part B (duplicate native session):

  1. Start a long turn in an ACP (Hermes) thread.
  2. While it runs, install the downloaded desktop update. The renderer calls desktop:update-install, then quitAndInstall, and the backend stops.
  3. After relaunch, restart continuation sends initialize, then session/load for the old session id.

Expected behavior

  • A: once a handoff has been delivered, or superseded by a newer full_thread_summary, a later fresh native session does not get it again. A delta_since_target_last_seen handoff does not reach back to runs that a later full summary already covers.
  • B: if session/load fails for a session whose turn may still be running on the agent side, T3 does not start the same work again in a second native session without saying so. It can surface the failure, cancel or wait for the old session, or treat it like ProviderAdapterThreadInUseError as it does for Codex.

Actual behavior

A. Old handoffs are re-delivered to every fresh native session. Every new Hermes session for this thread started with the morning's "Covered app runs: 197-198" handoff, plus every handoff whose target run had failed:

Fresh native session Run Handoffs inlined in its first prompt
ec42f7ec… (14:54:38Z) 233 197–198 (delta), 1–232 (full)
2cb18e63… (20:03:52Z) 241 197–198 (delta), 1–240 (full)
199c2537… (20:29:54Z) 245 197–198 (delta), 1–240 (full), 197–243 (delta), 1–244 (full)

The run-199 handoff was created at 00:47:04Z. Its delivery.nativeThreadId has been rewritten to each newer session, most recently at 20:29:54Z. Run 245's prompt therefore carried two full thread summaries, the morning delta and a "197–243" delta.

Cause, on main (12c495af49) and in the shipped bundle:

  • isPendingForRun (apps/server/src/orchestration-v2/ProviderTurnStartService.ts:447) keeps every status === "ready" handoff for the same provider thread pending whenever its target run is failed, interrupted or cancelled. Nothing retires it after delivery: status stays ready, and only delivery changes.
  • The "already delivered" check (settledHandoffs, :908) is scoped to delivery.nativeThreadId === <current native id>. A fresh native session therefore counts nothing as delivered and gets every such handoff again.
  • missedRuns (:992) never drops runs 197–198 either, so each retry delta starts at 197.

B. A second native session runs next to the first one. Twice that day, the update restart left the old Hermes turn running while T3 started the same work in a new session:

Update install (desktop trace) Old turn interrupted on T3 side session/load session/new Old Hermes turn kept running until
1 14:54:20.715Z run 232, 14:54:21Z failed 14:54:33.266Z 14:54:34Z, run 233 15:03:37Z, finished its reply unseen (9 min)
2 20:03:37.359Z run 240, 20:03:37Z failed 20:03:48.237Z 20:03:48Z, run 241 (restart continuation) 20:29:51Z, hard stop (26 min, 16 more model calls)

In both cases ProviderTurnStartService took the resume-fallback path (:1400, "Recovering provider context in a fresh native session", forceNewNativeThread: true). Only Codex errors map to ProviderAdapterThreadInUseError (the isCodexActiveWriterError mapping), so for ACP any session/load failure falls through to a fresh session. The thread then showed the new session's failures, and the user had to write twice before getting an answer. The old session kept working on the same request with no visible trace in T3.

The ACP agent answers that session/load with a bare JSON-RPC Internal error. Today's case of the same fallback in another thread (2026-11-15 16:32:10Z) has this server trace:

session/load exit Failure: Error: Internal error
    at AcpAdapterV2.openSession ...
    at ProviderTurnStartService.start (runtimeLayer-MvGsOTIR.mjs:126074:67)

Why the agent refuses the load, and why its turn outlives the ACP process, is on the Hermes side; I reported that part as NousResearch/hermes-agent#156173. The T3 part is that an ACP load failure is treated as "start over in a new session", with no check that the old turn has stopped.

Related, not the same:

Impact

Major degradation. After an update or restart, an ACP thread can have two agent sessions working on the same request. Only one of them is visible, and the visible one starts from a prompt padded with stale and duplicated summaries (about 20k characters for run 245, two full summaries included). It happened twice in one day on the same thread.

Version or commit

T3 Code Nightly 0.1.10-nightly.20261115.4736, the build after the incident. The same code is on main at 12c495af49. The incident ran on the nightly builds of 2026-11-14.

Environment

macOS (Darwin 27.0.0, arm64), desktop app. Provider: Local ACP (acpRegistry) running Hermes Agent 0.23.1. Models claude-fable-5-2 and claude-opus-5-5.

Logs or stack traces

Provider event log for the thread (logs/provider/events.<thread>.log), case 2:

20:03:37.573Z session/prompt failed errorTag=Interrupt
20:03:47.927Z session/load started
20:03:48.237Z session/load failed errorTag=AcpRequestError
20:03:48.974Z session/new started
20:03:49.815Z session/new succeeded
20:03:52.699Z session/prompt started

Desktop trace, case 2: desktop.ipc.invoke {channel: desktop:update-install} at 20:03:37.359Z, desktop.backendInstance.stop at 20:03:37.361Z, ElectronUpdater.quitAndInstall at 20:03:37.894Z.

The server traces for 2026-11-14 have already rotated out.

Screenshots, recordings, or supporting files

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions