Skip to content

fix(agents): align /btw model resolution with runtime aliases#92181

Closed
wangwllu wants to merge 1 commit into
openclaw:mainfrom
wangwllu:fix/btw-resolver-alias-92168
Closed

fix(agents): align /btw model resolution with runtime aliases#92181
wangwllu wants to merge 1 commit into
openclaw:mainfrom
wangwllu:fix/btw-resolver-alias-92168

Conversation

@wangwllu

@wangwllu wangwllu commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes #92168.

/btw used a registry-only model lookup, while the main agent loop resolves models through resolveModelAsync with runtime-aware fallback. That made /btw fail for canonical provider aliases such as anthropic/* when they are intentionally routed through a CLI runtime via agentRuntime.id and no direct provider entry exists in the agent's discovered models.json.

This PR aligns /btw model resolution with the main agent path by:

  • resolving the selected harness/runtime before model lookup
  • using resolveModelAsync instead of the primitive registry-only resolver
  • allowing bundled static catalog fallback when a plugin/CLI runtime owns transport
  • allowing metadata-only configured agent models when a plugin/CLI runtime owns transport
  • preserving the existing discovered-models retry path for normal OpenClaw-owned transports

Real behavior proof

  • Behavior or issue addressed: Native Telegram /btw side questions should resolve the selected session model the same way as the main agent turn when the selected model is a canonical provider alias routed through a CLI/plugin runtime. A metadata-only agents.defaults.models["provider/model"] entry with agentRuntime.id should not fail early with Unknown model just because there is no direct models.providers.<provider> registration.
  • Real environment tested: OpenClaw 2026.6.5 local gateway on macOS, Telegram group topic command path, patched local dist built from this PR branch. The concrete custom model id, private provider details, and local account identifiers are intentionally redacted.
  • Exact steps or command run after this patch:
    1. Configure the primary model as anthropic/<redacted-custom-cli-model>.
    2. Configure agents.defaults.models["anthropic/<redacted-custom-cli-model>"].agentRuntime.id = "claude-cli".
    3. Leave models.providers.anthropic unregistered, matching the original failing setup.
    4. Trigger native Telegram /btw what is this repro checking? in an active session.
    5. Compare the failure layer before and after the resolver change.
  • Evidence after fix:
    • Before the follow-up fix, native Telegram /btw stopped in the resolver with a redacted form of: Unknown model: anthropic/<redacted-custom-cli-model>. Found agents.defaults.models[...] but no matching models.providers["anthropic"].models[] entry....
    • After the code change, the real resolver regression for the same redacted config shape (skipAgentDiscovery, no provider registration, metadata-only agentRuntime.id = "claude-cli") returns a resolved model instead of Unknown model.
    • Local verification for the patch: npm test -- --run src/agents/btw.test.ts src/agents/embedded-agent-runner/model.test.ts passed 142 tests; npm run tsgo:core:test, oxfmt --check, oxlint, and git diff --check all passed.
  • Observed result after fix: The resolver no longer rejects metadata-only CLI-runtime agent models before execution. /btw now uses the runtime-aware resolver path and can proceed past model resolution for the original no-models.providers.anthropic configuration shape. Any later provider/API/runtime error is outside this resolver bug and no longer appears as the primitive /btw Unknown model failure.
  • What was not tested: The PR does not publish the private custom model id, private provider credentials, raw Telegram screenshots, or account-specific runtime logs. It also does not claim that every downstream CLI provider accepts every custom model id; this fix is scoped to /btw model resolution consistency before provider execution.

Tests

  • npm test -- --run src/agents/btw.test.ts src/agents/embedded-agent-runner/model.test.ts
  • npm run tsgo:core:test
  • npx oxfmt --check src/agents/btw.ts src/agents/btw.test.ts src/agents/embedded-agent-runner/model.ts src/agents/embedded-agent-runner/model.test.ts
  • npx oxlint src/agents/btw.ts src/agents/btw.test.ts src/agents/embedded-agent-runner/model.ts src/agents/embedded-agent-runner/model.test.ts
  • git diff --check

Note: npm run check:changed could not run locally because the configured Blacksmith/crabbox wrapper failed its own binary sanity check before executing repository checks.

@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: M triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup. labels Jun 11, 2026
@clawsweeper

clawsweeper Bot commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed June 12, 2026, 9:19 AM ET / 13:19 UTC.

Summary
Review failed before ClawSweeper could summarize the requested change.

PR surface: Source +135, Tests +103. Total +238 across 4 files.

Reproducibility: unclear. The review failed before ClawSweeper could establish a reproduction path.

Review metrics: none identified.

Stored data model
Persistent data-model change detected: vector/embedding metadata: src/agents/embedded-agent-runner/model.test.ts. Confirm migration or upgrade compatibility proof before merge.

Merge readiness
Overall: 🌊 off-meta tidepool
Proof: 🌊 off-meta tidepool
Patch quality: 🌊 off-meta tidepool
Result: rating does not apply to this item.

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

Risk before merge

  • [P1] No close action taken because the review did not complete.

Maintainer options:

  1. Decide the mitigation before merge
    Retry the Codex review after fixing the execution failure.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Next step before merge

  • [P1] Review did not complete, so no work-lane recommendation was made.
Review details

Best possible solution:

Retry the Codex review after fixing the execution failure.

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

Unclear. The review failed before ClawSweeper could establish a reproduction path.

Is this the best way to solve the issue?

Unclear. Retry the review first so ClawSweeper can evaluate the actual issue and fix direction.

AGENTS.md: unclear because the file could not be read completely.

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

Label changes

Label changes:

  • remove P2: Current review triage priority is none.
  • remove merge-risk: 🚨 auth-provider: Current PR review selected no merge-risk labels.

Label justifications:

  • rating: 🌊 off-meta tidepool: Overall readiness is 🌊 off-meta tidepool; proof is 🌊 off-meta tidepool and patch quality is 🌊 off-meta tidepool.
Evidence reviewed

PR surface:

Source +135, Tests +103. Total +238 across 4 files.

View PR surface stats
Area Files Added Removed Net
Source 2 163 28 +135
Tests 2 140 37 +103
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 4 303 65 +238

What I checked:

  • failure reason: retryable codex transport failure (capacity)
  • codex failure detail: Codex review failed for this PR with exit 1.
  • codex stderr: nusable; main turns continue to work, so the blast radius is limited to that one command.\n- Frequency: 4/4 observed (deterministic given the config shape).\n- Consequence: No side-question access in active sessions. Workaround forces users to either drop the canonical-alias indirection or skip /btw.\n\n### Additional information\n\n- Sibling resolver-divergence reports: image/pdf tool: 'Unknown model' for every provider, while the same models work as agent models (2026.5.28 and 2026.6.5) #92104 (image/pdf tool: same "resolver instance can't see catalog/aliases" symptom on every provider) and [Feature]: Per-alias agentRuntime override to support dual-route model configurations (Anthropic CLI + API) #82314 (asks for the dual-route alias shape that this bug then fails to handle in /btw). Likely the same underlying lesson — every callsite that resolves a runtime model should use resolveModelAsync (with multi-candidate + bundled-catalog fallback), not the bare resolveModelWithRegistry.\n- Suggested fix: Replace resolveModelWithRegistry in btw.ts:260 with resolveModelAsync (or at least mirror run.ts:730-790's selectedRuntimeProvider candidate list + allowBundledStaticCatalogFallback: pluginHarnessOwnsTransport + ensureOpenClawModelsJson retry on miss). Harness selection above already classifies the run correctly; only the model-resolver call is wrong.\n- Workaround: Change agents.defaults.model.primary from anthropic/<model> to the explicit claude-cli/<model> (which models.json discovery does write). Cost: loses the canonical-alias indirection [Feature]: Per-alias agentRuntime override to support dual-route model configurations (Anthropic CLI + API) #82314 is steering users toward.\n- **Last known go.

Likely related people:

  • unknown: Codex failed before it could trace repository history. (role: review did not complete; confidence: low)
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.

@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. merge-risk: 🚨 auth-provider 🚨 May break OAuth, tokens, provider routing, model choice, or credentials. labels Jun 11, 2026
@wangwllu

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

Real behavior proof added in PR body — captured before/after on OpenClaw 2026.6.5 with patched dist. The error-message swap (primitive Unknown model → buildUnknownModelError with registration hint) shows the new resolveModelAsync path is hit; with a minimal provider entry registered as the new error suggests, /btw then reaches the configured CLI backend end-to-end and returns a normal side-question answer.

@clawsweeper

clawsweeper Bot commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

Re-review progress:

@clawsweeper

clawsweeper Bot commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Command router queued. I will update this comment with the next step.

@clawsweeper clawsweeper Bot added rating: 🌊 off-meta tidepool PR readiness rating does not apply to this item. 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. mantis: telegram-visible-proof Mantis should capture Telegram visible proof. and removed 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. rating: 🌊 off-meta tidepool PR readiness rating does not apply to this item. labels Jun 11, 2026
@wangwllu
wangwllu force-pushed the fix/btw-resolver-alias-92168 branch from aac90d0 to b512447 Compare June 11, 2026 16:14
@wangwllu

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

Pushed b512447. This addresses the P1 gap: runtime-owned /btw resolution now allows metadata-only agents.defaults.models[provider/model] entries when a CLI/plugin runtime owns transport, so the original no-models.providers.anthropic config shape no longer stops at Unknown model. Added a redacted real-resolver regression for that shape; PR body updated with privacy-preserving proof.

@clawsweeper

clawsweeper Bot commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

Re-review progress:

@clawsweeper clawsweeper Bot added rating: 🌊 off-meta tidepool PR readiness rating does not apply to this item. and removed 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. mantis: telegram-visible-proof Mantis should capture Telegram visible proof. labels Jun 11, 2026
@wangwllu

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

Updated the PR body Real behavior proof section to use the required fields (behavior, environment, steps, evidence, observedResult, notTested) while keeping the local custom model id and provider details redacted.

@clawsweeper

clawsweeper Bot commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Command router queued. I will update this comment with the next step.

@wangwllu

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

Corrected the Real behavior proof labels to the policy-recognized names (Behavior or issue addressed, Real environment tested, Exact steps or command run after this patch, Evidence after fix, Observed result after fix, What was not tested) while keeping private model/provider details redacted.

@openclaw-barnacle openclaw-barnacle Bot added proof: supplied External PR includes structured after-fix real behavior proof. and removed triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup. labels Jun 11, 2026
@openclaw-mantis

Copy link
Copy Markdown
Contributor

Mantis Telegram Desktop Proof

Summary: Mantis captured native Telegram Desktop before/after GIF evidence for /btw model resolution.

Main screenshot This PR screenshot
Baseline native Telegram Desktop screenshot Candidate native Telegram Desktop screenshot
Main This PR
Baseline native Telegram Desktop proof GIF Candidate native Telegram Desktop proof GIF

Motion-trimmed clips:

Raw QA files: https://artifacts.openclaw.ai/mantis/telegram-desktop/pr-92181/run-27356952236-1/index.json

@wangwllu

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

Two prior re-review attempts (16:28Z and 16:38Z on 2026-06-11) both got picked up but progress stuck at State: Failed / Detail: targeted re-review did not finish c... — looks like Codex transport flake on the queue side rather than anything in this PR. CI is green across all 12 workflows, Mantis Telegram Desktop Proof posted full baseline+candidate evidence, and the PR-body Real behavior proof now uses the policy-recognized field names. Trying once more to get a fresh verdict.

@wangwllu

Copy link
Copy Markdown
Contributor Author

@vincentkoc — heads up that ClawSweeper review keeps failing on this PR for what looks like a Codex backend issue rather than anything in the change itself. Sharing the artifacts in case you want to bypass the 🌊 off-meta tidepool rating and review/merge directly.

Root cause (from clawsweeper run 27389971002 job 80945192159 step 13 "Review exact event item"):

[review] codex-retry #92181 attempt=2/3 delay_ms=15000 reason=transient_transport
[review] codex-retry #92181 attempt=3/3 delay_ms=30000 reason=transient_transport
[review] shard=0/1 done #92181 (1/1) decision=keep_open confidence=low action=kept_open
Error: Codex failed for 1 item; review artifacts were written and the workflow recovery lane can requeue the planned set.
ELIFECYCLE  Command failed with exit code 1.

All 3 Codex retries returned transient_transport, the run fell back to decision=keep_open confidence=low with the placeholder "Review failed before ClawSweeper could summarize the requested change." summary, and that got synced into the existing 🌊 off-meta tidepool / [P1] Review did not complete verdict comment. Three @clawsweeper re-review attempts (2026-06-11 16:16Z, 16:35Z, 2026-06-12 02:14Z) all reproduced the same shape, so this is a stable Codex backend failure on this PR rather than transient flake.

PR-side state is healthy:

  • PR body 4243 B, diff 21460 B across 4 files (+135 src / +103 tests) — moderate, not unusually large
  • All 12 GitHub workflows latest-green: CI (123 runs), CodeQL, CodeQL Critical Quality, Real behavior proof ✅, OpenGrep, Opengrep OSS, Workflow Sanity, Dependency Guard, Auto response, Labeler. ClawSweeper Dispatch and Mantis Telegram Desktop Proof are SKIPPED on the PR check tab purely because of the fork-PR pull_request_target quirk
  • openclaw-mantis Telegram Desktop Proof comment (run 27356952236) recorded native Telegram Desktop GIF+MP4+screenshot evidence that /btw resolves the model on the candidate where main reproduces the Unknown model failure
  • mergeable: MERGEABLE / mergeStateStatus: CLEAN, proof: supplied label applied
  • Will also file a separate issue against openclaw/clawsweeper for the underlying Codex transport pattern.

If you're OK with it, would you be willing to either review directly or bypass the ClawSweeper rating gate for this one? Happy to provide more evidence or split the diff if that helps.

@joshavant

Copy link
Copy Markdown
Contributor

Thanks @wangwllu for the broader resolver PR, the detailed proof, and the native Telegram evidence.

We merged #92226 as the narrower interim fix. The key decision was to stop /btw from silently switching a CLI-backed session over to direct provider auth/streaming; that is a transport/auth boundary issue, not only a model-resolution issue. The merged change now fails closed for CLI-runtime aliases until the selected runtime owns side-question execution.

Working same-runtime /btw support for CLI runtimes will be added in a future commit via a runtime-owned side-question path.

@joshavant joshavant closed this Jun 12, 2026
@wangwllu

Copy link
Copy Markdown
Contributor Author

Thanks for the quick fix and the clear framing on the transport/auth boundary — the fail-closed semantics make sense, and the error text users now see is far better than the prior Unknown model stack.

One small ask: is there a tracking issue or rough milestone for the runtime-owned side-question path? I'm a daily user of /btw on a CLI-routed Anthropic model, so I'd be happy to dogfood it as soon as there's a draft branch, and to contribute Telegram/native real-behavior proof similar to the Mantis run on this PR. No expectation of a date — just want to know where to watch so I can volunteer at the right moment instead of opening a stray PR.

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. proof: supplied External PR includes structured after-fix real behavior proof. rating: 🌊 off-meta tidepool PR readiness rating does not apply to this item. size: M

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: /btw fails with "Unknown model" for anthropic/* aliases routed via agentRuntime: claude-cli (resolver path divergence from main agent loop)

2 participants