Repository navigation
fix(wake): a wake turn knows the conversation that delegated and replies into it (#4537) - #4606
Conversation
…ies into it (#4537) A person asks an agent in chat to "ask X and tell me what it said". The agent delegates asynchronously and replies that it will report back. The wake turn then ran cut off from that conversation at both ends: its frame carried only the callee's ending, so the agent had lost the request and its own plan, and its reply stayed on the execution row, so the person never saw it. The wake frame now quotes the delegating turn, read off the link the callee row already records (continues_execution_id): what the agent was asked and what it replied then. A wake that delegates again links the next callee to the wake itself, so the request is read from the head of that chain and the plan from the turn that delegated last. Every row on the way must be the delegator's own; the text is sanitized and capped. When the head of the chain is a person's turn in an agent chat thread, the wake's reply is written into that thread as the agent's next message. It is written at the wake row's own terminal, which every terminal writer reaches, once per wake, on SUCCESS only, and announced with the existing thin chat_response_ready trigger. The open ChatPanel refetches its session in place on that trigger. The Chat tab sends /task, which never named its thread on the row, so persist_chat_session now does, after its own messages are saved. Workspace, Slack and Telegram conversations are unchanged: a delegated run already reports into those through its inherited channel context. Fixes #4537 Co-Authored-By: Claude Fable 5.2 <[email protected]>
) The new chat writer copied the persisted row's response without calling the runtime secret-scrub seam, which the ent#279 parity guard requires of every message-table writer. Co-Authored-By: Claude Fable 5.2 <[email protected]>
|
merge-train (2026-11-17): not on this train — the frontend half needs work. Validated at The backend half is strong: the 17 tests drive Findings, all in the frontend half:
2 and 3 are the symptom #4537 reports surviving on two paths, which is why this does not ride. Smaller: Scope note for when it comes back: #4537 also names wakes on an answered ask ( Rides the next train once fixed; |
|
✅ Nightly unit-suite clean when this PR is merged into |
…a failed turn (#4537) Review of the frontend half found the reply still lost on two paths, and nothing executing any of it: - A reply that landed while a turn was in flight was skipped, and a turn's end never refetches messages. The re-read now waits for the turn and runs when it ends. - 'Only when it grew' compared lengths. After a failed or cancelled turn the panel holds a message the server never saved, the counts are equal, and the reply was not shown. utils/chatSessionMerge decides by identity: a stored row by its id, a row the panel pushed itself by role and text. Rows only the screen has stay where they were. - A mounted spec drives the whole path: the chat_response_ready frame on /ws, the store, the panel's watcher, the session re-read and the merge. Docs: the user docs for wake-on-ending and report-back describe the reply landing in the Chat tab. Co-Authored-By: Claude Fable 5.2 <[email protected]>
Review findings addressed (
|
The sync-on-loop ratchet (#4680, now on dev) counted six blocking calls this PR added inside async def: the delegating-turn and reply-thread reads in _post_wake_reply and _claimed_wake, the chat-message write in post_platform_turn_reply and the execution/session link in persist_chat_session. Each now hops to a thread; the ratchet holds at its baseline with no entry raised. test_4536_wake_window steps the wake window one loop tick at a time, so its fixture runs that read inline: the choreography it pins is the window's. Also repoints agentDetailTalkDoor.spec.js at utils/chatSessionMerge.js, where the row mapping it pins now lives. Co-Authored-By: Claude Fable 5.2 <[email protected]>
Two CI failures fixed (
|
|
merge-train (2026-11-24): on this train. Validated at Nothing was pushed to this branch. The body keeps This PR and #4745 both add a bullet to Follow-ups, none blocking:
|
vybe
left a comment
There was a problem hiding this comment.
merge-train: batch validated on train/20261124-0752
…lets after #4606) Co-Authored-By: Claude Fable 5.2 <[email protected]>
Summary
A wake turn was cut off from the conversation that caused it, at both ends (#4537, found in v1.0.5 testing, row A5):
How
caller_wake_service._delegating_turnsfollowscontinues_execution_id(already written by ent#1225) from the callee row. The first row is the turn that delegated (its reply is the plan). The chain is followed through platform continuations to the turn at its head, whose message is the request, so round two of a delegate→wake loop still reads the person's request. At most 8 hops, and every row must be the delegator's own. Text is sanitized and capped from the end._post_wake_replyruns at the wake row's own terminal (the hook_drain_missedalready uses, reached by every terminal writer). SUCCESS only, once per wake (idempotency keycaller_wake_reply:{wake_id}, released if the write fails).source_user_id, nosource_agent_name) and the session is that person's thread of that agent.chat_persistence_service.persist_chat_sessionnow names the thread on the row (chat_session_id)./chatalready did (bug: a watchdog-recovered chat turn never writes its assistant message — row says SUCCESS, thread shows nothing #3380); the Chat tab sends/task, which did not.chat_response_readytrigger (identifiers only).ChatPanelre-reads the session it shows, in place.utils/chatSessionMerge.js): a stored row by its id, a row the panel pushed itself by role and text. After a failed turn the panel holds a message the server never saved; the reply is still shown, after it.No schema change: both columns exist.
Not changed
channel_completion_report). The wake's own reply is not posted there. Stamping a destination on the wake changes who the turn is for (feat(workspace): Discuss and Dismiss on asks (abilityai/trinity-enterprise#747, #748) #3181 review F1), so that is left for its own change./taskturn is saved posts nothing: the thread is named on the row only once that turn's own messages are written.Test Plan
cd tests && pytest unit/test_4537_wake_conversation.py— 17 passedtest_4536_wake_window,test_ent1102_caller_wake,test_4357_wake_chain_depth,test_ent1216_wake_turn_reads,test_ent1225_continuation_tier,test_1444_chat_session_persistence,test_2329_pull_delivery_parity, and others) — 393 passedchatPanelWakeReply4537.mount.spec.js— 16 passed. The realChatPanel, driven from thechat_response_readyframe on/wsthrough the store to the re-read. Nine mutations (handler, store, watcher, mid-turn wait, length compare, other-session guard, id, local-row matching) each turn a test redChatPanelspecs passPOST /api/agents/{name}/executions/{id}/result), put the reply in the thread once (a repeated callback added nothing) and onechat_response_readyevent arrived on/wsScope
This is part of #4537, so the issue stays open. Not in this PR:
operator_response/operator_ending);Journey Impact
Journey Impact: none: no journey in tests/journeys/catalog.yaml covers agent-to-agent delegation or the operator Chat tab
Related to #4537
🤖 Generated with Claude Code