Skip to content

fix(agents): narrow the unfinished-steps retry guard to actual committed mutations (ENG-18893) - #192

Merged
convyusboy merged 3 commits into
boonfrom
ridho/eng-18893-fix-unfinished-steps-side-effect-guard
Sep 4, 2026
Merged

convyusboy merged 3 commits into
boonfrom
ridho/eng-18893-fix-unfinished-steps-side-effect-guard

Conversation

@convyusboy

@convyusboy convyusboy commented Sep 3, 2026 •

Copy link
Copy Markdown
Collaborator

What Problem This Solves

The hadPotentialSideEffects guard added to shouldRetryUnfinishedSteps in #188 (its own code-review fix) was too broad and silently defeated the retry it was supposed to only narrow — for its own primary use case.

Why This Change Was Made

tool-replay-safety.ts never marks exec/bash/process as replay-safe by default (they can run arbitrary commands), so hadPotentialSideEffects is true any time an exec-class tool was called at all — which is unconditionally true for every attempt this retry exists to handle (isRecoverableExecClassToolName gates on exactly those tool names). The guard from #188 was therefore blocking the retry 100% of the time it should have fired.

Confirmed live, not just in theory: deployed the merged boon HEAD to a canary host (arief-openclaw-test) and drove a real turn through the real gateway (real model, real boon-llm-gateway → Bedrock, real anychat-boon-web plugin) that fails a single exec call. Before this fix: zero retries, straight to the fallback note. After this fix: unfinished steps detected: ... retrying 1/2 with continuation nudge, then a clean resolution with no fallback note at all.

The fix narrows the guard to the specific mutation evidence the original review finding actually described — a committed messaging-tool send, cron add, or session spawn (hasMessagingToolDeliveryEvidence, hasAcceptedSessionSpawn, successfulCronAdds) — instead of the broad replay-safety flag that also covers the mere presence of an unreplayable tool call.

The existing unit + full-loop tests didn't catch this because they used empty toolMetas arrays — none of them modeled a real failed exec call, which is exactly the shape production traffic has. Strengthened those tests to include a realistic toolMetas: [{ toolName: "exec" }] entry, plus new coverage for the narrowed guard (a committed messaging-tool send still blocks the retry; a solo exec failure with no other mutation does not).

User Impact

Restores the actual intent of #188 — non-terminal exec-class failures now silently retry as designed, without reopening the messaging/cron/session-spawn duplication risk the original review finding was right to flag.

Evidence

  • node scripts/run-tsgo.mjs -p tsconfig.core.json --incremental --tsBuildInfoFile .artifacts/tsgo-cache/core.tsbuildinfo — clean.
  • node scripts/run-oxlint-shards.mjs --threads=8 — clean.
  • node scripts/run-vitest.mjs src/agents/embedded-agent-runner/run.incomplete-turn.test.ts — 118/118 passed, verified post-rebase onto latest origin/boon.
  • Live-verified on canary host arief-openclaw-test (real boon-llm-gateway/Bedrock model, real gateway process) — before/after comparison above.

Follows #188 (merged) on ENG-18893: https://linear.app/getboon/issue/ENG-18893/gemstone-industrial-proposal-generation-generic-one-step-didnt-finish


Summary by cubic

Fixes the unfinished-steps retry guard so a failed exec call retries as designed instead of always falling through to the "steps didn't finish" note. The previous hadPotentialSideEffects check was unconditionally true for every attempt this retry exists to handle, which silently defeated the retry for its own primary use case (ENG-18893).

  • Replaced the broad replay-safety flag with a hasCommittedMutation check limited to messaging-tool sends, cron adds, and session spawns.
  • Updated tests to include realistic exec toolMeta entries, which the previous empty fixtures missed, and added full-loop coverage for the cron-add and session-spawn mutation paths.

Written for commit 1ccaad4. Summary will update on new commits.

Review in cubic

…ted mutations (ENG-18893)

The hadPotentialSideEffects check added in the previous fix was too broad: it
is unconditionally true whenever an exec/bash/process tool was called at all
(tool-replay-safety.ts never marks those replay-safe by default), which is
true for every single attempt this retry exists to handle
(isRecoverableExecClassToolName gates on exactly those tool names). The guard
was silently defeating the retry for its own primary use case — confirmed
live on a canary host (arief-openclaw-test): a solo failed exec call never
retried at all, going straight to the fallback note.

Narrowed shouldRetryUnfinishedSteps to the specific mutation evidence the
original review finding actually described — a committed messaging-tool
send, cron add, or session spawn — via hasMessagingToolDeliveryEvidence,
hasAcceptedSessionSpawn, and successfulCronAdds, instead of the broad
replay-safety flag. Re-verified live on the same canary host: the retry now
fires correctly and resolves the turn without ever surfacing the
'steps didn't finish' note.

Strengthened the existing unit + full-loop tests to include a realistic
failed exec toolMeta entry (the previous tests used empty toolMetas, which
is why they didn't catch this regression), plus new coverage for the
narrowed guard.
@convyusboy
convyusboy requested a review from a team September 3, 2026 17:20
@claude

claude Bot commented Sep 3, 2026 •

Copy link
Copy Markdown

Claude encountered an error —— View job


I'll analyze this and get back to you.

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

All reported issues were addressed across 3 files

Reply with feedback, questions, or to request a fix.

Fix all with cubic | Re-trigger cubic

…paths at the full-loop level (ENG-18893)

cubic review flagged that the new full-loop coverage only exercised the
messaging-tool branch of the committed-mutation guard; the other two
evidence paths wired into hasCommittedMutation in run.ts
(hasAcceptedSessionSpawn, successfulCronAdds > 0) were only proven at the
unit level, so a wiring regression there would silently let retries fire
after a committed cron add or session spawn -- the exact broad-suppression
vs duplicate-mutation risk this PR exists to guard against.

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

1 issue found across 1 file (changes from recent commits).

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="src/agents/embedded-agent-runner/run.incomplete-turn.test.ts">

<violation number="1" location="src/agents/embedded-agent-runner/run.incomplete-turn.test.ts:1649">
P3: The two new test titles embed the Linear ticket ID `(ENG-18893)`. Keep test titles focused on the behavior being asserted and drop the ticket reference, consistent with the established convention in this file that describe() blocks are ticket-free.</violation>
</file>

Reply with feedback, questions, or to request a fix.

Fix all with cubic | Re-trigger cubic

Keep test titles focused on the behavior being asserted rather than the
Linear ticket; the ticket context lives in the commit message and PR body.

@gandalfboon gandalfboon Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Approve.

The fix correctly diagnoses #188: hadPotentialSideEffects decomposes to hadUnsafeTools || hadAsyncStartedTool || messaging || sessionSpawn || cronAdd, and hadUnsafeTools is unconditionally true for every exec/bash/process failure — i.e. every case isRecoverableExecClassToolName gates on — so the guard was firing 100% of the time it should have opened. Narrowing to hasCommittedMutation = messaging || sessionSpawn || cronAdd restores the retry for its intended cases while keeping the specific duplication risks #188 was right to flag.

Scope check: verified the other five sites still keying off the broad hadPotentialSideEffects (compaction-continuation, incomplete-turn-fallback-safe, isAttemptReplaySafe, etc.) are untouched — only the unfinished-steps retry gate is narrowed. Good.

Test coverage: the exec-toolMeta shape on the existing full-loop tests is the right regression-catcher (empty toolMetas is exactly what let the #188 regression through). The new cron-add and session-spawn full-loop cases close the gap cubic flagged.

One nit — not blocking:
hadAsyncStartedTool (a backgrounded exec) also drops out of the guard by construction. In practice the transcript carries the background session id so the model can poll rather than re-launch, but it's a deliberate line-drawing choice worth calling out in the field-doc comment alongside the hadUnsafeTools explanation — the current comment reads as if the only broad-flag contributor being excluded is the unreplayable-tool-presence one.

CI still cooking (many jobs IN_PROGRESS/QUEUED, cubic review IN_PROGRESS) — hold merge until it goes fully green, per usual.

@convyusboy
convyusboy enabled auto-merge (squash) September 4, 2026 01:18
@convyusboy
convyusboy merged commit 978fbaf into boon Sep 4, 2026
149 checks passed
@convyusboy
convyusboy deleted the ridho/eng-18893-fix-unfinished-steps-side-effect-guard branch September 4, 2026 01:38
convyusboy added a commit that referenced this pull request Sep 4, 2026
…193)

Cuts the next boon-fork release. On merge, tag v2026.6.11-boon.36 ->
boon-release.yml builds & publishes openclaw-2026.6.11-boon.36.tgz (+ sibling
plugin assets) -> the fleet deploy pipeline rolls it.

Ships ENG-18893: the embedded run loop now silently retries a turn that ends
with a real reply but an unrecovered exec-class tool failure (#188), with the
retry guard corrected to key off actual committed mutations rather than the
mere presence of an exec-class tool call (#192).

Diff is mechanical pnpm release:prep output plus the CHANGELOG.md release
section:
- Root package.json boon.35 -> boon.36.
- Lockstep extension package.json + npm-shrinkwrap.json synced to boon.36.
- Regenerated release artifacts: plugin inventory/reference docs, plugin-sdk
  API baseline, config-baseline sha256.

npm pack --dry-run verified end to end (build + changelog extraction +
tarball assembly), version 2026.6.11-boon.36, exit 0.
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