Skip to content

fix: malformed tool calls report auth failures when argument length is 401 or 403 - #168500

Merged
steipete merged 3 commits into
openclaw:mainfrom
TYY-2005:fix/malformed-tool-call-auth-classification
Oct 10, 2026
Merged

steipete merged 3 commits into
openclaw:mainfrom
TYY-2005:fix/malformed-tool-call-auth-classification

Conversation

@TYY-2005

@TYY-2005 TYY-2005 commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

Closes #168450

What Problem This Solves

Fixes: malformed tool calls report authentication failures when their diagnostic argument length is 401 or 403.

User Impact

Malformed arguments receive the existing bounded recovery instead of false sign-in guidance or auth-profile failure signals. Genuine authentication failures still report as auth errors.

Why This Change Was Made

The shared failover matcher treated every standalone 401/403 in an error body as authentication evidence, including argumentChars. The matcher now requires a leading status, HTTP/status context, or a structured status/code field. This fixes classification at its owner and preserves the existing continuation and loop budgets.

Original fix and regressions by @TYY-2005. Main was merged into the contributor branch without rebasing or replacing contributor commits. Production: +6/-2 (net +4); tests: +54/-2. The four added lines give the shared status matcher its documented context requirement. The follow-up also corrects an inherited TUI billing-error expectation to the existing formatted HTTP 403 diagnostic, while removing two redundant fields from that same fixture table.

Evidence

  • Baseline main 84b6b0858f387c5b3fbd3e4bc2bc72152b059692: a probe using the actual terminal-argument parser, assistant consumer, and shared classifier fails for malformed lengths 401/403; 400/402/404 controls pass. The unchanged probe passes all controls on this candidate (15.30s wall).

  • Real local inference through the CLI, isolated Gateway, and LM Studio Responses (google/gemma-4-e4b): a transparent loopback proxy corrupts exactly one generated read call to 401 or 403 argument characters. Main exits 1 with false sign-in guidance (18.06s/21.97s). This candidate retries, reads the file once, and returns its verification code, exit 0 (20.71s/28.74s). The fault is injected; the model did not naturally emit these malformed bytes. The model inference, transport parser, recovery, tool execution, and final answer are real.

  • 783 tests passed across the assistant-message and shared-classifier suites plus the existing failover corpus and structured-provider suites (124.23s wall, including 31.26s worker compilation). Separate single-file walls: assistant-message-failures 58.48s (15 tests), classify 33.21s (66 tests). These timings are dominated by existing worker transforms/imports; the new malformed-length cases measured 0ms, and the HTTP controls 10ms/1ms. No new process, Gateway, timer, or broad import was added.

  • Full pnpm build passed (843.81s wall). Core and canonical agents-other test typechecks, formatting, targeted lint, and all eight relevant ratchets passed. Gateway-only setup initially omitted a Solid lint dependency; a frozen full install restored it, then the single lint retry passed (37.89s).

  • Independent Codex autoreview: scoped-clean at P2, no accepted/actionable findings. Review did not execute tests; the execution evidence above is separate.

  • CI exposed an inherited TUI fixture mismatch: the full 93-test file failed identically with both the candidate and original-main auth matchers (81.69s/68.10s), because fix: keep Ollama embedding models out of onboarding chat choices #168075 intentionally normalized string-valued JSON errors. The repaired file passes 93/93 (23.31s); shared formatter tests pass 28/28 (2.33s). Targeted TUI lint, types, formatting, and affected ratchets pass. This follow-up is test-only; runtime/build/live evidence above is from ad4b25bca154634d8a79601fafba1bce65f6ff15, with identical production source in the updated head.

ClawSweeper reviewed final head 7778d57c048ee609a912d5a4fcb5d9ba40af8fa2 at 18:44 UTC with no code findings. Its remaining proof-only hold asks for inspectable runtime captures/profile-health evidence and a genuine-auth runtime control; live proof here uses injected malformed output, while genuine-auth controls run at the classifier boundary.

Exact-head CI passed: 40 successful jobs, 29 intentionally skipped; openclaw/ci-gate, dependency review, and security-sensitive review are green. The first run's cleanup-script lint defect is fixed on main by 493a499b86e3 and passed in the fresh merge ref. Final independent autoreview is scoped-clean at P2 with no actionable findings. Hosted Node test steps ranged from 2 to 535 seconds across shared shards; their per-file CI costs were not isolated.

@clawsweeper

clawsweeper Bot commented Oct 10, 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.

@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: S labels Oct 10, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Oct 10, 2026
@clawsweeper

clawsweeper Bot commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge.

What this changes

This PR requires status context before interpreting numeric 401 or 403 text as an authentication failure.

Example: A rejected malformed tool call carries argumentChars: 401.

  • Before: The diagnostic becomes an auth failure, producing misleading reauthentication guidance and a provider-profile penalty.
  • After: The diagnostic stays unclassified and follows existing bounded malformed-call recovery.

Review scores

Measure Result What it means
Overall readiness 🧂 unranked krab (1/6) The focused patch and regression coverage are sound, but inspectable shipped-behavior proof remains required.
Proof confidence 🧂 unranked krab (1/6) Real behavior proof is necessary before merge. See Before merge.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Valid credentials receive false reauthentication guidance and cooldown handling when malformed argument diagnostics happen to contain 401 or 403.
Reason: The repair addresses a demonstrated official-release failure at its existing shared owner without adding configuration, APIs, or another recovery mechanism.

Merge readiness

⛔ Blocked before merge - 1 item remains

Keep open: this PR fixes a concrete current-main classification bug, has no actionable code findings, and has a green exact-head CI gate.

Priority: P2
Reviewed head: 7778d57c048ee609a912d5a4fcb5d9ba40af8fa2

Before merge

  • Add real behavior proof - The body reports real CLI → isolated Gateway → LM Studio runs with injected malformed read arguments at lengths 401 and 403, followed by successful recovery, but provides no inspectable output or artifacts. Attach existing redacted terminal captures or logs showing those results, no false profile-health penalty, and a genuine-auth runtime control; redact IPs, API keys, phone numbers, and non-public endpoints. Production is unchanged from ad4b25b, so captures from that head remain applicable. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.

Findings

None.

Tests

  • Missing end-to-end proof: Attach the described shipped CLI recovery captures for both malformed lengths, profile-health handling, and a genuine-auth control; the reported baseline probe was not independently inspectable.
Agent review details

How this fits together

Provider transports produce assistant error diagnostics; the shared failover classifier turns them into recovery decisions, profile-health reasons, and user-facing errors.

flowchart TD
  A[Provider transport] --> B[Assistant diagnostics]
  B --> C[Failover signal extraction]
  C --> D[Shared classifier]
  D --> E[Bounded recovery]
  D --> F[Profile health]
  D --> G[User error rendering]
Loading

Technical review

Best possible solution:

Land the focused shared matcher repair while preserving genuine authentication handling and existing recovery budgets.

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

Current-main source exposes argumentChars to bare numeric auth matching, corroborated by the official-release report; this read-only review executed no target code.

Is this the best way to solve the issue?

Repairing numeric matching at the shared classifier addresses the demonstrated collision across consumers without weakening tool parsing or adding a provider-specific bypass.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 7924f12c75f5.

Provenance checked

  • Numeric authentication matching changes intended behavior with a stated reason (unknown: Commit 6739c28 reorganized existing auth patterns; the later canonical consolidation expressly retained their breadth. Their original introduction remains unknown because some earlier local objects are unavailable.)
  • TUI billing-error expectation keeps the original intent (5843c0b: The test-cleanup change consolidated related cases while preserving diagnostic behavior; the updated expectation follows the subsequently merged string-error parser.)

Testing

Proof path: unit tests only.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit 6739c28 adds src/agents/pi-embedded-helpers/failover-matches.ts:6 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 6739c28718ec; files: src/agents/pi-embedded-helpers/failover-matches.ts)
  • Lee Raesly: Raw commit 6ac9827 adds src/agents/failover/message-patterns.ts:46 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: medium; commits: 6ac98274afd3; files: src/agents/failover/message-patterns.ts)

PR surface

Source +4, Tests +52. Total +56 across 4 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 1 6 2 +4
Tests 3 54 2 +52
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 4 60 4 +56

Review metrics

Metric Value Why it matters
Production versus test LOC Production +6/-2; tests +54/-2 Small production growth implements contextual status matching; test growth covers diagnostic collisions, genuine statuses, and the existing formatted billing result.

Root-cause cluster

Relationship: same_root_cause
Canonical: #168450
Summary: This PR repairs the canonical report's exact diagnostic-number collision.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Labels

Label changes:

No label changes.

Label justifications:

  • P2: A limited diagnostic-number collision interrupts established agent workflows and temporarily penalizes valid provider credentials.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🐚 platinum hermit.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Attach the existing redacted runtime captures described in the proof assessment.

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 need explicit maintainer commands such as @clawsweeper autofix or @clawsweeper automerge.

History

Review history (4 earlier review cycles)
  • reviewed 2026-10-10T15:42:36.784Z sha 2d15684 :: needs real behavior proof before merge. :: none
  • reviewed 2026-10-10T17:51:55.286Z sha ad4b25b :: needs real behavior proof before merge. :: none
  • reviewed 2026-10-10T18:08:46.320Z sha ad4b25b :: needs real behavior proof before merge. :: none
  • reviewed 2026-10-10T18:44:05.477Z sha 7778d57 :: needs real behavior proof before merge. :: none

Reviewed October 10, 2026, 3:07 PM ET / 19:07 UTC (Revision 5).

@steipete
steipete marked this pull request as ready for review October 10, 2026 17:45
Preserve the complete billing explanation after the shared error parser began recognizing string-only error bodies in openclaw#168075. The raw-envelope expectation failed with both the original and repaired auth matchers. Keep the local TUI regression against misleading auth refresh guidance.
@steipete steipete self-assigned this Oct 10, 2026
@steipete
steipete merged commit 3050cdc into openclaw:main Oct 10, 2026
144 checks passed
@steipete

Copy link
Copy Markdown
Contributor

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 11, 2026
…s 401 or 403 (openclaw#168500)

* fix: malformed tool calls report auth failures when argument length is 401 or 403

* test(tui): expect normalized billing diagnostics

Preserve the complete billing explanation after the shared error parser began recognizing string-only error bodies in openclaw#168075. The raw-envelope expectation failed with both the original and repaired auth matchers. Keep the local TUI regression against misleading auth refresh guidance.

---------

Co-authored-by: TYY-2005 <[email protected]>
Co-authored-by: Peter Steinberger <[email protected]>
RomneyDa pushed a commit that referenced this pull request Oct 12, 2026
…s 401 or 403 (#168500)

* fix: malformed tool calls report auth failures when argument length is 401 or 403

* test(tui): expect normalized billing diagnostics

Preserve the complete billing explanation after the shared error parser began recognizing string-only error bodies in #168075. The raw-envelope expectation failed with both the original and repaired auth matchers. Keep the local TUI regression against misleading auth refresh guidance.

---------

Co-authored-by: TYY-2005 <[email protected]>
Co-authored-by: Peter Steinberger <[email protected]>
(cherry picked from commit 3050cdc)
RomneyDa added a commit that referenced this pull request Oct 12, 2026
 backport

The #168500 backport (a827a9d) carried a TUI test tweak that expects
main's "HTTP 403: <error>" billing formatter, which release/2026.10.5 does not
have. Restore the branch's original fixture and expectation; the #168500
classification change and its own tests are unaffected.
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: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: S status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Malformed tool-call error is classified as auth when argumentChars is 401 or 403

2 participants