Skip to content

refactor(agents): unify configured model assembly - #178309

Merged
steipete merged 2 commits into
mainfrom
deslop/z39-18-configured-model-owner-20261015
Oct 20, 2026
Merged

steipete merged 2 commits into
mainfrom
deslop/z39-18-configured-model-owner-20261015

Conversation

@steipete

@steipete steipete commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Configured-only model resolution duplicates the route, request, pricing, capability, and token-limit assembly already used for discovered models.

User Impact

No user-visible change is intended. Existing model configuration, provider routes, plugin hooks, suppression, credential authority, and unknown-output-cap behavior remain supported. No configuration, protocol, dependency, persisted-shape, or public SDK change.

Why This Change Was Made

Let the existing configured-override owner handle an absent discovered model explicitly. Keep the genuine optional catalog donor separate rather than fabricating a model that can accidentally authorize its own route. Three production callers now use the existing normalization operation; delete the parallel constructor and its orphan parameter-merge wrapper.

Retain authored source pricing, model/provider/manifest/catalog route precedence, headers and request facts, input/media/reasoning, same-route compatibility and parameter counts, context provenance, output-cap omission/clamping/provenance, and final runtime normalization. The no-op discovered branch still exists, but prepares its passthrough request only when used.

Best-effort tradeoffs accepted

  • No security, durability, public-contract, or speculative-race guard is removed. This is duplicate assembly consolidation, not a new best-effort routing policy. The constructor split in #113785 did not make it a separate product contract.
  • Keep the behavior from #98295: an unknown output cap stays absent, not replaced by the context window. Keep authored pricing from #144034 and route support from #150128. The human repetition reports #138245 and #44965 are not dismissed; their same-route parameter metadata/output-budget behavior remains.

Evidence

Net production: 179 lines removed (+107/-286); completed-owner residue under the campaign's 100-line rule, not a LARGE PR. Test delta +4/-4 consists only of migrating existing constructor calls/imports; no assertion, timeout, retry, or skip is weakened.

  • All 119 existing cases across 13 model/catalog/prompt-prefix files passed in five serial Vitest shards, --maxWorkers=1. The wrapper took 918 seconds including cold compiler/import work on the shared host; no speedup claim. This source remained unchanged throughout the run. The only subsequent change deletes a wrapper with no remaining reference; behavioral proof is reused for that unreachable deletion.
  • The changed pricing suite's test body took 3.1 seconds; the existing forward-compatibility/override cases took about 12 seconds together, preserving distinct pricing, suppression, alias-route, and fallback contracts. Hosted CI seconds are pending.
  • Final targeted typecheck, scoped type-aware lint, runtime cycles (0), static/Madge cycles (0), six-file format, and the 14-case lint-suppression suite passed. The changed-check planner is dry-run only; exact-head PR CI supplies broad proof.
  • Final independent isolated P0–P2 review after orphan cleanup was scoped-clean (correct verdict, 0.90). Author simplification confirmed one assembly owner, no new mode, cache, seam, public type weakening, or suppression.
  • CI correction: document the existing unknown-output-cap assertion invariant and delete the retired constructor's stale assertion allowance. The targeted assertion ratchet, 14 suppression cases, format and diff checks pass; independent P0–P2 correction review is scoped-clean (0.99). No runtime changes; the 119-case behavior proof remains applicable. Exact-head CI 39406351126 passed, including the final CI gate. All 128 head check runs were accounted for; the two cancelled metadata jobs have successful same-head replacements.

Local proof uses nice -n 10 and isolated HOME/OpenClaw/XDG/TMP state. No live-provider, throughput, or whole-product E2E claim. The standalone Phase E session memory backend is untouched.

@clawsweeper

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

@steipete
steipete marked this pull request as ready for review October 20, 2026 09:26
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-20T09:30:01.874517Z 00b3812 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: M labels Oct 20, 2026
@clawsweeper clawsweeper Bot added P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Oct 20, 2026
@clawsweeper

clawsweeper Bot commented Oct 20, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs changes before merge.

What this changes

This PR routes configured-only models through the existing configured-override owner and deletes the separate fallback constructor.

Example: Resolve xiaomi/mimo-v2.5-pro without an authored output cap.

  • Before: The separate fallback constructor leaves maxTokens absent.
  • After: The shared configured-override owner leaves maxTokens absent.

Review scores

Measure Result What it means
Overall readiness 🦪 silver shellfish (2/6) The consolidation is coherent and preserves the inspected runtime contracts, but a directly introduced ratchet failure blocks readiness.
Proof confidence 🦐 gold shrimp (3/6) This maintainer-authored refactor is outside the ordinary contributor proof gate; supplied validation exercises model-resolution tests rather than a shipped CLI or Gateway request.
Patch quality 🦪 silver shellfish (2/6) 1 actionable review finding remain.

Product

Kind: Refactor · Worth it: Yes · Fix scope: Complete
User problem: Duplicated model assembly makes consistent preservation of configured routes, pricing, and token limits harder to maintain.
Reason: The maintainer-authored direction consolidates an existing responsibility, removes the replaced path, and adds no configuration or public API.

Merge readiness

⛔ Needs changes before merge - 1 item remains

Keep open: this is a useful maintainer-directed consolidation with one concrete assertion-ratchet blocker.

Priority: P3
Reviewed head: 00b38127511b7aac42a1c24ca49301f2fe5f32fa

Before merge

  • Reconcile the assertion ratchet after consolidating model assembly (P2) - The new as Model makes this file contain two uncommented non-const assertions, while config/assertion-safety-baseline.txt allows one. The baseline also retains the deleted fallback file's allowance. check-assertion-safety-ratchet.mts rejects both conditions, and the reviewed head's baseline job reports assertion-safety failure. Remove the added assertion where possible, or document its concrete invariant under the existing SAFETY rule, and remove the deleted file's stale allowance without increasing the surviving allowance.

Findings

  • [P2] Reconcile the assertion ratchet after consolidating model assembly — src/agents/embedded-agent-runner/model.configured-overrides.ts:685

Tests

  • Missing end-to-end proof: The supplied evidence covers resolver tests, with no shipped-entry-point configured-only request demonstrated.
Agent review details

How this fits together

Model resolution combines configured rows, catalog metadata, provider transport, and request policy into the runtime model consumed by agent execution and prepared aliases.

flowchart TD
  A[Model configuration] --> D[Configured override owner]
  B[Registry and catalog metadata] --> D
  C[Provider transport and request policy] --> D
  D --> E[Runtime model normalization]
  E --> F[Agent execution]
  E --> G[Prepared model aliases]
Loading

Technical review

Best possible solution:

Keep the single assembly owner, repair its assertion accounting without expanding allowances, and preserve the existing routing, pricing, and unknown-cap contracts.

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

Source inspection establishes the assertion-ratchet violation directly; no target code or tests were executed during this read-only review.

Is this the best way to solve the issue?

Extending the existing override owner is the smallest coherent consolidation, and the migrated tests retain distinct pricing and fallback contracts.

Full review comments:

  • [P2] Reconcile the assertion ratchet after consolidating model assembly — src/agents/embedded-agent-runner/model.configured-overrides.ts:685
    The new as Model makes this file contain two uncommented non-const assertions, while config/assertion-safety-baseline.txt allows one. The baseline also retains the deleted fallback file's allowance. check-assertion-safety-ratchet.mts rejects both conditions, and the reviewed head's baseline job reports assertion-safety failure. Remove the added assertion where possible, or document its concrete invariant under the existing SAFETY rule, and remove the deleted file's stale allowance without increasing the surviving allowance.
    Confidence: 0.99

Overall correctness: patch is incorrect
Overall confidence: 0.94

AGENTS.md: found and applied where relevant.

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

Provenance checked

Testing

Proof path: unit tests only.

Security

None.

Evidence

Acceptance criteria:

  • pnpm check:assertion-safety
  • pnpm test src/agents/embedded-agent-runner/model.configured-pricing.test.ts src/agents/embedded-agent-runner/model.forward-compat.errors-and-overrides.test.ts --maxWorkers=1
  • git diff --check

What I checked:

Likely related people:

  • Ayaan Zaidi: Raw commit 5f17f89 adds src/agents/embedded-agent-runner/model.configured-overrides.ts:58 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 5f17f893af58; files: src/agents/embedded-agent-runner/model.configured-overrides.ts)

PR surface

Source -179, Tests 0. Total -179 across 7 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 5 107 286 -179
Tests 2 4 4 0
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 7 111 290 -179

Review metrics

Metric Value Why it matters
Production versus test changes Production +107/-286; tests +4/-4 The reduction removes duplicate assembly; test edits migrate existing calls without changing assertions.

Labels

Label changes:

  • add P3: This is internal cleanup with no intended user-visible behavior change.
  • add rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦐 gold shrimp and patch quality is 🦪 silver shellfish.
  • add status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.

Label justifications:

  • P3: This is internal cleanup with no intended user-visible behavior change.
  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦐 gold shrimp and patch quality is 🦪 silver shellfish.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.

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 execution lanes are retired.

Reviewed October 20, 2026, 5:44 AM ET / 09:44 UTC.

@steipete
steipete merged commit 3213e3e into main Oct 20, 2026
138 of 140 checks passed
@steipete
steipete deleted the deslop/z39-18-configured-model-owner-20261015 branch October 20, 2026 10:44
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 21, 2026
* refactor(agents): unify configured model assembly

* chore(agents): reconcile model assertion safety accounting
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling 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: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant