Skip to content

fix(providers): canonicalize model families and stream outcomes - #116998

Merged
steipete merged 2 commits into
mainfrom
codex/wave3-bedrock-openrouter-chat
Jul 31, 2026
Merged

steipete merged 2 commits into
mainfrom
codex/wave3-bedrock-openrouter-chat

Conversation

@steipete

@steipete steipete commented Jul 31, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Finalize successful Bedrock Converse text, reasoning, redacted-reasoning, and tool blocks even when their stream omits contentBlockStop.
  • Normalize OpenRouter model families in their provider owner so qualified references, ~ routes, z-ai models, and dated DeepSeek V4 variants reach the correct cache, reasoning, replay, and assistant-prefill decisions.
  • Honor reasoning.enabled: false without deleting a valid trailing assistant prefill.
  • Fix four independently reproduced provider-owner invariants while reducing production code by two lines.

Current reviewed head and merge status

PR:        https://github.com/openclaw/openclaw/pull/116998
HEAD:      60df12e4bc8b3b8153ad9153fc8b068d02cfd342
TREE:      91d1171faeeb78dd08b6bf996c0ad5e03c904b7b
BASE:      eb0087dc7c96e6a6832b7a894b0a43c6ba26d753
Mergeable: MERGEABLE

openclaw/ci-gate: SUCCESS
check-lint:       SUCCESS
check-test-types: SUCCESS

The earlier review referenced superseded head a0c6fe8b; the current 60df12e4 follow-up repairs both previously failing CI gates with the canonical typed OpenRouter stream-test fixture.

What was actually exercised

Evidence Source Realism / limitation
Bedrock terminal stream behavior Actual Bedrock provider stream owner plus a mocked AWS SDK BedrockRuntimeClient.send event stream Local deterministic provider-owner execution; not a live AWS inference request.
OpenRouter qualified/dated request handling Actual OpenRouter plugin registration, cache hook, stream wrapper, and captured owner-mutated payload Local deterministic provider-owner execution; not a live OpenRouter inference request or response.
OpenRouter model availability Live unauthenticated GET https://openrouter.ai/api/v1/models Real public catalog response only; it does not prove paid/authenticated model inference.
SDK compatibility Installed @aws-sdk/[email protected], [email protected], and @openrouter/[email protected] types/source Direct dependency contract inspection; no credentialed provider call.

No credentials, private endpoints, account identifiers, or real customer content are included below. Synthetic tool identifiers and model-independent fixture content are redacted where appropriate.

Bedrock: redacted actual local provider-owner stream trace

extensions/amazon-bedrock/stream.runtime.lifecycle.test.ts invokes the actual streamSimpleBedrock owner. The AWS SDK client is mocked to return an HTTP-200 async event stream that deliberately omits contentBlockStop:

{
  "evidence": "local provider-owner execution; mocked AWS SDK response",
  "model": "<bedrock-model-redacted>",
  "endpoint": "<bedrock-endpoint-redacted>",
  "sdkHttpStatus": 200,
  "providerEvents": [
    { "messageStart": { "role": "assistant" } },
    {
      "contentBlockDelta": {
        "contentBlockIndex": 0,
        "delta": { "text": "ready" }
      }
    },
    { "messageStop": { "stopReason": "end_turn" } }
  ],
  "contentBlockStopEmittedByProvider": false,
  "observedTerminalOwnerEvents": ["text_end", "done"],
  "persistedContent": { "type": "text", "text": "ready" },
  "persistedScratchFields": []
}

The same actual provider-owner loop is exercised for all four fixture variants:

text delta                       -> text_end     -> done; no persisted index
reasoning text delta             -> thinking_end -> done; no persisted index
redacted reasoning bytes         -> thinking_end -> done; redacted=true; signature preserved
tool start + streamed JSON delta -> toolcall_end -> done; no persisted index or partialJson

These are real outputs of the shipped provider owner driven by a synthetic SDK event stream; they are not presented as live Bedrock traffic. The directly inspected installed SDK declares ContentBlockDeltaEvent, ContentBlockStopEvent, MessageStopEvent, and redacted-reasoning bytes in its public event contract.

OpenRouter: redacted actual local owner request/response traces

extensions/openrouter/chat-owner-regression.test.ts registers the actual OpenRouter plugin and invokes its real cache/thinking/stream-wrapper hooks. The following traces show deterministic in-process hook inputs and captured transformed payloads, not network requests or provider inference responses.

Qualified references and live-catalog families

{
  "evidence": "local plugin cache-hook execution; no provider network call",
  "isCacheTtlEligible": {
    "openrouter/anthropic/claude-sonnet-5": true,
    "openrouter/deepseek/deepseek-v4-pro": true,
    "openrouter/moonshotai/kimi-k3": true,
    "z-ai/glm-5.2": true,
    "openrouter/z-ai/glm-5.2": true,
    "~anthropic/claude-opus-latest": true,
    "~moonshotai/kimi-latest": true,
    "openai/gpt-5.4": false,
    "~openai/gpt-5.4": false,
    "openrouter/openai/gpt-5.4": false
  }
}

Dated DeepSeek V4 model: captured request transformation

{
  "evidence": "local OpenRouter stream-wrapper payload capture; no HTTP request",
  "configuredModelReference": "deepseek/deepseek-v4-flash-0731",
  "thinkingProfile": { "defaultLevel": "high" },
  "inputPayload": {
    "messages": [{ "role": "assistant", "content": "done" }]
  },
  "capturedOutputPayload": {
    "reasoning": { "effort": "high" },
    "messages": [
      { "role": "assistant", "content": "done", "reasoning_content": "" }
    ]
  }
}

Qualified/latest Anthropic model: captured request transformation

{
  "evidence": "local OpenRouter stream-wrapper payload capture; no HTTP request",
  "configuredModelReferences": [
    "~anthropic/claude-opus-latest",
    "openrouter/~anthropic/claude-opus-latest"
  ],
  "inputPayload": {
    "reasoning": { "effort": "high" },
    "messages": [
      { "role": "user", "content": "Continue." },
      { "role": "assistant", "content": "{" }
    ]
  },
  "capturedOutputPayload": {
    "reasoning": { "effort": "high" },
    "messages": [{ "role": "user", "content": "Continue." }]
  }
}

Explicitly disabled reasoning preserves assistant prefill

{
  "evidence": "local OpenRouter stream-wrapper payload capture; no HTTP request",
  "configuredModelReference": "anthropic/claude-opus-5",
  "inputPayload": {
    "reasoning": { "enabled": false },
    "messages": [
      { "role": "user", "content": "Return JSON." },
      { "role": "assistant", "content": "{" }
    ]
  },
  "capturedOutputPayload": {
    "reasoning": { "enabled": false },
    "messages": [
      { "role": "user", "content": "Return JSON." },
      { "role": "assistant", "content": "{" }
    ]
  }
}

Actual live public OpenRouter catalog response

An unauthenticated live call to GET https://openrouter.ai/api/v1/models returned all four affected public model identifiers:

{
  "evidence": "live public OpenRouter model-catalog response; no authenticated inference",
  "deepseek/deepseek-v4-flash-0731": true,
  "z-ai/glm-5.2": true,
  "~anthropic/claude-opus-latest": true,
  "~moonshotai/kimi-latest": true
}

This proves that the regression fixtures correspond to currently advertised model references; it does not claim that a live generation request was made.

Frozen-baseline red reproduction

Baseline commit: 36b80ada3ceae2de21b3d8710b883d778e4c4578.

node scripts/run-vitest.mjs \
  extensions/amazon-bedrock/stream.runtime.lifecycle.test.ts \
  extensions/openrouter/chat-owner-regression.test.ts

Test Files  2 failed (2)
Tests       16 failed | 3 passed (19)

The failing cases cover missing Bedrock terminal events, leaked streaming scratch state, qualified/cacheable model families, ~ aliases, explicitly disabled reasoning, and dated DeepSeek thinking/replay.

Exact-current-head independent verification

The final candidate was fetched into a separate detached remote checkout with its immutable Git identity and clean tree asserted before running validation:

HEAD=60df12e4bc8b3b8153ad9153fc8b068d02cfd342
TREE=91d1171faeeb78dd08b6bf996c0ad5e03c904b7b
git status --porcelain: clean

node scripts/run-tsgo.mjs \
  -p test/tsconfig/tsconfig.extensions.test.json \
  --incremental \
  --tsBuildInfoFile /tmp/openclaw-bedrock-openrouter-ci-test.tsbuildinfo
=> PASS: full extension test types

node scripts/run-oxlint.mjs \
  --tsconfig config/tsconfig/oxlint.extensions.json \
  extensions
=> PASS: full extension lint

node scripts/run-vitest.mjs \
  extensions/amazon-bedrock/stream.runtime.test.ts \
  extensions/amazon-bedrock/stream.runtime.lifecycle.test.ts \
  extensions/openrouter/index.test.ts \
  extensions/openrouter/chat-owner-regression.test.ts
=> Test Files  4 passed (4)
=> Tests       111 passed (111)

Independent full-branch review

Reviewed head: 60df12e4bc8b3b8153ad9153fc8b068d02cfd342
Review base:   36b80ada3ceae2de21b3d8710b883d778e4c4578
Engine:        codex / gpt-5.6-sol / high
Scope:         full branch, --max-priority P3
TruffleHog:    clean
P0/P1/P2/P3:   0 actionable findings
Verdict:       patch is correct
Confidence:    0.90

Response to ClawSweeper rank-up moves

  1. Bedrock stream behavior: Added redacted terminal-event input/output traces from actual Bedrock provider-owner execution. The SDK event stream is mocked; no live AWS inference is claimed.
  2. OpenRouter qualified/dated behavior: Added exact qualified-reference cache decisions, dated-model payload capture, alias prefill capture, disabled-reasoning capture, and a real unauthenticated public model-catalog response. No authenticated OpenRouter inference is claimed.
  3. Current head / validation: Updated every verification and review reference to current head 60df12e4, recorded the current MERGEABLE state, linked the successful current-head CI gates, and reproduced the previously failing full test-type/lint lanes plus all 111 owner tests on an independently clean exact-head checkout.

Remaining evidence limitation: No credentialed live Bedrock or OpenRouter generation was executed. If real paid/authenticated provider inference is a strict merge requirement, this PR documents that limitation explicitly instead of presenting fixture output as live-provider traffic.

@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. labels Jul 31, 2026
@clawsweeper

clawsweeper Bot commented Jul 31, 2026 •

Copy link
Copy Markdown
Contributor

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

ClawSweeper review

What this changes

This PR finalizes incomplete Amazon Bedrock stream blocks and centralizes OpenRouter model-family normalization so configured aliases and dated model names receive the intended cache, reasoning, replay, and assistant-prefill behavior.

Merge readiness

⛔ Blocked until real behavior proof from a real setup is added - 5 items remain

Keep this PR open: current main does not contain its provider-owner fixes, and the patch reads as a coherent repair with focused regression coverage. It still needs redacted after-fix behavior from an actual Bedrock and/or authenticated OpenRouter runtime before merge; the supplied traces are mocked SDK/provider-hook executions.

Likely related people: steipete is the high-confidence routing candidate from the existing provider code and both PR commits.

Priority: P2
Reviewed head: 60df12e4bc8b3b8153ad9153fc8b068d02cfd342
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🦪 silver shellfish (2/6) The owner-boundary repair and targeted tests look solid, but provider fixtures and catalog lookup do not replace after-fix real-provider proof.
Proof confidence 🦪 silver shellfish (2/6) Needs real behavior proof before merge: The PR provides useful mocked AWS stream and in-process OpenRouter hook traces, but no redacted after-fix live provider inference result; add real runtime output with private details removed before merge. 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.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Needs proof Needs real behavior proof before merge: The PR provides useful mocked AWS stream and in-process OpenRouter hook traces, but no redacted after-fix live provider inference result; add real runtime output with private details removed before merge. 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.
Evidence reviewed 7 items Bedrock repair owns terminal stream state: The PR finalizes every still-indexed content block only after a successful messageStop, so text, thinking, and tool-call scratch state cannot remain persisted when a valid stream omits a block-stop event.
Bedrock finalizer preserves the existing event owner: The existing block-stop helper emits the matching terminal event and removes only streaming scratch fields; the new loop reuses that canonical owner instead of duplicating output handling.
OpenRouter change consolidates family matching: The PR adds one normalized family identifier and reuses it for Mistral, Anthropic, cache-TTL, and dated DeepSeek V4 decisions, avoiding separate qualifier and alias parsing in each behavior path.
Findings None None.
Security None None.

How this fits together

Provider plugins turn configured model references and provider stream events into OpenClaw’s shared assistant-message flow. The Amazon Bedrock plugin owns Converse-stream block lifecycle, while the OpenRouter plugin owns provider-specific model-family and request-payload decisions.

flowchart LR
  Config[Configured model reference] --> OpenRouter[OpenRouter provider plugin]
  ProviderStream[Bedrock Converse stream] --> Bedrock[Bedrock stream owner]
  OpenRouter --> Payload[Normalized request payload]
  Bedrock --> Events[Finalized assistant events]
  Payload --> AgentLoop[Shared agent loop]
  Events --> AgentLoop
  AgentLoop --> Response[Assistant response]
Loading

Decision needed

Question Recommendation
Should this PR require redacted live provider evidence before merge, or is its mocked provider-owner evidence sufficient for these compatibility-sensitive fixes? Require live provider proof: Request redacted after-fix Bedrock and authenticated OpenRouter traces that directly show the repaired behavior before merge.

Why: The repository policy requires live verification for external API behavior, but obtaining Bedrock/OpenRouter inference proof may require maintainer-controlled credentials and cost approval.

Before merge

  • Add real behavior proof - Needs real behavior proof before merge: The PR provides useful mocked AWS stream and in-process OpenRouter hook traces, but no redacted after-fix live provider inference result; add real runtime output with private details removed before merge. 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.
  • Resolve merge risk (P1) - Merging changes provider behavior for existing OpenRouter model references, including cache-TTL eligibility, reasoning payload patches, replay handling, and assistant-prefill stripping.
  • Resolve merge risk (P1) - The supplied after-fix evidence is deterministic mocked SDK/provider-hook output plus a public model-catalog lookup; it does not demonstrate an authenticated Bedrock or OpenRouter request completing through the changed runtime paths.
  • Resolve merge risk (P1) - Local GitHub and archive reads failed, and the local dependency store lacked inspectable AWS SDK declarations, so live PR state and the claimed SDK contract could not be independently refreshed.
Agent review details

Security

None.

PR surface

Source -2, Tests +227. Total +225 across 6 files.

View PR surface stats
Area Files Added Removed Net
Source 4 33 35 -2
Tests 2 227 0 +227
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 6 260 35 +225

Review metrics

None.

Stored data model

Persistent data-model change detected: persistent cache schema: extensions/openrouter/chat-owner-regression.test.ts. Confirm migration or upgrade compatibility proof before merge.

Merge-risk options

Maintainer options:

  1. Add redacted live provider proof (recommended)
    Before merging, capture an after-fix Bedrock response without a block-stop event and an authenticated OpenRouter request using an affected qualified or dated model reference.
  2. Accept the fixture-only evidence
    A maintainer may merge with the documented limitation that the changed provider paths were not exercised against live inference services.

Technical review

Best possible solution:

Retain the plugin-owned normalization and Bedrock finalizer, then add redacted after-fix evidence from a real Bedrock stream and an authenticated OpenRouter request that exercise the affected terminal and payload paths before merging.

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

Yes, from source: current main leaves active Bedrock blocks without terminal events when contentBlockStop is absent, and its OpenRouter matching does not normalize the qualified and alias forms covered by the branch. I did not execute the reproduction because this is a read-only review and the local dependency installation is unavailable.

Is this the best way to solve the issue?

Yes. The patch repairs behavior at each provider owner, reuses Bedrock’s canonical block-finalization helper, and replaces scattered OpenRouter family parsing with one shared normalizer rather than adding a core fallback.

AGENTS.md: found and applied where relevant.

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

Labels

Label justifications:

  • P2: This is a bounded provider-runtime correctness repair with meaningful but non-emergency impact on affected model routes.
  • merge-risk: 🚨 compatibility: The branch changes matching and payload behavior for existing configured OpenRouter model identifiers and Bedrock stream completion 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: The PR provides useful mocked AWS stream and in-process OpenRouter hook traces, but no redacted after-fix live provider inference result; add real runtime output with private details removed before merge. 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.

Evidence

What I checked:

  • Bedrock repair owns terminal stream state: The PR finalizes every still-indexed content block only after a successful messageStop, so text, thinking, and tool-call scratch state cannot remain persisted when a valid stream omits a block-stop event. (extensions/amazon-bedrock/stream.runtime.ts:359, 60df12e4bc8b)
  • Bedrock finalizer preserves the existing event owner: The existing block-stop helper emits the matching terminal event and removes only streaming scratch fields; the new loop reuses that canonical owner instead of duplicating output handling. (extensions/amazon-bedrock/stream.runtime.ts:646, 60df12e4bc8b)
  • OpenRouter change consolidates family matching: The PR adds one normalized family identifier and reuses it for Mistral, Anthropic, cache-TTL, and dated DeepSeek V4 decisions, avoiding separate qualifier and alias parsing in each behavior path. (extensions/openrouter/models.ts:24, 60df12e4bc8b)
  • Current main still lacks the proposed behavior: The PR head is not an ancestor of the checked-out current main, and the current files contain none of the new normalized-family helper, cache-family regex, or missing-block-stop finalizer. (extensions/openrouter/models.ts:24, 4976eb38ab4e)
  • Focused tests cover the stated owner invariants: The branch adds lifecycle fixtures for incomplete Bedrock blocks and provider-plugin fixtures for qualified OpenRouter references, dated DeepSeek V4 names, and explicitly disabled reasoning. (extensions/openrouter/chat-owner-regression.test.ts:1, 60df12e4bc8b)
  • Feature history points to the same provider owner: The preceding OpenRouter model and stream decisions blame to Peter Steinberger’s provider work; this PR’s two commits are also authored and committed by Peter Steinberger on July 31, 2026. (extensions/openrouter/models.ts:52, 500fed6d4a)

Likely related people:

  • steipete: The base implementation’s OpenRouter decision paths blame to Peter Steinberger, and both commits in this branch were authored and committed by him. (role: recent provider-area contributor and PR author; confidence: high; commits: 500fed6d4a, a0c6fe8b543c, 60df12e4bc8b; files: extensions/amazon-bedrock/stream.runtime.ts, extensions/openrouter/models.ts, extensions/openrouter/stream.ts)

Rank-up moves

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

  • Add redacted live Bedrock stream output that omits contentBlockStop and still reaches the expected terminal event.
  • Add redacted authenticated OpenRouter request/response evidence for an affected qualified, alias, or dated model reference.

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.

History

Review history (4 earlier review cycles)
  • reviewed 2026-07-31T19:13:44.461Z sha a0c6fe8 :: needs real behavior proof before merge. :: none
  • reviewed 2026-07-31T19:28:21.990Z sha a0c6fe8 :: needs real behavior proof before merge. :: none
  • reviewed 2026-07-31T19:43:31.691Z sha a0c6fe8 :: needs real behavior proof before merge. :: none
  • reviewed 2026-07-31T22:03:14.564Z sha 60df12e :: needs real behavior proof before merge. :: none

@steipete
steipete marked this pull request as ready for review July 31, 2026 21:41
@steipete
steipete merged commit d92d68a into main Jul 31, 2026
91 checks passed
@steipete
steipete deleted the codex/wave3-bedrock-openrouter-chat branch July 31, 2026 22:29
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 1, 2026
…claw#116998)

* fix(providers): canonicalize live model families and stream finalization

* test(openrouter): use canonical typed stream fixture

---------

Co-authored-by: Peter Steinberger <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

extensions: amazon-bedrock extensions: openrouter maintainer Maintainer-authored PR merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P2 Normal backlog priority with limited blast radius. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. size: M 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.

1 participant