Skip to content

refactor(providers): consolidate compatible replay policies - #114669

Merged
steipete merged 1 commit into
mainfrom
codex/reduce-provider-policies-f0a963a2cb5
Jul 27, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/reduce-provider-policies-f0a963a2cb5

Conversation

@steipete

@steipete steipete commented Jul 27, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Users switching between OpenAI-compatible providers depend on replayed assistant reasoning being preserved, removed, or backfilled according to the selected model's actual transport. Maintaining those rules independently across Qwen, Baseten, Venice, OpenRouter, Kimi, and DeepSeek-compatible providers makes cross-provider tool-call replay vulnerable to subtle drift. Ollama's local and hosted providers also repeated their native transport and replay policies, and xAI maintained a separate copy of the standard payload-wrapper contract.

Why This Change Was Made

This maintainer-requested, AI-assisted refactor consolidates assistant reasoning replay in the existing provider-stream SDK, moves both Ollama providers onto one plugin-owned native transport/replay hook object, and uses the existing generic payload wrapper for xAI. Provider authentication, catalogs, model selection, request wire formats, callback ordering, cancellation, and public SDK paths remain unchanged.

User Impact

Cross-provider tool-call conversations preserve native reasoning consistently across Qwen, DeepSeek, Baseten, Venice, OpenRouter, Kimi, Xiaomi, and OpenCode Go. Ollama's local and cloud transport behavior remains unchanged. Removes 123 net production lines (+121/-244) without moving production logic into tests or adding a public SDK path.

Evidence

  • 27 targeted provider, native-stream, replay, reasoning, tool-schema, SDK, and runtime test files: 756 tests passed in six Vitest shards on a Blacksmith Testbox.
  • Five direct shared-replay regression tests cover existing reasoning, null preservation, provider-specific null replacement, tool-call-only replay selection, all-message cleanup, and assistant-only cleanup.
  • Public SDK surface check passed across 316 entry points and 7,457 exports.
  • SDK/plugin import-boundary check returned [].
  • All changed files pass repository formatting; git diff --check passes.
  • Fresh independent autoreview: --engine codex --model gpt-5.6-sol --thinking xhigh; no accepted or actionable findings.
  • Full type-aware lint, all four tsgo lanes, full formatting, changed-file checks, dead-code checks, and packaged build are validated on the same Testbox before marking ready.

@steipete
steipete marked this pull request as ready for review July 27, 2026 17:58
@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. P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. labels Jul 27, 2026
@clawsweeper

clawsweeper Bot commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed July 27, 2026, 2:03 PM ET / 18:03 UTC.

ClawSweeper review

What this changes

This PR replaces several provider-local OpenAI-compatible reasoning replay normalizers with one plugin-SDK helper, shares Ollama’s native transport/replay hooks, and routes xAI through the existing generic payload wrapper.

Merge readiness

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

Keep this PR open for normal maintainer review. The refactor has a focused shared-policy shape and no concrete patch defect surfaced from the supplied diff, but it carries provider-compatibility risk and the PR body provides test/CI claims rather than after-fix real behavior proof. Likely related people: steipete (medium confidence, provider replay refactor contributor).

Priority: P3
Reviewed head: 8e88079876d3d034bf3d9b034d19152618ccff79

Review scores

Measure Result What it means
Overall readiness 🦪 silver shellfish (2/6) The implementation and focused regression coverage appear solid, but merge confidence is capped until the changed provider replay behavior is demonstrated outside mocks and CI claims.
Proof confidence 🦪 silver shellfish (2/6) Needs real behavior proof before merge: The PR body reports targeted tests, SDK checks, and CI/Testbox validation, but it does not include a redacted after-fix provider session, runtime log, terminal output, recording, or linked artifact that shows real replay behavior. 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 body reports targeted tests, SDK checks, and CI/Testbox validation, but it does not include a redacted after-fix provider session, runtime log, terminal output, recording, or linked artifact that shows real replay behavior. 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 4 items Shared replay consolidation: The branch exports a common reasoning-replay normalizer and replaces duplicated provider-local replay mutations in Baseten, Kimi, OpenRouter, Qwen, and Venice wrappers.
Ollama ownership remains plugin-local: The branch keeps Ollama’s transport, replay, thinking, overflow, and failover behavior inside the Ollama plugin by sharing a typed hook object between its local and cloud provider registrations.
Focused regression coverage: The branch adds shared-helper tests for assistant-only backfill, provider-selected tool-call backfill, null replacement, and disabled-reasoning cleanup; the PR body also reports targeted provider and SDK checks.
Findings None None.
Security None None.

How this fits together

Provider plugins prepare model-specific stream payloads before OpenClaw sends requests to OpenAI-compatible and native provider transports. The shared replay helper determines whether historical assistant reasoning is retained, removed, or backfilled when tool-call conversations switch among those transports.

flowchart LR
  A[Conversation history] --> B[Provider stream wrapper]
  B --> C[Shared reasoning replay policy]
  C --> D{Provider transport rules}
  D --> E[OpenAI-compatible payload]
  D --> F[Ollama native payload]
  E --> G[Provider API request]
  F --> G
  G --> H[Assistant stream and tool calls]
Loading

Before merge

  • Add real behavior proof - Needs real behavior proof before merge: The PR body reports targeted tests, SDK checks, and CI/Testbox validation, but it does not include a redacted after-fix provider session, runtime log, terminal output, recording, or linked artifact that shows real replay behavior. 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) - One shared helper now controls replay-field mutation for several providers whose earlier rules intentionally differed for null values, tool-call selection, and cleanup scope; test coverage is strong but the supplied material does not demonstrate an after-fix real provider replay run.
  • Resolve merge risk (P1) - The maintainer label requires explicit maintainer handling before any cleanup or merge automation decision.
Agent review details

Security

None.

PR surface

Source -123, Tests +98. Total -25 across 9 files.

View PR surface stats
Area Files Added Removed Net
Source 8 121 244 -123
Tests 1 98 0 +98
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 9 219 244 -25

Review metrics

Metric Value Why it matters
Replay-policy centralization 1 shared helper adopted across 5 provider wrappers; 2 Ollama identities share 1 hook object The reduced duplication is valuable, but semantic differences now depend on options passed to one common implementation.

Merge-risk options

Maintainer options:

  1. Add after-fix replay evidence (recommended)
    Capture a redacted real provider-session transcript, terminal output, or request diagnostic that demonstrates reasoning replay across at least one shared-policy path and one provider-specific option path before merge.
  2. Accept test-backed refactor risk
    A maintainer may merge based on the focused regression suite if they confirm that no credentialed provider-session proof is proportionate for this behavior-neutral refactor.

Technical review

Best possible solution:

Keep the provider-specific option callbacks narrowly documented and land only after a redacted after-fix provider-session artifact confirms that a replayed tool-call conversation preserves each affected transport’s intended reasoning field behavior.

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

Not applicable: this PR is a provider-policy refactor, not a report of a currently reproducible user bug. The branch includes focused regression tests, but no failing current-main reproduction was supplied because the intended result is semantic preservation.

Is this the best way to solve the issue?

Yes, provisionally: centralizing identical replay-field transformations in the existing provider-stream SDK is the most maintainable shape, provided the provider-specific selection and null-handling options remain covered by both tests and real behavior proof.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add P3: This is a behavior-preserving provider refactor with bounded compatibility review needs rather than a confirmed user-facing regression.
  • add merge-risk: 🚨 compatibility: The patch centralizes persisted-conversation replay behavior across multiple provider transports, so an incorrect shared default could affect existing cross-provider tool-call sessions.
  • add rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🐚 platinum hermit.
  • add status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: The PR body reports targeted tests, SDK checks, and CI/Testbox validation, but it does not include a redacted after-fix provider session, runtime log, terminal output, recording, or linked artifact that shows real replay behavior. 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.

Label justifications:

  • P3: This is a behavior-preserving provider refactor with bounded compatibility review needs rather than a confirmed user-facing regression.
  • merge-risk: 🚨 compatibility: The patch centralizes persisted-conversation replay behavior across multiple provider transports, so an incorrect shared default could affect existing cross-provider tool-call sessions.
  • 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 body reports targeted tests, SDK checks, and CI/Testbox validation, but it does not include a redacted after-fix provider session, runtime log, terminal output, recording, or linked artifact that shows real replay behavior. 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:

  • Shared replay consolidation: The branch exports a common reasoning-replay normalizer and replaces duplicated provider-local replay mutations in Baseten, Kimi, OpenRouter, Qwen, and Venice wrappers. (src/plugin-sdk/provider-stream-shared.ts:463, 8e88079876d3)
  • Ollama ownership remains plugin-local: The branch keeps Ollama’s transport, replay, thinking, overflow, and failover behavior inside the Ollama plugin by sharing a typed hook object between its local and cloud provider registrations. (extensions/ollama/index.ts:715, 8e88079876d3)
  • Focused regression coverage: The branch adds shared-helper tests for assistant-only backfill, provider-selected tool-call backfill, null replacement, and disabled-reasoning cleanup; the PR body also reports targeted provider and SDK checks. (src/plugin-sdk/provider-stream-shared.test.ts:264, 8e88079876d3)
  • Protected review state: The PR is newly opened on July 27, 2026 and has the protected maintainer label, so conservative cleanup must not auto-close it.

Likely related people:

  • steipete: The available PR history identifies steipete as the author of the consolidated replay-policy change across the affected provider plugins; local history inspection was unavailable in this read-only environment, so ownership confidence remains moderate. (role: provider replay refactor contributor; confidence: medium; commits: 8e88079876d3; files: src/plugin-sdk/provider-stream-shared.ts, extensions/ollama/index.ts, extensions/openrouter/stream.ts)

Rank-up moves

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

  • Add redacted after-fix evidence from a real provider conversation that replays assistant reasoning through a tool-call turn.
  • Show one default shared-replay case and one provider-specific option case, with private endpoints, identifiers, and credentials redacted.

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.

@steipete
steipete merged commit 778edf0 into main Jul 27, 2026
188 of 200 checks passed
@steipete
steipete deleted the codex/reduce-provider-policies-f0a963a2cb5 branch July 27, 2026 18:15
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

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

Labels

extensions: baseten Extension: baseten extensions: kimi-coding extensions: ollama extensions: openrouter extensions: venice extensions: xai maintainer Maintainer-authored PR merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. 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