Repository navigation
fix(agent): fail a Room Run that never replied to a waiting Human - #230
oldwinter53 wants to merge 1 commit into
Conversation
A Pi Run on a small local model often answers in its final text without calling the message command. The Run then succeeded and the Room showed nothing. A Room Run that never tried to post while a Human's Message that mentioned the Agent waits now finishes failed with reply_not_sent, so the Room shows the cause. The final text stays private scratch and is not posted for the Agent. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
Approve with nits (1 P2)
Scope: base main, merge base fb2e1537, 1 commit, 14 files reviewed at 6c3969b6. Loaded skills: coderbook, ponytail-review, karpathy-guidelines. Ran in a separate session.
Findings
P2
A Run resumed after a restart can fail with reply_not_sent even though the reply is already in the Room (apps/node-services/src/agent/executor/run-loop.ts:1009)
#runExecutionbuilds a freshReplyDeliveryfor each claim attempt and callsobserveInputs(execution.messages). A Run that the process stops for a restart is requeued (local_run.requeued_for_restart, around line 1462). The next process resumes it in the same native session withresumesAttempt = true, so the original mentioned-Human input sets#awaitingHumanagain while#attemptedWritesgoes back to 0.- The resume prompt (
renderInterruptedRunReminder,prompt/inbox-notification.ts:133) tells the Agent that "the messages you already sent" are in native history and not to repeat operations that already ran. Failure case: the Agent posts its answer, a deploy restarts node-services before the turn ends, and the resumed attempt finishes without a newmessage send. The Human then sees a red "Pi: The Agent finished without sending its reply to the Room… choose a stronger model" under a reply that is already there. The yield path is fine because it reuses the sameReplyDeliveryacross segments. Only the cross-process resume is affected. - Fix: skip the
reply_not_sentdecision whenexecution.resumesAttemptis true, either by not callingobserveInputsfor the initial messages in that case or by passing the flag into#completedTerminal. Steered inputs that arrive after the resume can still count. Add a run-loop test that claims withattemptCount: 2, has no message writes, and expectssucceeded.
Verified as fine
- The detection uses structured fields only (
mentioned,authorType == "user",messageKind == "conversation"fromacceptedNotification.messages) and matches no wording. Those are the same fieldsrun-kind.tsandaccepted-fact.tsalready read. - The Computer classifies
teamhub message <send-verb>asmessageand every othermessagesubcommand asmessage_read(command_activity.go:376-380). Counting attempts onactivity.startedof kindmessageis therefore correct, including failed writes, whichreply_undeliveredstill handles first. - Steered inputs are observed only after
provider.steersucceeds (#applyProviderSteer), so a steer that is folded back into a new Run is not counted twice. The yield/continue loop shares oneReplyDelivery. - Task (
alter_ego), Document and trusted/feature inputs have noacceptedNotificationor are notmeta, so they are unaffected. - The prompt still allows silence for routines, background results and Room talk not aimed at the Agent (
compact-meta-instructions.ts:37,meta-instructions.ts:104), which matches the new rule. - Contract change is in
contracts/openapi/components/agent-runtime-state.yaml, and the generated Go/TS diffs match the enum addition. The TeamHub validator accepts the new code. Old web clients fall back to "Run failed" for an unknown code (runtimeFailureMessagechecksObject.hasOwn). - Docs:
apps/node-services/src/agent/AGENTS.mddescribes the new failure. No new env vars, no cross-app imports, English-only. - Critical path: the check runs after the Provider turn completes, so there is no extra round trip before
provider_ready, as the PR body says. - Tests cover the mentioned-Human, steered-mention, replied, unmentioned, routine and agent-mention cases. The Go and web tests cover the new code.
Process notes
- The branch is 6 commits behind
main, andmainrequires up-to-date branches, so it needs a rebase. - Single commit with no merge or fixup commits. The commit author email
cdd@simplexai.comresolves to GitHub accountoldwinter90, which is not the PR authoroldwinter53. Please confirm this is intended.
CI
At review time CodeQL, Analyze, changes, repository-gate, check (desktop), check (installer) and check (teamhub-cli) had passed. check (computer-go) was skipped. check (contracts), check (packages), check (teamhub), web tests 1–3 and web-static were still pending, and no node-services check was listed yet. I did not run the focused node-services test: the worktree has no node_modules, and installing them just to run it was not justified. The finding comes from reading the code.
Automated review by Claude Code
Automated review of 6c3969b by Claude Code.
Problem (P1-7, #172)
Pi on a small local model often answers in the Run's final text without calling
teamhub message send. The Run reportedsucceededand the Room showed nothing: no reply and no failure.Root cause:
ReplyDelivery.replyUndelivered(apps/node-services/src/agent/executor/reply-delivery.ts) failed a Room Run only when it tried to post and every write failed. An Agent that never tried was treated as choosing silence, so#completedTerminalinrun-loop.tsreturnedsucceeded. Silence is correct for Room talk the Agent only reads along with, but not when a Human mentioned it and is waiting.Fix
A Room (Meta) Run now finishes failed with the new code
reply_not_sentwhen both are true:mentioned,authorType == "user", andmessageKind == "conversation". The web sends every direct-chat message with the peer's @mention, so direct chats are covered.Routine wakes, Task callbacks, another Agent's mention, and Room talk that doesn't mention the Agent can still end silently. No wording is matched anywhere.
The final text is not posted on the Agent's behalf. The prompt defines it as private scratch, which often holds reasoning about whether to reply, and node-services has no server-side post path. The Room shows the failure instead: "Pi: The Agent finished without sending its reply to the Room. Its model may have answered without using the message command. Ask again, or choose a stronger model for the Agent."
apps/node-services/src/agent/executor/reply-delivery.ts:observeInputs,replyNotSent,awaitsReplyapps/node-services/src/agent/executor/run-loop.ts:#completedTerminalreturnsreply_not_sentand logslocal_run.reply_not_sent. Steered inputs are observed in#applyProviderSteer.contracts/openapi/components/agent-runtime-state.yaml(regenerated)apps/teamhub/internal/agentruntimestate/runtime_failure.goapps/web/src/features/rooms/runtime-status/runtime-failure-message.tsapps/node-services/src/agent/AGENTS.mdCritical path (user message →
provider_ready): no change. The check runs after the Provider turn completes and adds no network round trip or file walk.Not in this PR
skipin the Inbox disposition, and a failed Run is not replayed. The loop looks like model behavior inside one Runtime turn, and that needs the real-machine check below before adding a per-Run budget or duplicate guard.Tests
Written first. Both "posted nothing" cases came back
succeededbefore the fix.apps/node-services/tests/agent/executor/run-loop.test.ts› Room reply delivery:reply_not_sent, the final text stays out of the terminal, andlocal_run.reply_not_sentis logged.reply_not_sent.runtime_failure_test.go:reply_not_sentis accepted.runtime-failure-message.test.ts: copy forreply_not_sent.Checks run locally:
make check-node-services(260 files, 2622 tests)make check-webmake -C apps/teamhub fmt-check,go test ./tests/integration/layout,make -C apps/teamhub testpnpm contracts:verifymake check-repository-gate BASE=origin/mainmake check BASE=origin/mainalso selects check-packages and check-computer because the generated contracts changed. check-packages passes once mise's exportedGOROOT/GOBINare unset.TestManagedToolsUpdateKeepsResidentDaemonPID("Managed tools require Node 26.5.0") fails on this host on an unmodified origin/main too, so it isn't caused by this change.Real-machine checks (FIXLIST section 6, item 5; 0.1.4 RC round)
macOS (macmini, zh-CN, 24 GB), Pi with Spark-X2.6 4B, then again with LFM3 1.7B:
local_run.reply_not_sentevent withdeliveredMessageWrites: 0.reply_not_sentappears (regression check).🤖 Generated with Claude Code