Skip to content

fix(agents): let read-only settled turns continue with tools after an empty stop - #178192

Merged
steipete merged 1 commit into
mainfrom
codex/settled-continuation-readonly-tools
Oct 20, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/settled-continuation-readonly-tools

Conversation

@steipete

Copy link
Copy Markdown
Contributor

What Problem This Solves

When a model returns an empty or non-visible stop right after settled tool calls, the embedded runner gives it one "settled tool terminal continuation". That continuation is text-only (tools disabled, reduced transcript) so a model cannot repeat side effects. It also ran when every settled tool in the attempt was read-only. A model that stalled mid-task could then only answer that it cannot read the remaining files.

Live, Groq openai/gpt-oss-120b on a six-file read task: after 4-5 successful read calls Groq returns a genuinely empty completion (finish_reason: stop, no content, no reasoning; wire-captured through a logging proxy). The text-only continuation then produced "I'm unable to read the remaining files without tool access" or a partial answer. In one run it returned raw tool-call markup as the reply. The same model in a direct API loop completes the task, so the empty stop is transient.

User Impact

Turns that stall after read-only tool work can now continue the task with their tools. Turns that may have caused side effects, or that lack side-effect evidence, keep the existing text-only finalization unchanged.

Why This Change Was Made

The decision point in incomplete-turn-recovery.ts now keeps normal tools and transcript for the one continuation only when current-attempt replay evidence explicitly reports hadPotentialSideEffects === false. That is the same classifier the replay-safety paths already use. The instruction says to continue the task and not repeat completed calls. The retry budget (one continuation) and silent-reply handling are unchanged. terminal-resolution.ts routes those attempts to the normal continuation instead of isolated finalization; the finalizer itself is untouched.

Evidence

  • Live A/B, openclaw agent --local, Groq gpt-oss-120b, six sequential reads, 4 runs each: main 0/4 correct (7/7 failures across the investigation); this branch 2/4 fully correct. The other two reached 5 of 6 words before a second empty stop exhausted the unchanged one-retry budget.
  • Regression: Claude Haiku 5.5 and DeepSeek V4 Pro unchanged on the same task.
  • Tests: 307 across 21 files, including read-only, side-effecting, and missing-evidence regressions plus prompt-prefix stability.
  • Codex autoreview (P1, focus on side-effect classification, loops, NO_REPLY semantics): scoped-clean.

… empty stop

Retain the normal tools and transcript for one continuation only when current-attempt replay evidence explicitly reports no potential side effects. Keep isolated text-only finalization unchanged for possible effects or missing evidence, including its failure warning and existing retry budget.
@steipete
steipete marked this pull request as ready for review October 20, 2026 07:01
@clawsweeper

clawsweeper Bot commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-20T07:07:03.047908Z def611c Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: M labels Oct 20, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: def611ce84

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

};
const answer = classifyAssistantTurn({ attempt, payloadCount: 0 });
const instruction = resolveSettledToolTerminalContinuationInstruction({
const continuation = resolveSettledToolTerminalContinuation({

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P1 Badge Pass current replay evidence to worker continuations

readSubscriptionCompletionEvidence() supplies only replayMetadata, but resolveSettledToolTerminalContinuation() retains tools only when attempt.currentAttemptReplayMetadata?.hadPotentialSideEffects === false. Consequently, every worker turn still gets disableTools: true: after a settled read-only tool and empty stop, this path clears session.agent.state.tools, so multi-read worker tasks remain unable to continue. Populate the current-attempt metadata from this fresh subscription before calling the resolver.

AGENTS.md reference: AGENTS.md:L48-L51

Useful? React with 👍 / 👎.

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. labels Oct 20, 2026
@clawsweeper

clawsweeper Bot commented Oct 20, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs changes before merge.

What this changes

This PR allows one tool-enabled continuation after non-visible output when the current attempt explicitly records no potential side effects.

Example: Groq openai/gpt-oss-120b stops empty after reading four files in a six-file task.

  • Before: Recovery disables tools, preventing the model from reading the remaining files.
  • After: Local recovery retains tools for one continuation; worker recovery still disables them.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) Useful, focused local recovery repair with reported live results, but the worker integration remains ineffective.
Proof confidence 🦐 gold shrimp (3/6) The ordinary contributor proof gate is exempt for this maintainer-authored PR; its body reports local Groq CLI A/B results, but no raw capture is supplied and those runs do not exercise worker recovery.
Patch quality 🦐 gold shrimp (3/6) 1 actionable review finding remain.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: A task can stop partway through reading files because recovery removes the tools needed to finish it.
Reason: The maintainer-authored direction addresses observed incomplete tasks while preserving isolation after possible effects and retaining the existing retry budget.

Merge readiness

⛔ Needs changes before merge - 1 item remains

Keep this PR open: the recovery change has clear value, but the worker adapter never supplies the evidence required to retain tools.

Priority: P2
Reviewed head: def611ce84d0a72bb7405063012783fa44e31a06

Before merge

  • Supply current-attempt replay evidence to worker recovery (P2) - After a worker completes a read-only tool and stops empty, this call receives an attempt built from readSubscriptionCompletionEvidence(), which returns replayMetadata but no currentAttemptReplayMetadata. The new resolver checks currentAttemptReplayMetadata?.hadPotentialSideEffects === false, so keepTools is always false here and the worker still clears its tool list. A task that reads index.txt and then needs remaining.txt cannot benefit from this fix. Build the current-attempt metadata from the fresh completion evidence before invoking the shared resolver, and cover the worker path with a regression.

Findings

  • [P2] Supply current-attempt replay evidence to worker recovery — src/worker/embedded-agent.runtime.ts:439

Tests

  • Missing end-to-end proof: The supplied material does not exercise worker continuation through its production entry point or show the new regression failing on the base.
Agent review details

How this fits together

The embedded runner and worker pass settled tool activity and assistant output into shared recovery policy, which selects either normal continuation or isolated text-only finalization.

flowchart TD
  A[Assistant stops without visible output] --> B[Subscription completion evidence]
  B --> C[Shared recovery policy]
  C --> D[Normal continuation with tools]
  C --> E[Isolated text-only finalization]
  D --> F[Terminal reply]
  E --> F
Loading

Technical review

Best possible solution:

Keep the shared recovery policy and supply explicit current-attempt replay evidence from the worker’s fresh subscription.

Do we have a high-confidence way to reproduce the issue?

Source inspection establishes the worker failure deterministically: missing current-attempt metadata selects disableTools=true after a settled read and empty stop; no target code was executed.

Is this the best way to solve the issue?

Using the existing replay classifier and recovery owner is appropriate; the worker must provide the same explicit evidence that local attempt completion already produces.

Full review comments:

  • [P2] Supply current-attempt replay evidence to worker recovery — src/worker/embedded-agent.runtime.ts:439
    After a worker completes a read-only tool and stops empty, this call receives an attempt built from readSubscriptionCompletionEvidence(), which returns replayMetadata but no currentAttemptReplayMetadata. The new resolver checks currentAttemptReplayMetadata?.hadPotentialSideEffects === false, so keepTools is always false here and the worker still clears its tool list. A task that reads index.txt and then needs remaining.txt cannot benefit from this fix. Build the current-attempt metadata from the fresh completion evidence before invoking the shared resolver, and cover the worker path with a regression.
    Confidence: 0.99

Overall correctness: patch is incorrect
Overall confidence: 0.97

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 11ad47f0ea86.

Provenance checked

Testing

Proof path: in-process harness.

Security

None.

Evidence

Acceptance criteria:

  • pnpm test src/worker/worker.runtime.test.ts --maxWorkers=1
  • pnpm test src/agents/embedded-agent-runner/run/terminal-resolution.settled-request.test.ts src/agents/embedded-agent-runner/run/settled-tool-evidence.test.ts src/agents/embedded-agent-runner/run/settled-turn-finalization.qwen.test.ts --maxWorkers=1
  • pnpm test src/agents/agent-tools.prefix-stability.test.ts --maxWorkers=1
  • git diff --check

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit bdc5529 adds src/worker/embedded-agent.runtime.ts:433 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: bdc552927712; files: src/worker/embedded-agent.runtime.ts)

PR surface

Source +37, Tests +94. Total +131 across 7 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 3 69 32 +37
Tests 4 134 40 +94
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 7 203 72 +131

Review metrics

Metric Value Why it matters
Production versus test changes Production +69/-32; tests +134/-40 Growth selects recovery policy within existing owners and covers read-only, side-effecting, missing-evidence, and retry-budget cases.

Labels

Label changes:

  • add P2: The change addresses incomplete tool tasks after transient empty model output, with a focused worker integration defect remaining.
  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🦐 gold shrimp.
  • add status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.

Label justifications:

  • P2: The change addresses incomplete tool tasks after transient empty model output, with a focused worker integration defect remaining.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🦐 gold shrimp.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

Reviewed October 20, 2026, 3:18 AM ET / 07:18 UTC.

@steipete
steipete merged commit 4601114 into main Oct 20, 2026
219 of 221 checks passed
@steipete
steipete deleted the codex/settled-continuation-readonly-tools branch October 20, 2026 07:39
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

steipete added a commit that referenced this pull request Oct 20, 2026
PR #178192 moved terminal recovery onto the aggregate retry policy. Keep its two component helpers private and exercise the same expectations through that public policy. PR #178116 replaced the Telegram group-config alias with the canonical resolver type; remove the unused alias.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 21, 2026
… empty stop (openclaw#178192)

Retain the normal tools and transcript for one continuation only when current-attempt replay evidence explicitly reports no potential side effects. Keep isolated text-only finalization unchanged for possible effects or missing evidence, including its failure warning and existing retry budget.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 21, 2026
PR openclaw#178192 moved terminal recovery onto the aggregate retry policy. Keep its two component helpers private and exercise the same expectations through that public policy. PR openclaw#178116 replaced the Telegram group-config alias with the canonical resolver type; remove the unused alias.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: M status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant