You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
deleteSubAgent doesn't stick while a client is still connected #2003
A client opens a WebSocket to a sub-agent (a /sub/... path through the parent).
The parent calls deleteSubAgent for that sub-agent. hasSubAgent now returns false.
The client sends one more message, or just disconnects.
hasSubAgent returns true again. The sub-agent is back, with fresh state.
Expected: the sub-agent stays deleted.
Cause: the parent routes every incoming WebSocket frame with _cf_resolveSubAgent, which creates the sub-agent when it doesn't exist. deleteSubAgent doesn't close open connections. So the old connection survives the delete, and its next message (or its close event) recreates the sub-agent it was pointing at.
Repro on main (a68736f), using the existing test agents:
constparent=awaitgetAgentByName(env.TestSubAgentParent,parentName);awaitparent.subAgentPing(childName);constws=awaitconnectWS(`/agents/test-sub-agent-parent/${parentName}/sub/counter-sub-agent/${childName}`);awaitparent.subAgentDelete(childName);expect(awaitparent.has("CounterSubAgent",childName)).toBe(false);ws.send("straggler");// or just ws.close()awaitexpect.poll(()=>parent.has("CounterSubAgent",childName)).toBe(true);
Workaround: in _cf_forwardSubAgentWebSocketMessage and _cf_forwardSubAgentWebSocketClose, check hasSubAgent first and drop the frame when the sub-agent is gone.
Activity
refactor(agents): drop unreachable defensive checks in _cf_resolveExi…
fix(ai-chat): keep thread deletes clean while the thread is open
feat(ai-chat): close the error and abort edge-case gaps (#791)
Merge origin/main into fix-2003-subagent-delete
fix(agents): drop late frames from a deleted sub-agent's socket so th…
fix(agents): stop deleteSubAgent from being reversed by a stale sub-a…