Skip to content

fix(agent-runs): ignore user turns that ended without output - #826

Merged
astyfx merged 1 commit into
mainfrom
feat/agent-macro
Oct 25, 2026
Merged

astyfx merged 1 commit into
mainfrom
feat/agent-macro

Conversation

@astyfx

@astyfx astyfx commented Oct 25, 2026

Copy link
Copy Markdown
Member

Summary

A reply the Agent run refused before it ran (for example a macro pinned to Codex sent into a Claude run) no longer makes the run continue its stage and write the original stage prompt into the transcript a second time.

Changes

Fixes

  • agent-runs: user turns on the lead task that ended failed with no output (refused at admission, or a provider that failed at once) are skipped when the run reads the task's turns. They no longer start a continue-after-user turn, resume an expired wait, or count as a user reply. The check reads the turn's terminal receipt, which is written in the same transaction as completed_at, so it holds across a restart. Turns the run itself linked keep their existing retry and nudge handling.

Test Evidence

  • New regression test in tests/agent-run-runtime.test.ts: a Claude run blocks its stage, a Codex reply is refused with "keeps the provider it started on" and ends failed with no output. The run starts no new turn, records no user-turn and stays blocked, also after a restart. A user turn that ran with output still continues the stage. Without the fix the test fails with two run turns instead of one, which is the reported incident.
  • bun test tests/agent-run-runtime.test.ts tests/agent-run-policy.test.ts tests/agent-run-event-wait.test.ts tests/delegated-agent-run.test.ts tests/agent-run-briefing.test.ts tests/agent-run-renderer-stores.test.ts: 262 pass, 0 fail
  • bun run typecheck: pass
  • oxlint --report-unused-disable-directives src electron server scripts: pass (existing warnings only)
  • bun run build:pages: pass

Notes

  • A reply that fails with no output now leaves the run where it was; the user resends it from the failed-send bubble. The refused text itself was already kept out of the transcript as a failed send, which is unchanged.
  • Not verified in a running Stave build.

🤖 Generated with Claude Code

A reply the run refused at admission (for example a macro pinned to
another provider) ends failed before any output. The supervisor counted
that turn as a user reply, started a continue-after-user turn and wrote
the stage prompt into the transcript again. Turns whose terminal receipt
says failed with no output are now skipped when the run reads the lead
task's turns, so they neither continue the stage, resume a wait nor
count as a reply.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@astyfx
astyfx requested a review from a team as a code owner October 25, 2026 12:33
@astyfx
astyfx requested review from heath-s and schang124 and removed request for a team October 25, 2026 12:33
@astyfx
astyfx enabled auto-merge (squash) October 25, 2026 12:34

@heath-s heath-s left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved

@astyfx
astyfx merged commit d88bccd into main Oct 25, 2026
6 checks passed
@astyfx
astyfx deleted the feat/agent-macro branch October 25, 2026 12:43
@astyfx astyfx mentioned this pull request Oct 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants