Skip to content

refactor(agents): share incomplete-turn visibility classification - #135374

Merged
steipete merged 1 commit into
mainfrom
fix/anthropic-hard-refusal-sweep
Sep 1, 2026
Merged

steipete merged 1 commit into
mainfrom
fix/anthropic-hard-refusal-sweep

Conversation

@steipete

@steipete steipete commented Sep 1, 2026 •

Copy link
Copy Markdown
Contributor

Related: #134980, #134968, #134281

What Problem This Solves

The terminal-refusal repair in #134980 now prevents repeated full-context requests. Its surrounding empty-turn recovery code still computed the same current-attempt visibility and silent-reply eligibility through overlapping predicates, making it easier for those paths to drift apart during later changes.

This is the separate cleanup follow-up to that repair. Thanks to @Marvinthebored for the original report and fix, and @obviyus for completing the gateway-visible refusal repair and landing it.

Why This Change Was Made

Compute the current assistant, visible text, reasoning-only state, and silent-reply eligibility together in the existing classifier. Empty-response recovery is the same eligibility with reasoning-only turns excluded. Remove the duplicate predicates, unused projected fields, and one-use terminal-error wrapper. Current-attempt provenance remains unchanged; historical assistant messages are not reintroduced.

Also align the model-failover documentation with the already-merged retry-controller consolidation in #134281. No configuration, persistence, protocol, dependency, retry budget, or product policy changes.

User Impact

No runtime behavior change intended. Hard refusals remain terminal and visible; transient server failures retain normal retry behavior. The docs no longer promise the retired outer ten-attempt overload loop.

Evidence

  • Focused verification: 705 passing tests across retry classification, incomplete-turn resolution, refusal terminal resolution, terminal outcomes, and assistant failover.
  • Original defect independently reproduced against pre-fix main 83e75f5e310123a393e91d66f86f95be4117e4b2: structured-refusal retry regression failed with expected false, received true. Restored the candidate immediately afterward.
  • Production LOC: +25/-96 = -71. Test LOC: 0. Docs: +1/-1. Existing regression coverage is reused for this behavior-preserving refactor.
  • Local changed checks passed core typechecking, formatting, and boundary/ratchet checks, then stopped at missing local UI mermaid during core-test typechecking. The full build and first CI run both hit the protocol declaration failure fixed by fix: restore protocol declaration builds #135360. Rebased onto that landed repair; exact-head CI passed (run 33536344740). The supported qaRuntime build passed.
  • Live proof passed: real precompiled gateway child, fresh isolated HOME/state/workspace, loopback mock Anthropic provider, free non-default ports, synthetic credentials only. Two sequential chat.send → agent.wait → chat.history turns verify refusal versus transient HTTP 500. Read-only inspection of the isolated SQLite transcript confirms both terminal records. Owned gateway stopped and temporary state removed.
  • Proof runtime was built at 4455c8f29a6de273f22966982050078882ff88dd; the four-file patch is unchanged by the mechanical rebase to 26bff7dd1c2b5418dc3f2dc17b0feb1c5752fd04 for the declaration-build repair. Source-gateway startup attempts timed out before provider requests; the compiled-runtime proof did not need relaxed retry assertions.

Sanitized live-proof transcript:

refusal: terminal=error, primary requests=1, fallback requests=0
chat.history: The provider refused this request (category: reasoning_extraction). Revise the request and try again.
transient HTTP 500 then success: terminal=ok, primary requests=2, fallback requests=0
chat.history final answer: SYNTHETIC_TRANSIENT_RETRY_COMPLETED
SQLite: refusal assistant stopReason=error, diagnostic=provider_refusal
SQLite: successful retry assistant stopReason=stop, final answer persisted
PASS: refusal terminal; HTTP 500 retried once; both outcomes persisted

ClawSweeper status: both review-start placeholders were removed and no completed review or Rank-up moves: survived. Native prepare passed, but native merge requires a completed ClawSweeper review and correctly refused to land. Requested @clawsweeper re-review of the unchanged green head; no gate is bypassed.

Observations outside this refactor

  • HTTP refusal error detail: /v1/responses also made one request and no fallback, but returned its existing generic 500 / api_error / internal error for a resolved failed agent run. openresponses-http.ts:757 and its terminal-failure tests deliberately suppress provider details. A typed safe refusal response would need a separate error-disclosure contract decision; this PR preserves the existing contract.
  • Recovered-attempt history placeholder: the transient turn's reloaded history includes an intermediate The agent run failed before producing a reply. placeholder before its successful final answer. This comes from the existing error-history projection, not the classification refactor. A separate history/presentation follow-up should decide how recovered attempts appear; no failed run was silently dropped here.

The original fix is already merged as ead8ce050963ae717419a7977a6e7b240ba8b56c; linked issue #134968 is already closed. This PR does not duplicate or reland it.

@clawsweeper

clawsweeper Bot commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation agents Agent runtime and tooling size: S maintainer Maintainer-authored PR labels Sep 1, 2026
@steipete
steipete marked this pull request as ready for review September 1, 2026 17:04
Follow up on #134980 by computing attempt visibility and silent-reply eligibility once, removing duplicated empty-turn predicates and a one-call terminal-error wrapper. Align the failover docs with the consolidated transient retry owner from #134281. Production delta: -71 lines; no behavior or configuration change.
@steipete
steipete force-pushed the fix/anthropic-hard-refusal-sweep branch from 4455c8f to 26bff7d Compare September 1, 2026 17:11
@steipete

steipete commented Sep 1, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

Please complete review of current head 26bff7dd1c2b5418dc3f2dc17b0feb1c5752fd04. Exact-head CI is green: https://github.com/openclaw/openclaw/actions/runs/33536344740 . Native prepare passed; native merge correctly stopped because no completed ClawSweeper review is published. The earlier review-start placeholders were removed, leaving only the acknowledgment.

This is the separate -71 production-line cleanup following already-merged #134980. The PR body contains the live isolated-gateway proof: one structured refusal request, no fallback, bounded guidance after chat.history reload; HTTP 500 retries once and succeeds; both outcomes persisted in SQLite. No config, schema, protocol, dependency, or product-policy changes.

@clawsweeper

clawsweeper Bot commented Sep 1, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@steipete

steipete commented Sep 1, 2026

Copy link
Copy Markdown
Contributor Author

Native landing is blocked by the required completed ClawSweeper review, not by CI or the patch. Head 26bff7dd1c2b5418dc3f2dc17b0feb1c5752fd04 is unchanged; exact-head CI is green and scripts/pr prepare-run passed. scripts/pr merge-run correctly refused to proceed without a completed trusted review.

Three review-generation attempts failed with codex_execution marked retryable: runs 33536691614, 33538186374, and 33539572866. The diagnostic manifests report unknown stage/reason and omit the underlying error. No authentication or provider cause is established. The last two failure artifacts are 9812714888 and 9813186228; the automatic retry was allowed to finish rather than duplicated.

The PR remains open and prepared. No gate was bypassed. Resume native merge after the review service produces a completed review and its findings/Rank-up moves are addressed. The original refusal regression is already fixed by #134980; this is its separate -71-line cleanup follow-up.

@clawsweeper clawsweeper Bot added P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Sep 1, 2026
@steipete
steipete merged commit c6a2bce into main Sep 1, 2026
287 of 288 checks passed
@steipete
steipete deleted the fix/anthropic-hard-refusal-sweep branch September 1, 2026 17:58
@steipete

steipete commented Sep 1, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

@clawsweeper

clawsweeper Bot commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 1, 2026, 1:57 PM ET / 17:57 UTC.

ClawSweeper review

What this changes

This PR centralizes incomplete assistant-turn visibility classification for recovery paths, inlines a one-use terminal-error helper, and corrects the model-failover documentation.

Merge readiness

⚠️ Ready for maintainer review - 1 item remains

Keep this maintainer-owned PR open: its behavior-preserving consolidation is not on fetched current main, and the examined predicates are equivalent to the removed branches.

Priority: P3
Reviewed head: 26bff7dd1c2b5418dc3f2dc17b0feb1c5752fd04

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused, behavior-equivalent refactor with relevant existing coverage and no actionable defect found.
Proof confidence 🌊 off-meta tidepool Not applicable: This maintainer-authored refactor is exempt from the external-contributor proof gate; its body nevertheless supplies an isolated real Gateway trace across the affected terminal and retry outcomes.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This maintainer-authored refactor is exempt from the external-contributor proof gate; its body nevertheless supplies an isolated real Gateway trace across the affected terminal and retry outcomes.
Evidence reviewed 7 items Equivalent shared classification: The new classifier computes the shared non-visible condition once; its empty-response result is that condition excluding reasoning-only output, matching the former empty predicate.
Recovery callers use the canonical result: Silent-reply eligibility, settled-tool continuation, and empty-response retry now consume the same classification while retaining their separate replay-safety and provider guards.
Existing behavioral coverage: Focused tests cover empty responses, reasoning-only turns, side effects, provider-specific recovery, and settled tool continuation through the affected recovery entry points.
Findings None None.
Security None None.

How this fits together

The embedded agent runner classifies provider output before choosing a retry, intentional silence, continuation, or visible terminal result. Gateway-facing completion and history then consume that terminal decision.

flowchart LR
  A[Provider response] --> B[Current attempt evidence]
  B --> C[Visibility classifier]
  C --> D[Retry or silence decision]
  D --> E[Terminal resolution]
  E --> F[Gateway history and reply]
Loading

Before merge

  • Complete next step (P2) - No repair is needed; this maintainer-owned PR should continue through normal review and merge gates.
Agent review details

Security

None.

PR surface

Source -71, Docs 0. Total -71 across 4 files.

View PR surface stats
Area Files Added Removed Net
Source 3 25 96 -71
Tests 0 0 0 0
Docs 1 1 1 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 4 26 97 -71

Review metrics

Metric Value Why it matters
Production versus test delta production -71, tests 0, docs 0 The refactor removes duplicate production predicates without adding test-support or configuration surface.

Technical review

Best possible solution:

Land the single canonical visibility classification with the existing focused recovery coverage and the corrected retry-owner documentation.

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

Not applicable as a cleanup PR; existing focused tests and the supplied isolated Gateway trace cover the preserved recovery behavior.

Is this the best way to solve the issue?

Yes. Computing the shared non-visible condition once preserves both former predicates while removing their opportunity to drift.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against a040b0363656.

Labels

Label changes:

  • add P3: This is a small cleanup and documentation correction with no intended user-facing behavior change.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This maintainer-authored refactor is exempt from the external-contributor proof gate; its body nevertheless supplies an isolated real Gateway trace across the affected terminal and retry outcomes.

Label justifications:

  • P3: This is a small cleanup and documentation correction with no intended user-facing behavior change.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This maintainer-authored refactor is exempt from the external-contributor proof gate; its body nevertheless supplies an isolated real Gateway trace across the affected terminal and retry outcomes.

Evidence

What I checked:

Likely related people:

  • Marvinthebored: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • obviyus: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 2, 2026
…enclaw#135374)

Follow up on openclaw#134980 by computing attempt visibility and silent-reply eligibility once, removing duplicated empty-turn predicates and a one-call terminal-error wrapper. Align the failover docs with the consolidated transient retry owner from openclaw#134281. Production delta: -71 lines; no behavior or configuration change.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling docs Improvements or additions to documentation maintainer Maintainer-authored PR P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: S status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant