Skip to content

fix(openrouter): Fusion prompt corrupts boundary emoji in model IDs - #104433

Merged
steipete merged 3 commits into
openclaw:mainfrom
zhangguiping-xydt:fix/problem-openrouter-fusion-utf16
Jul 11, 2026
Merged

steipete merged 3 commits into
openclaw:mainfrom
zhangguiping-xydt:fix/problem-openrouter-fusion-utf16

Conversation

@zhangguiping-xydt

Copy link
Copy Markdown
Contributor
Additional instructions

MUST: Keep Allow edits from maintainers enabled for this PR so maintainers
can help update the branch when needed.

What Problem This Solves

Fixes an issue where users configuring a long OpenRouter Fusion analysis or final model ID could get a broken replacement glyph in the generated agent system prompt when an emoji crossed the existing 256-unit display limit.

Why This Change Was Made

The existing control-character filtering and trimming remain unchanged, but the final display cap now uses OpenClaw's canonical UTF-16-safe truncation helper. The same sanitizer owns both analysis_models and final model prompt lines, so the fix covers the complete Fusion prompt boundary without changing the raw plugin configuration sent to OpenRouter.

This is a root-cause fix with no config, schema, routing, auth, request-format, or public API change. A fresh open-PR scan found no PR covering the Fusion configuration-to-system-prompt behavior.

User Impact

OpenRouter Fusion configuration shown to the agent remains valid Unicode at the existing length limit. If the cap lands inside an emoji, OpenClaw drops the incomplete pair instead of placing corrupted text in the system prompt; ordinary model IDs and the provider request payload are unchanged.

Evidence

  • Before the fix, the registered OpenRouter provider regression failed because both bounded Fusion model lines ended with a lone U+D83D replacement glyph:

    Test Files  1 failed (1)
         Tests  1 failed | 41 passed (42)
    Received: Analysis models: aaaa...�.
              Final Fusion model: aaaa...�.
    
  • After the fix, a real isolated OpenClaw Gateway ran an agent turn with openrouter/fusion against a deterministic local OpenAI-compatible endpoint. The endpoint captured the production /v1/chat/completions request:

    gatewayReady: true
    realGatewayAgentTurn: true
    fakeOpenRouterRequestReceived: true
    requestModel: openrouter/fusion
    systemPromptLoneSurrogates: []
    analysisModelSafePrefixPresent: true
    finalModelSafePrefixPresent: true
    fullBoundaryEmojiAbsentFromPrompt: true
    requestPluginsPreserved: true
    cliReturnedProofText: true
    

    This proves the real Gateway → agent runtime → bundled provider prompt hook → provider HTTP request path. Only the paid external service was replaced; the raw Fusion plugins payload still contained the complete configured ID.

  • Full affected provider test file:

    Test Files  1 passed (1)
         Tests  42 passed (42)
    
  • Targeted formatting passed for both changed files.

  • Changed-surface checks passed, including extension and extension-test type checks, lint, dependency guards, database-first guard, runtime sidecar checks, and zero runtime import cycles.

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. P2 Normal backlog priority with limited blast radius. labels Jul 11, 2026
@clawsweeper

clawsweeper Bot commented Jul 11, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed July 11, 2026, 2:15 PM ET / 18:15 UTC.

Summary
The PR replaces raw UTF-16 slicing in OpenRouter Fusion system-prompt model-ID display sanitization with the canonical safe truncation helper and adds boundary regression coverage for both analysis and final model lines.

PR surface: Source +3, Tests +34. Total +37 across 2 files.

Reproducibility: yes. from source with high confidence: 255 ASCII code units followed by an emoji are cut at 256 units on current main, leaving the emoji’s high surrogate unpaired.

Review metrics: none identified.

Merge readiness
Overall: 🦞 diamond lobster
Proof: 🦞 diamond lobster
Patch quality: 🦞 diamond lobster
Result: ready for maintainer review.

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

Next step before merge

  • No automated repair or product decision is needed; the clean exact-head PR should proceed through ordinary OpenRouter owner review and merge gates.

Security
Cleared: The diff introduces no concrete security or supply-chain concern; it only imports an existing public plugin helper and adds focused provider regression coverage.

Review details

Best possible solution:

Merge the narrow helper reuse after ordinary OpenRouter owner review, preserving the existing 256-code-unit display limit and the unchanged raw Fusion request payload.

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

Yes, from source with high confidence: 255 ASCII code units followed by an emoji are cut at 256 units on current main, leaving the emoji’s high surrogate unpaired.

Is this the best way to solve the issue?

Yes. Reusing the repository’s tested UTF-16-safe helper at the existing display-only OpenRouter sanitizer is the narrowest maintainable fix; changing global prompt assembly or transport normalization would be broader and at the wrong owner boundary.

AGENTS.md: found and applied where relevant.

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

Label changes

Label justifications:

  • P2: This fixes a deterministic but bounded OpenRouter system-prompt display corruption without broader compatibility, availability, or setup impact.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The PR provides after-fix live Gateway-to-provider request output showing well-formed system-prompt Unicode, complete raw Fusion plugin configuration, and the expected agent response; the exact-head proof check passes.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR provides after-fix live Gateway-to-provider request output showing well-formed system-prompt Unicode, complete raw Fusion plugin configuration, and the expected agent response; the exact-head proof check passes.
Evidence reviewed

PR surface:

Source +3, Tests +34. Total +37 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 1 16 13 +3
Tests 1 34 0 +34
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 50 13 +37

What I checked:

Likely related people:

  • steipete: Current-main blame and the latest grafted OpenRouter entrypoint history attribute the Fusion prompt sanitizer and contribution path to commit ae12413. (role: recent area contributor; confidence: medium; commits: ae12413ee29c; files: extensions/openrouter/index.ts, extensions/openrouter/index.test.ts, docs/providers/openrouter.md)
  • vincentkoc: The latest release-boundary OpenRouter history and release commit are associated with Vincent Koc, and he also refreshed this PR branch from main. (role: recent OpenRouter area contributor; confidence: medium; commits: e085fa1a3ffd, 6d93e040d947, 0d562d022e5c; files: extensions/openrouter/index.ts, extensions/openrouter/index.test.ts)
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-11T11:26:39.674Z sha bcbc813 :: needs maintainer review before merge. :: none
  • reviewed 2026-07-11T11:34:15.466Z sha bcbc813 :: needs maintainer review before merge. :: none
  • reviewed 2026-07-11T14:02:51.634Z sha 6d93e04 :: needs maintainer review before merge. :: none

@steipete steipete self-assigned this Jul 11, 2026
@steipete
steipete merged commit 03558dc into openclaw:main Jul 11, 2026
91 checks passed
@steipete

Copy link
Copy Markdown
Contributor

Merged via squash.

steipete pushed a commit that referenced this pull request Jul 11, 2026
…104433)

Co-authored-by: Vincent Koc <[email protected]>
(cherry picked from commit 03558dc)
(cherry picked from commit 6092dd41693e03168d21c4279775e07cec805099)
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jul 12, 2026
zooqueen pushed a commit to zooqueen/openclaw that referenced this pull request Sep 11, 2026
…penclaw#104433)

Co-authored-by: Vincent Koc <[email protected]>
(cherry picked from commit 03558dc)
(cherry picked from commit 6092dd41693e03168d21c4279775e07cec805099)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

extensions: openrouter P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor 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.

3 participants