Skip to content

fix: recover GitHub Copilot sessions with invalid tool call ids - #108029

Closed
goutamadwant wants to merge 1 commit into
openclaw:mainfrom
goutamadwant:fix-tool-call-id-retry-sanitization
Closed

goutamadwant wants to merge 1 commit into
openclaw:mainfrom
goutamadwant:fix-tool-call-id-retry-sanitization

Conversation

@goutamadwant

@goutamadwant goutamadwant commented Jul 15, 2026 •

Copy link
Copy Markdown
Contributor

Closes #108002

What Problem This Solves

Fixes an issue where users running Claude through GitHub Copilot could receive the same invalid tool-call ID rejection repeatedly even after OpenClaw announced that tool calls would be sanitized on retry.

Why This Change Was Made

The first explicit tool-call ID format rejection now triggers one bounded retry with strict replay ID sanitization enabled. The retry recognizes dotted, underscored, spaced, and hyphenated provider error forms, overrides weaker planned ID modes, and applies only to the API that rejected the transcript. Repeated errors, unrelated format failures, and later fallback APIs continue through the existing recovery paths without inheriting the forced policy.

User Impact

Malformed historical tool-call IDs can be repaired on the immediate retry instead of wasting multiple provider attempts before falling back to another model. OpenAI Responses transports and unrelated request-format failures retain their existing behavior.

Evidence

  • Before: the issue log shows a GitHub Copilot Claude request rejected with messages.17.content.0.tool_use.id: String should match pattern, followed by the same failure after the sanitize-on-retry message.
  • After: focused coverage verifies one strict retry for documented separator variants, no retry loop after a repeated rejection, no match for generic format errors, no forced retry for Responses APIs, and no forced sanitization leaking from an Anthropic-format attempt into an OpenAI Responses fallback.
  • node scripts/run-vitest.mjs src/agents/embedded-agent-runner/run/attempt.transcript-policy.test.ts passed: 1 file, 6 tests.
  • pnpm tsgo:core:test passed for the core test type graph.
  • Production type validation and the full build passed earlier on the same production change surface; the rebased branch retains those paths unchanged.
  • Targeted oxfmt, oxlint, and git diff --check validation passed for the touched files.
  • The bundled autoreview helper completed with no actionable findings after the retry and fallback boundaries were applied.
  • Live GitHub Copilot provider validation was not run because no disposable provider transcript containing a rejected malformed ID was available. The remaining proof limitation is an after-fix provider transcript from a real Copilot setup.

Disclosure: AI was used to understand the codebase and review the fix.

@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: S labels Jul 15, 2026
@clawsweeper clawsweeper Bot added 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. P2 Normal backlog priority with limited blast radius. labels Jul 16, 2026
@clawsweeper

clawsweeper Bot commented Jul 16, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed July 17, 2026, 6:20 PM ET / 22:20 UTC.

Summary
The branch adds a one-time, API-scoped retry that forces strict tool-call-ID sanitization after matching GitHub Copilot transcript-format errors, with focused policy tests.

PR surface: Source +66, Tests +104. Total +170 across 7 files.

Reproducibility: no. high-confidence repeatable live path is available yet: the linked report contains a concrete GitHub Copilot 400 and the branch encodes that path in focused tests, but the contributor has no disposable provider transcript to run after the fix.

Review metrics: none identified.

Root-cause cluster
Relationship: fixed_by_candidate
Canonical: #108002
Summary: This PR is the active candidate implementation for the concrete GitHub Copilot sanitize-on-retry failure reported in the canonical issue.

Members:

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

Merge readiness
Overall: 🦪 silver shellfish
Proof: 🦪 silver shellfish
Patch quality: 🐚 platinum hermit
Result: blocked until real behavior proof is added.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Rank-up moves:

  • [P1] Add a redacted GitHub Copilot after-fix transcript or runtime log proving the immediate sanitized retry succeeds.
  • Update the PR body after adding proof; if no automatic review appears, ask a maintainer to comment @clawsweeper re-review.

Proof guidance:

  • [P1] Needs real behavior proof before merge: Focused tests and claimed static validation are useful supplemental evidence, but the PR explicitly lacks a redacted after-fix GitHub Copilot runtime transcript; provide terminal output or redacted runtime logs showing the successful sanitized retry, then update the PR body for re-review.

Risk before merge

  • [P1] Merging without a redacted real GitHub Copilot after-fix transcript leaves the provider-specific retry contract unobserved; an overly broad match or unexpected provider error shape could alter retry behavior for an auth/provider workflow despite the focused unit coverage.

Maintainer options:

  1. Add provider runtime proof (recommended)
    Provide a redacted after-fix GitHub Copilot transcript or runtime log showing the rejected malformed ID is repaired by the immediate retry before merge.
  2. Accept test-only provider evidence
    A maintainer may explicitly accept the remaining provider-runtime uncertainty if the targeted policy coverage is considered sufficient for this narrow retry path.

Next step before merge

  • [P1] The remaining merge blocker is contributor-owned real provider evidence, which an automated repair lane cannot manufacture from the contributor’s GitHub Copilot setup.

Security
Cleared: The proposed TypeScript-only retry-policy change adds no dependency, workflow, permission, secret-handling, download, or supply-chain surface; the remaining concern is provider behavior proof rather than a concrete security defect.

Review details

Best possible solution:

Retain the bounded same-API retry design and merge only after a redacted GitHub Copilot run shows the malformed historical ID rejection followed by a successful sanitized retry without affecting an OpenAI Responses fallback.

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

No high-confidence repeatable live path is available yet: the linked report contains a concrete GitHub Copilot 400 and the branch encodes that path in focused tests, but the contributor has no disposable provider transcript to run after the fix.

Is this the best way to solve the issue?

Yes, provisionally: one forced strict-sanitization retry scoped to the rejecting API is narrower than changing baseline transcript policy or allowing the override to leak into model fallbacks.

AGENTS.md: found and applied where relevant.

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

Label changes

Label justifications:

  • P2: This is a bounded provider retry repair that avoids a recoverable fallback delay but has no evidence of a widespread outage or data loss.
  • merge-risk: 🚨 auth-provider: The patch changes retry behavior after GitHub Copilot provider-format rejections, so real-provider proof is needed to confirm the intended API-scoped behavior.
  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🐚 platinum hermit.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: Focused tests and claimed static validation are useful supplemental evidence, but the PR explicitly lacks a redacted after-fix GitHub Copilot runtime transcript; provide terminal output or redacted runtime logs showing the successful sanitized retry, then update the PR body for re-review.
Evidence reviewed

PR surface:

Source +66, Tests +104. Total +170 across 7 files.

View PR surface stats
Area Files Added Removed Net
Source 6 69 3 +66
Tests 1 105 1 +104
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 7 174 4 +170

What I checked:

Likely related people:

What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

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.

How this review workflow works
  • 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.
Review history (3 earlier review cycles)
  • reviewed 2026-07-16T07:31:30.113Z sha d35df4d6cb596fb70ba439e626e47c0fae88a5c2 :: needs real behavior proof before merge. :: none
  • reviewed 2026-07-17T20:06:59.242Z sha 66b9b92bb808b5e571835189b873eefc372da022 :: needs real behavior proof before merge. :: none
  • reviewed 2026-07-17T20:37:32.542Z sha 379a4e3bf5ef7f5e9abb0a7882c44e0d1b9a8144 :: needs real behavior proof before merge. :: none

@goutamadwant
goutamadwant force-pushed the fix-tool-call-id-retry-sanitization branch from d35df4d to 3238450 Compare July 17, 2026 07:44
@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. merge-risk: 🚨 auth-provider 🚨 May break OAuth, tokens, provider routing, model choice, or credentials. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. labels Jul 17, 2026
@goutamadwant
goutamadwant force-pushed the fix-tool-call-id-retry-sanitization branch from 3238450 to 97c1b40 Compare July 17, 2026 14:55
@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Jul 17, 2026
@goutamadwant
goutamadwant force-pushed the fix-tool-call-id-retry-sanitization branch 2 times, most recently from 66b9b92 to 379a4e3 Compare July 17, 2026 20:33
@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. labels Jul 17, 2026
@goutamadwant
goutamadwant force-pushed the fix-tool-call-id-retry-sanitization branch 2 times, most recently from 32c6dc9 to 13b9fca Compare July 17, 2026 22:15
@steipete

Copy link
Copy Markdown
Contributor

Closing per ClawSweeper review verdict duplicate_or_superseded (decision packet 2026-07-17T23:02:16.032Z). This item was part of the audited close backlog (openclaw/clawsweeper#920) stranded by an apply-lane defect, drained manually after re-verification. If this is wrong, reopen and ClawSweeper will re-review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling merge-risk: 🚨 auth-provider 🚨 May break OAuth, tokens, provider routing, model choice, or credentials. P2 Normal backlog priority with limited blast radius. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. 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.

tool_use.id sanitize-on-retry not working for invalid characters

2 participants