Repository navigation
fix(qwen): pass the complete model id to the qwen CLI - #399
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 91b238a8ab
ℹ️ 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".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
8e20a95 to
cffa997
Compare
|
One addition on top of the review fix: the engine name is not canonicalised in |
|
Thanks for addressing the bare-model regression. I think the Qwen-specific behavior should live at the adapter boundary rather than adding another engine-specific branch in Issue #196 separates credential/provider resolution from adapter materialization. Also, #247/#262 removed Qoder’s model allowlist; they retained legacy Simply joining Please also cover the full resolution-to-execution path for slash-containing IDs, explicit providers with bare IDs, YAML configuration, and judge configuration. The command-builder test alone does not exercise the parsing that caused #383. |
cffa997 to
b35d4b5
Compare
|
Moved the Qwen behaviour to the adapter boundary as you asked — the credential layer is generic again. What changed in b35d4b5:
Tests now cover resolution through execution rather than command construction alone:
Verified with PR body is updated. Still no real qwen CLI/credentials on this machine, so the reporter's exact auth failure remains unverified end-to-end. |
|
The adapter boundary looks right now, but I think we can simplify the state by dropping Keeping both The legacy split is reversible, so we do not need a second model string. Please set the flag where splitting actually happens, clear it when another source replaces the model, and carry it along when inheriting the model. Qwen’s adapter materialization can reconstruct Explicit provider + bare model and separate YAML provider/name fields should remain unchanged. Please add regression coverage for environment overrides, including judge overrides and inherited runner models. |
b35d4b5 to
5909fbf
Compare
|
Rewritten per your review — thank you for the drift example; it is exactly the failure mode this simplification closes. What changed relative to the adapter-boundary revision:
Negative controls: disabling the join turns the adapter tests red ( |
|
Thanks, the flag-only implementation in 5909fbf addresses the state-drift concern from my previous comment, and the updated PR description now matches it. I reviewed the source and the new regression tests, but have not independently rerun the tests. GitHub currently reports merge conflicts for this head and no PR-triggered CI runs; please resolve the conflicts with the base branch and rerun verification on the resulting head so we can review the final integrated version. |
5909fbf to
44d0001
Compare
|
Rebased onto current main () as |
|
Thanks, the flag-only implementation addresses the state-drift issue. One part of my earlier feedback needs clarification: I meant for the reconstruction logic to live in
Please use its result consistently for |
zpzjzj
left a comment
There was a problem hiding this comment.
Requesting changes on 44d0001 to complete the adapter-boundary change. The drift fix is addressed, but ModelPolicyJoinLegacySplit still reconstructs Qwen IDs inside shared resolveAppliedModel. Please move reconstruction to Qwen-specific materialization in qwen_code.go, leaving the credential layer responsible only for recording/clearing/inheriting ModelSplit, and use the materialized result consistently for reporting, -m, and OPENAI_MODEL.
…licy `ModelPolicyJoinLegacySplit` rebuilt `provider/name` inside the shared `resolveAppliedModel`, so a rule about how one CLI receives a model id lived in the credential/agent-kind layer that alibaba#196 keeps for resolving credentials and protocol. It also meant the value the policy produced, the value the adapter passed to `-m`, and what the report called applied could drift. The shared layer now only records what happened: the credential layer splits a legacy `provider/name` to select provider-scoped credentials and sets `ModelSplit`, clears it when a provider env or credential file replaces the model wholesale, and lets a judge inherit it from the runner. `Config` carries the flag to the adapter and nothing rejoins it there. The adapter materializes the id. `QwenCodeAgent.MaterializedModel` rejoins `provider + "/" + name` when the flag is set and passes everything else through unchanged; `-m` and `OPENAI_MODEL` use it, and so does the applied model in `SessionResult` and the observability attributes, through the new `agent.ModelMaterializer` interface. An embedded `BaseAgent` cannot see the adapter holding it, so the adapter hands itself to the base in its constructor. Tests cover the four shapes end to end (CLI slashed, explicit provider with a bare name, YAML slashed, YAML provider plus name), the judge inheriting the runner's split, and one run asserting that `-m`, `OPENAI_MODEL` and the reported model are the same value. Disabling the rejoin fails all three.
|
Moved the rejoin into the adapter in Shared layer: records only. Adapter: materializes. One thing worth flagging, since it forced the shape: Tests, all end-to-end from resolution rather than command construction alone:
A judge inheriting the runner's split materializes the same id, and a provider env or credential file clears the flag and the replacement is forwarded as written.
|
|
Thanks, the reconstruction now lives in With a configured
Could we have a Qwen-specific config materialization function produce the complete The existing |
|
Following up on the applied-model report finding: there is a second mismatch at |
The applied model id that Qwen Code runs was assembled inside the adapter, so the run report and the telemetry read a different value than the command: the report recorded the bare model name and the telemetry could prefix the provider onto an id that was already qualified. ResolveAdapterConfig now dispatches to a Qwen-specific materialization before the adapter is built, so the command, the session result, the telemetry attributes and the machine-readable applied_configuration.model all read the same complete id. The ModelMaterializer callback is gone with it, and the report renderer no longer doubles a provider the id already carries. Co-Authored-By: Claude Code <[email protected]>
|
Both findings are addressed in The applied model id is now materialized in the shared entry point. The telemetry no longer doubles the provider. Coverage.
|
goconst flags `"zcode/GLM-5.3-Flash"` in `qwen_code_test.go`: the package already defines `qwenSlashedModelID` in `capabilities_test.go`, so the new assertions use it. The two `-m '…'` substring checks build the expected flag from the same constant instead of repeating the id.
|
CI caught a lint finding in my last commit — Verified with |
Summary
qwen_coderesolves its model against the ids registered in the qwen CLI'smodelProviders. When--model zcode/GLM-5.3-Flashmatches a configured provider, the credential layer splits the reference to select that provider's credentials (ZCODE_API_KEY, base URL), so the adapter used to receive the bareGLM-5.3-Flash, fail to match the registeredzcode/GLM-5.3-Flash, and fall back toOPENAI_API_KEY— the failure in #383.The split must stay: it is what picks provider-scoped credentials, and
opencoderelies on the same rule. What changes is who rebuilds the id and what the shared layer keeps.Where the id is rebuilt
The credential/agent-kind layer owns credentials and protocol, not how one CLI receives a model id (#196). So it now only records what happened to the model:
ResolvedAgentConfig.ModelSplitis set where the legacy split occurs —applyCLIModelOverridefor--modelandparseJudgeModelfor a judge model — cleared when a provider env var or credential file replaces the model wholesale (setResolvedValue), and inherited by a judge from the runner (applyFallback).internal/agent/capabilities.gorejoins anything:ModelPolicyJoinLegacySplitis gone andqwen_codeis back toModelPolicyPassthrough.The adapter materializes the id it runs:
QwenCodeAgent.MaterializedModel()returnsprovider + "/" + namewhenModelSplitis set, and the resolved model unchanged otherwise, so a bare name never gains a prefix it did not have.-mandOPENAI_MODELuse that value.SessionResultand theskill_up.model/skill_up.model.appliedattributes use the same value, viaagent.ModelMaterializer. The report therefore cannot name a model the CLI was not asked for.One implementation note:
annotateSessionResultis a*BaseAgentmethod, and a method called on an embeddedBaseAgentsees only the base — not the*QwenCodeAgentholding it. The adapter therefore gives itself to the base in its constructor (agent.inspector = agent), and the annotation asks that value for the materialized id. Engines that do not implementModelMaterializerare unaffected.Related issues
Changes
internal/credential/agent_init.go: recordModelSplitat the split sites, clear it on wholesale replacement, inherit it for a judge; drop the Qwen branch from the CLI override path.internal/agent/capabilities.go: removeModelPolicyJoinLegacySplitand its branch inresolveAppliedModel.internal/agent/agent.go:Config.ModelSplit,ModelMaterializer,BaseAgent.inspector, and reporting that goes through the materialized id.internal/agent/qwen_code.go:MaterializedModel, used by-m,OPENAI_MODEL.internal/agent/factory.go: passparams.ModelSplitto the adapter config.cli-reference, en + zh) andCHANGELOG.md.Test plan
make test— full suite green;make verify— 0 issues.zcode/GLM-5.3-Flash(split recorded, providerzcode), explicit--provider openai --model qwen3-coder-plus(bare, no invented prefix), YAMLmodel.name: zcode/GLM-5.3-Flash(opaque, no split), YAMLprovider: zcode+name: GLM-5.3-Flash(no split).TestQwenCodeRun_ForwardsResolvedSlashedModeldrives resolution → adapter → run and asserts that-m,OPENAI_MODELand the reported applied model are the same value.MaterializedModelstop rejoining failsTestResolveAdapterConfig_QwenRecordsLegacySplitForTheAdapter,TestResolveAdapterConfig_QwenJudgeInheritsLegacySplitandTestQwenCodeRun_ForwardsResolvedSlashedModel(adapter materialized model = "GLM-5.3-Flash", want "zcode/GLM-5.3-Flash").qwenshim recording argv, run through the built binary:--model zcode/GLM-5.3-Flash→--yolo -m zcode/GLM-5.3-Flash,OPENAI_MODEL=zcode/GLM-5.3-Flash.--provider openai --model qwen3-coder-plus→-m qwen3-coder-plus,OPENAI_MODEL=qwen3-coder-plus(no prefix invented).Notes
modelProviderslookup. The resolution path and the adapter's output are tested directly.opencodekeeps slashed ids opaque as before: it never sets or usesModelSplit.Disclosure
This change was prepared with AI assistance from DeepSeek Harness (deepseek-v4.1-flash), reviewed and adjusted by me before submission.