agent-orchestrator icon indicating copy to clipboard operation
agent-orchestrator copied to clipboard

Chat sessions fail every turn with set ACP session option "model": "Session not found" (-32603) after heavy system load

Open GabrielGoncalvesICE opened this issue 2 months ago • 5 comments

Most agent sessions on our fleet crashed. Every new message to an affected Chat session immediately fails with:

The agent ran into a problem
set ACP session option "model": {"code":-32603,"message":"Internal error","data":{"details":"Session not found"}}

The error repeats on each message I send, so the session is unusable. We were running a lot of things at once, so this was quite likely triggered by high CPU / RAM usage on the machine.

Environment: Agent Orchestrator desktop 0.13.4-nightly.202610031727, macOS 26.5 (25F71), 16 GB RAM / 10 cores.

GabrielGoncalvesICE avatar Oct 03 '26 20:10 GabrielGoncalvesICE

Agent-collected evidence

Collected 2026-10-03 ~20:35Z by a local AO worker agent on the reporter's machine. Installed build: 0.13.4-nightly.202610031727 (ao version reports dev). Daemon on port 3001. Source references point to main @ a2a8917. Session names are anonymized as A–D.

1. Failed turns (sqlite3 -readonly ao.db, conversation_turns.error_message LIKE '%Session not found%')

session requested_at (UTC) time to failure error
A 20:08:29 20 ms set ACP session option "model": … Session not found
B 20:08:43 25 ms same
B 20:08:59 60 ms same
C 20:10:51 51 ms same
D 20:12:18 45 ms set ACP session mode "auto": … Session not found
D 20:15:11 149 ms set ACP session mode "auto": … Session not found
C 20:15:23 56 ms set ACP session option "model": …
C 20:15:33 8 ms same
A 20:20:54 16 ms same
A 20:23:47 47 ms same

Every turn fails within milliseconds, before a prompt is sent. Earlier the same day, two turns in other sessions failed with The connection to Claude was lost. (18:44:51Z and 19:23:45Z).

2. The failure persists across a daemon restart

ao status shows the daemon started at 20:15:06Z. Sessions A, C and D kept failing with the same error after that restart. Session C recovered only after a new ao chat-host and ACP child were spawned at 20:26:31Z (from chat-hosts/<session>/host.json startedAt).

3. Orphaned chat-host processes

From ps -axo pid,ppid,lstart,rss,command: about 20 ao chat-host <session> processes from the previous day's run have PPID 1, so they outlived the earlier daemon. Some still have an acp-runtime/node child, and several use under 1 MB RSS. Only 2 chat-hosts are parented to the current daemon.

4. System resources at collection time

$ sysctl vm.swapusage
vm.swapusage: total = 8192.00M  used = 7046.31M  free = 1145.69M  (encrypted)
$ memory_pressure | tail -2
Pageouts: 2667200
System-wide memory free percentage: 35%

No AO crash report was found in ~/Library/Logs/DiagnosticReports for this window, and there was no JetsamEvent near it. I found no daemon log file in this install, so there are no log excerpts.

5. Code path

The error comes from backend/internal/adapters/chatdriver/acp/conversation.go:490 (applyOption), when c.conn.SetSessionConfigOption fails. Only isACPMethodNotFound is special-cased, so a -32603 "Session not found" from the ACP agent becomes a terminal turn failure. The SetSessionMode path behaves the same way. LoadSession/ResumeSession support exists in driver.go:408-424.

Hypothesis (unconfirmed): under memory pressure, the ACP agent process restarted or lost its in-memory session. The conversation kept the stale ACP sessionId, so each turn's first call (session/set_config_option or session/set_mode) fails with Session not found and nothing re-creates or resumes the session. I did not reproduce this on a separate build.

The reporter's screenshot shows two consecutive user messages in one session, each answered with the error above. It is not attached because it contains private prompt text.

GabrielGoncalvesICE avatar Oct 03 '26 20:10 GabrielGoncalvesICE

Follow-up: the project orchestrator died (agent-collected evidence)

The reporter noticed that the project's orchestrator session was dead. That orchestrator is session D in the table above, one of the sessions that hit set ACP session mode "auto": … Session not found. Collected 2026-10-03 ~21:50Z from the same install (0.13.4-nightly.202610031727) with ao orchestrator ls, ao session get --json, ao status, ps, and read-only queries on ao.db (sessions, change_log, conversation_turns, session_interface_transitions).

Timeline (UTC)

time event
20:12:18, 20:15:11 Chat turns fail: set ACP session mode "auto": … Session not found
20:32:42 → 20:33:22 session_interface_transitions: chat→tui, tui→chat, chat→tui (all completed, policy drain). Three queued turns marked recovered at 20:33:08. The session ends up in TUI mode (ptyhost-v1 runtime). This appears to be the user switching modes to work around the dead Chat.
20:33 → 21:06 Session active (regular session_updated events)
21:33:49 The desktop app process (MacOS/agent-orchestrator) relaunches. The version is unchanged, and ~/.ao/update-settings.json (nightly channel, auto-update enabled) and update-restart/active.json have mtimes near this time. No crash report was found in DiagnosticReports.
21:33:51–52 New daemon starts (ao status: started 21:33:52Z). Orchestrator session_updated → activity: exited, isTerminated: false
21:33:57 5 s later, orchestrator → activity: exited, isTerminated: true. There is no session_cleanup_facts row and no agent_switches row.

Observations

  • After the 21:33 relaunch, the daemon restored pty-hosts for other TUI workers. For example, a worker's ao pty-host was respawned at 21:33:55 by the new daemon. The orchestrator's pty-host was not restored, and the session was terminated instead.
  • At the same time, this machine had ~20 orphaned ao chat-host processes (PPID 1) from earlier daemon generations, with swap almost full (7.0/8.0 GB). These are the same conditions described in the original report.
  • ao session restore <orchestrator> brought it back immediately. A new pty-host and agent-process supervise were started, and Claude was relaunched with --resume <same native session id>, so the orchestrator's conversation was preserved. Termination was therefore not needed to recover. The session was resumable the whole time.

Hypotheses (unconfirmed)

  1. On daemon startup, a TUI session whose pty-host is gone, possibly because the relaunch tore it down or because it was killed under memory pressure, is treated as exited and then terminated. Auto-resume (as with resume-agent/restore) is not attempted. For an orchestrator, this leaves the project without a coordinator and gives no visible reason.
  2. The relaunch at 21:33:49 may come from the nightly updater's restart path (update-restart/) rather than a crash, because no crash report exists and the update settings file changed at the same moment. I could not confirm this without app/daemon logs, and this install did not produce any log files I could find.

GabrielGoncalvesICE avatar Oct 03 '26 21:10 GabrielGoncalvesICE

Follow-up: after the crashes, Terminal → Chat switch is permanently blocked (agent-collected evidence)

The reporter's follow-up: several sessions (including the orchestrator) that had been moved to Terminal mode to work around the Chat failure could not be switched back to Chat. Collected 2026-10-03 ~22:00Z on the same install (0.13.4-nightly.202610031727) using read-only queries on ao.db (session_interface_transitions, sessions.native_checkpoint_evidence) and a read-only walk of each session's Claude transcript (~/.claude/projects/…/<native-id>.jsonl). Source references point to main @ a2a8917. Sessions are anonymized.

Errors (session_interface_transitions, tui→chat)

TARGET_HISTORY_UNSETTLED  switch interface <s>: resume chat: wait for native checkpoint: claude native checkpoint:
  observed native turn not completed: chat conversation history is not settled: checkpoint mismatches [unsettled_turn_boundary]: context deadline exceeded
TARGET_RESUME_FAILED      switch interface <s>: resume chat: context deadline exceeded

One worker failed this way 4 times (21:34, 21:45, 21:46, 21:54Z), and the orchestrator failed at 21:57Z. Every retry fails, so the UI's "retry (strict)" recovery for TARGET_HISTORY_UNSETTLED cannot succeed.

Why it can never settle. I mirrored verifyCheckpointTranscript (backend/internal/adapters/chatdriver/claudeacp/checkpoint.go) in a small read-only script. It checks every observation in native_checkpoint_evidence. Each turn must be complete (last assistant record has stop_reason == "end_turn"). AppendNativeCheckpoint (domain/native_checkpoint.go) keeps every observation, and the evidence is only cleared when the native identity changes (lifecycle/manager.go ~L685–703). So one permanently incomplete observed turn blocks the switch for the rest of that Claude conversation. I found two ways that happens:

  1. A turn cut off by a crash or restart. In three workers, an observed submission's turn ends with an assistant tool_use and no tool_result. The agent was killed mid-tool during the crashes and app relaunch described above. One example: the submission was at 20:43:32Z, the last record is tool_use at 20:54:58Z, and the next user prompt is at 21:34Z, after the relaunch. Later turns complete normally, but the old observation remains in the evidence forever.
  2. Two queued messages answered in one turn (orchestrator). At 21:54:27.195Z, two ao send messages from two workers were written as two consecutive user records with different promptIds. There was no assistant record between them, and Claude answered both in a single end_turn reply. The parser starts a new checkpointTurn for each non-tool-result user record, so the first turn has no assistant record (complete=false) and its observation can never be discharged. This one does not need a crash: any Terminal-mode orchestrator that receives a burst of ao send messages can hit it.

Impact / workaround used. The sessions themselves worked fine in Terminal mode. The only way back to Chat was to have each agent write a handoff and spawn a new Chat-mode session, which loses the native conversation. provider_history recovery is not offered for TARGET_HISTORY_UNSETTLED (interfaceTransitionHistoryRecoveryPolicy in SessionInterfaceTransition.tsx; providerHistoryRecoveryAuthorized in session_manager/interface_transition.go).

Hypotheses (unconfirmed, not reproduced on a separate build)

  • An observed turn that a later completed turn has superseded, or that was interrupted by a process exit, could be treated as settled instead of blocking forever.
  • Consecutive user records with no assistant record between them (queued input merged by Claude Code) could be folded into the following turn.
  • Alternatively, provider_history recovery could be offered for TARGET_HISTORY_UNSETTLED too, so the user has a way out short of starting a new session.

GabrielGoncalvesICE avatar Oct 03 '26 23:10 GabrielGoncalvesICE

Follow-up 2: answers on the 21:33:49Z relaunch (agent-collected, read-only)

Collected 2026-10-04 ~01:30Z on the same machine and build (0.13.4-nightly.202610031727). Nothing was restored, restarted or modified. Local time is PDT (UTC-7). Session letters are the same as above: A, B, C, D (orchestrator), plus E (a TUI worker). Two more Chat workers are new here: F and G. Preview URLs and prompt text are redacted.

Correction first: 21:33:49Z was the recovery. The outage began at 21:06:40Z, with a normal app quit.

log show (unified log), 14:06:20–14:07:10 PDT:

14:06:22.020 runningboardd … ActivityMonitor … (Activity Monitor was open)
14:06:33.444 runningboardd … Acquiring assertion targeting [app<…agent-orchestrator.desktop…>:15825] from originator [osservice<com.apple.Dock.agent…
14:06:40.589 agent-orchestrator[15825] [com.apple.AppKit:Application] Handling Quit AppleEvent
14:06:40.611 agent-orchestrator[15825] … replyToApplicationShouldTerminate:YES
14:06:40.612 agent-orchestrator[15825] … App termination approved
14:06:43.254 ao[39156] MallocStackLogging: can't turn off malloc stack logging … (several short-lived `ao` processes 39156–39163, likely hook invocations)

The app received a normal Quit AppleEvent and approved it. The log doesn't show who sent the Quit event: a Dock assertion was taken 7 s earlier, and Activity Monitor was open. In this window there are no memorystatus kill or jetsam events for any AO, node or claude process. The only memorystatus line is an unrelated DockHelper exceeded mem limit (non-fatal). The 14:33:49 PDT window shows only a user-demand launch: launchd … Successfully spawned agent-orchestrator[42218] because launch job demand, started through CoreServicesUIAgent. There are no kills there either.

change_log has 0 rows between 21:07:00Z and 21:33:50Z, so no daemon was running for about 27 minutes.

1. hooks.log. There is nothing in 21:32–21:35, and no agent-process process-exited lines at all. The whole file (5 lines) is from the quit:

2026-10-03T21:06:58Z session=C ao hooks claude-code session-end: AO daemon is not running — start it with `ao start`
2026-10-03T21:06:58Z session=E ao hooks claude-code session-end: AO daemon is not running — start it with `ao start`
2026-10-03T21:06:58Z session=B ao hooks claude-code session-end: AO daemon is not running — start it with `ao start`
2026-10-03T21:06:58Z session=D ao hooks claude-code session-end: AO daemon is not running — start it with `ao start`
2026-10-03T21:06:58Z session=A ao hooks claude-code session-end: AO daemon is not running — start it with `ao start`

So the Claude processes of A, B, C, D and E all ended about 18 s after the app quit, while no daemon was available to receive their exit.

2. change_log rows, 21:33:40–21:34:10Z (SELECT * FROM change_log WHERE session_id IN (…) AND event_type='session_updated'). Columns: seq|project_id|session_id|event_type|payload|created_at. The project is anonymized as P. Rows whose payload is only {"id":…} are listed by seq.

D (orchestrator):

180493, 180494                       {"id":"D"}  21:33:52.208774
180496|P|D|session_updated|{"id":"D","activity":"exited","isTerminated":false,"terminateOnPrMerge":false,"previewUrl":"","previewRevision":0,"isPinned":false,"mode":"tui","autoInjectReview":true,"autoInjectCI":true,"autoReviewEnabled":false,"provisionState":"ready"}|21:33:52.342424
180543 21:33:53.819063 · 180564 21:33:54.817708 · 180581 21:33:55.063482 · 180596 21:33:55.226898 · 180606 21:33:56.090808 · 180611 21:33:57.175414   {"id":"D"}
180612|P|D|session_updated|{"id":"D","activity":"exited","isTerminated":true,"terminateOnPrMerge":false,"previewUrl":"","previewRevision":0,"isPinned":false,"mode":"tui","autoInjectReview":true,"autoInjectCI":true,"autoReviewEnabled":false,"provisionState":"ready"}|21:33:57.180017
180622 21:33:59.213892               {"id":"D"}

E (TUI worker that came back):

180500, 180501 21:33:52.375852 · 180546 21:33:53.819063 · 180567 21:33:54.817708   {"id":"E"}
180574|P|E|session_updated|{"id":"E","activity":"idle","isTerminated":false,"terminateOnPrMerge":false,"previewUrl":"<redacted>","previewRevision":1,"isPinned":false,"mode":"tui","autoInjectReview":true,"autoInjectCI":true,"autoReviewEnabled":false,"provisionState":"ready"}|21:33:55.050296
180575 21:33:55.053337 · 180590 21:33:55.063482 · 180599 21:33:55.226898 · 180616–180618 21:33:57.708819 · 180669 21:34:06.046846 · 180723 21:34:06.496199   {"id":"E"}

B and A, the other TUI workers, follow the same pattern as E. Their full payloads are B activity:"idle" at 21:33:54.809466 (seq 180558) and A activity:"idle" at 21:33:55.102301 (seq 180578). So within the same 3 s, the three TUI workers went to idle, while D went exited and was then terminated 4.8 s later. The only obvious difference: D is kind=orchestrator and the others are worker.

The payloads do not contain a runtime handle ID or launch ID. For reference only, these are the current values, not the ones at 21:33, from sessions:

  • D: runtime_handle_id=ptyhost-v1:D, runtime_launch_id=agent_session_id_launch_id=99d9346c-….
  • E: ptyhost-v1:E, cc1adef6-….

Note that D's running supervise process and the pty-host registry both carry launch 13fa2fcd-…, which is not the 99d9346c-… stored on the row (see 3).

3. Process evidence (01:27Z)

 8756 42314 Sat Oct  3 17:24:29  15312 ao pty-host <worker-new>
53951 42314 Sat Oct  3 14:51:47   7536 ao pty-host G
59141 42314 Sat Oct  3 14:57:08  10704 ao pty-host D
 8761  8756 Sat Oct  3 17:24:29   8608 ao agent-process supervise --session <worker-new> --launch a4bc342f-…
59142 59141 Sat Oct  3 14:57:08  13152 ao agent-process supervise --session D --launch 13fa2fcd-…
53954 53951 Sat Oct  3 14:51:47   6080 ao agent-process supervise --session G --launch e622ec6d-…

~/.ao/windows-pty-hosts.json holds three entries, all parented to the current daemon (42314, started 14:33:51 PDT):

  • G: ptyHostPid 53951, launchId e622ec6d-…, registered 21:51:47Z.

  • D: ptyHostPid 59141, launchId 13fa2fcd-…, registered 21:57:08Z.

  • <worker-new>: ptyHostPid 8756, registered 2026-10-04T00:24:29Z.

  • No pty-host or supervise process for D has a start time before 21:33:49Z. D's current one dates from the 21:57:08Z rollback after a failed Chat switch.

  • No pty-host survived the 21:06:40 quit. In a ps snapshot at ~21:49Z, every pty-host had PPID 42314 and a start time after 14:33:51 PDT. E's pty-host started at 14:33:55 PDT (21:33:55Z), which matches its idle row. A's and B's pty-hosts in that snapshot started later (14:46:36 and 14:47:45 PDT), after their own Terminal→Chat→Terminal transitions, so from ps alone I can't prove they also got one at 21:33:55. Their idle rows at 21:33:54–55 suggest they did.

  • In contrast, ACP ao chat-host processes do survive daemon restarts and app quits: about 20 have PPID 1 and start times from 2026-10-02.

5. Update install? No. The version didn't change around 21:33:49Z.

  • ~/.ao/update-restart/ contains only active.json = {"attempt":"attempt-70VWhu"}, mtime 2026-10-03T13:14:41-0700 (20:14:41Z). That lines up with the earlier daemon restart at 20:15:06Z, not this one.
  • ~/.ao/update-settings.json mtime 14:33:51 PDT. Content: version 0.13.4-nightly.202610031727, lastReconciledAt 2026-10-03T21:33:50.849Z, installSource unknown. This looks like a startup reconcile write, not an install.
  • App Info.plist mtime 10:32:14 PDT and daemon binary mtime 10:40:09 PDT, both hours earlier. Version before and after: 0.13.4-nightly.202610031727.

6. A Chat session still failing with "Session not found": yes, F.

  • F is still in Chat and failed at 21:51:09, 21:51:16, 21:53:57 and 21:58:26Z. G failed twice at 21:51 and has since moved to Terminal mode.
  • F's chat-host comes from the 2026-10-02 daemon generation and is orphaned (host.json startedAt 2026-10-03T00:51:44Z, token redacted):
39960     1 Fri Oct  2 17:51:44   1984 Ss  ao chat-host F …
39962 39960 Fri Oct  2 17:51:44    208 S   acp-runtime/node … node_modules/@agentclientprotocol/claude-agent-acp/dist/index.js   (etime 1-00:37:08, cpu 0:06.34)
          (no children)

So the claude-agent-acp node process is alive, with 208 KB RSS (paged out), and has no claude child.

New, after the reporter's fix: D still can't switch to Chat, and the failure looks different. After D was brought back (it is running in TUI mode), Terminal→Chat failed again at 2026-10-04 01:27:46Z:

tui|chat|failed|TARGET_RESUME_FAILED|switch interface D: resume chat: context deadline exceeded|01:27:46.255Z → 01:27:51.147Z

This time it failed after about 5 s. Earlier attempts waited about 60 s and failed with TARGET_HISTORY_UNSETTLED, and the UI toast now shows only "resume chat: context deadline exceeded". D is still on the same native conversation (9ded6307-…), with conversation_checkpoint_state=coordination and conversation_checkpoint_unsettled=1. My read-only mirror of verifyCheckpointTranscript still stops at the same turn:

NOT COMPLETED: turn 19/32 promptId=90e9ec7e ts=2026-10-03T21:54:27.195Z (no assistant record)

That is the two-queued-messages-in-one-turn case from the previous comment. So the transcript evidence hasn't changed. Only the error code and the time to failure have. I can't tell from here whether something now fails earlier, before the checkpoint wait, or whether the deadline got shorter. Hypothesis, not confirmed.

GabrielGoncalvesICE avatar Oct 04 '26 01:10 GabrielGoncalvesICE

Fixed by #8195, a lost ACP session now recovers on resume.


Generated by Claude Code

Rishet11 avatar Nov 28 '26 19:11 Rishet11