vscode icon indicating copy to clipboard operation
vscode copied to clipboard

Agent host: send_message to a session evicted as idle fails with "Unknown chat owner" instead of restoring it

Open wcushing-st opened this issue 3 weeks ago • 4 comments

Environment

  • Agent host: VS Code 1.145.1 (commit 6bab64e2d12b04d04c0d99c27ff166023efd1dda) on a Linux x64 server, used over Remote-SSH.
  • @github/copilot-sdk-linux-x64 1.0.27-unstable.41379698026.g3219c66

Steps

  1. Session A is idle, and the host evicts it: 22:51:55.362 [AgentService] Evicting idle session: ahp-session:/b3d0673a-… (triggered by unsubscribe of ahp-session:/b3d0673a-…)
  2. From agent-host session B, call the send_message tool with session A as the target.

Actual

The tool call fails and no turn starts in A. A's SDK events.jsonl is unchanged. Host log:

23:18:31.145 [Copilot:2192990e-…] Tool started: send_message
23:18:31.169 [warning] [AgentHostStateManager] Action for unknown chat: ahp-chat:/aa71d0a0-c6b9-4d7a-b535-8832aca9de16, type=chat/turnStarted
23:18:31.169 [error] Error: Unknown chat owner: ahp-chat:/aa71d0a0-c6b9-4d7a-b535-8832aca9de16
    at cb.requireChatOwner (agentHostMain.js:93:14304)
    at fR.requireChatOwner (agentHostMain.js:1053:6097)
    at nk.handleTurnStarted (agentHostMain.js:1442:26579)
    at nk.startTurnMessage (agentHostMain.js:1442:25128)
    at Bk._startSessionMessage (agentHostMain.js:1458:46176)
    at Bk._startSessionPrompt (agentHostMain.js:1458:45989)
    at Object.startPrompt (agentHostMain.js:1458:35488)

ahp-chat:/aa71d0a0-… is A's chat. Earlier the host logged Resumed chat backing ahp-chat:/aa71d0a0-… for configuration ahp-session:/b3d0673a-… (22:36:02).

Expected

startPrompt should restore an evicted session before it starts the turn. Evicted sessions can be restored: on the same host, ahp-session:/59a8386a-… was evicted at 22:36:31 and restored at 22:51:55. If restoring isn't possible, send_message should say the target is evicted and must be reopened, rather than report an internal ownership error.

Possibly related: the target session in this report is the one described in #346413.

wcushing-st avatar Nov 05 '26 23:11 wcushing-st

Also reproduced on VS Code Server commit 261c84cb1eddf11235f9e2c921425e9663fbe556 (Linux, 2026-11-06).

  • The host logged Evicting idle session ... (triggered by unsubscribe ...) at 16:12:40 local time. send_message calls at 16:12:50 and 16:15:01 failed with Unknown chat owner: ahp-chat:/....
  • The calls used the target's full agent-host-session://ahp-session/<uuid> link from list_sessions. The session's persisted record was present and unarchived.
  • Retrying didn't help, and neither did calling get_session_context first. Opening the target chat in the UI restored it, and later sends then worked.

In the bundle, send_message resolves the link to the session's default chat and then calls requireChatOwner on the in-memory registry. Other paths seem to have a fallback to a retained chat owner. Either using that fallback here or restoring the session before starting the turn would fix it. As things stand, an orchestrating session can't deliver work to an idle session without a person reopening its chat.

roscroft avatar Nov 06 '26 22:11 roscroft

Happy path success here is that the target session is reactivated and the message is delivered.

Per OP's comments, the target session should be retored so that message passing works. If restoring the session fails, then the error should be "the session could not be restored, manually open the session". The fix here should not simply change the error message to "reactive the session", which would not improve the user's experience in automated message passing.

This also leads to the residual unsent message. In the case where the target session legitimately could not be retored automatically and the user had to intervene to restore it, how would a user cause the message to be resent once the target session has been resotred? The sending session would not likely be automatically be informed barring a polling message queue of some sort that detected that the target session was now re-enabled.

chiefgeek157-pnnl avatar Nov 13 '26 18:11 chiefgeek157-pnnl

I also ran into this. I'm pushing a fix in #348805.

benibenj avatar Nov 17 '26 10:11 benibenj

Thanks for the fix in #348805. Could it be considered for a 1.147 recovery release?

The current stable builds don't have it:

  • 1.146.0 (69047191fc427f2f92828279aae1d90d8eeda7ab, VS Code Server on WSL2): same failure as above. One agent-host log today had 14 send_message failures across 6 target chats. Each target had been evicted ~10 s after its last unsubscribe. Messages to targets that were still loaded succeeded.
  • 1.147.0 (8a14f0cc1b08d531eb83255ea3764ae22aa932b5): #348805 isn't on release/1.147, and the agent-host bundle has no restoreChat accessor, so I expect the same behavior there. I haven't reproduced it on 1.147.0.

So on stable, send_message can only reach sessions currently shown in a window.

[warning] [AgentHostStateManager] Action for unknown chat: ahp-chat:/b4882d81-511c-4ce3-a35d-19e2abe856fd, type=chat/turnStarted
[error] Error: Unknown chat owner: ahp-chat:/b4882d81-511c-4ce3-a35d-19e2abe856fd
    at Wb.requireChatOwner (agentHostMain.js:93:14304)
    at QR.requireChatOwner (agentHostMain.js:1117:6097)
    at zk.handleTurnStarted (agentHostMain.js:1516:9294)
    at zk.startTurnMessage (agentHostMain.js:1516:7843)
    at xP._startSessionMessage (agentHostMain.js:1532:51073)
    at xP._startSessionPrompt (agentHostMain.js:1532:50886)
    at Object.startPrompt (agentHostMain.js:1532:36863)
    at Object.startPrompt (agentHostMain.js:1604:14163)
    at V3e (agentHostMain.js:121:60103)
    ... Failed in server tool handler: tool=send_message

SlawomirNowaczyk avatar Nov 18 '26 12:11 SlawomirNowaczyk