Repository navigation
Add Qwen Code as a supported agent - #787
Open
QuanCheng-QC wants to merge 3 commits into
Open
QuanCheng-QC wants to merge 3 commits into
QuanCheng-QC wants to merge 3 commits into
Conversation
Qwen Code (npm @qwen-code/qwen-code, binary qwen) is Alibaba's open-source
terminal coding agent. It runs here the way CodeBuddy does, one headless
`qwen --output-format stream-json` run per message with the prompt piped
over stdin, workspace tools over --mcp-config, and the channel's session
resumed with --resume. The stream is Claude Code's frame format, so the
reply is read from the result frame and assistant frames only drive the
progress ticker.
Behaviour verified against the real CLI (0.25.1) that shaped the adapter
- Auto-memory is turned off. Left on, every turn ends with a memory
extractor subagent and the result frame waits for it. A resumed turn
had its answer after 7s and its result after 194s, with 100k+ extra
tokens. The adapter loads a system-defaults settings layer
(QWEN_CODE_SYSTEM_DEFAULTS_PATH) that disables it, plus self-update
and usage statistics. The user's own settings.json still wins, and a
machine-wide system-defaults file is merged, not replaced.
- --auth-type openai is passed whenever the agent has a key. The CLI
only infers its OpenAI provider when a key AND a model are both set,
otherwise it fails with "No auth type is selected". Key, base URL and
model are taken as one set, from the agent's LLM_* fields or from
OPENAI_*, never mixed. A blank base URL means Model Studio only for
the agent's own key, so an OPENAI_API_KEY exported for another tool
is never sent to DashScope.
- Sessions are filed under the working directory, so a channel's
session is only resumed from the directory it was created in, and a
"No saved session found" resume is retried once from scratch. A
stopped session stays resumable, so Stop keeps the conversation.
- A model error is streamed as "[API Error ...]" assistant text before
the is_error result frame. It is reported as an error, never posted
as the answer.
- On Windows the npm entry script relaunches the CLI as a child, and
killing only the parent leaves the turn running, so Stop uses
taskkill /T. On POSIX, SIGINT to the group ends the run in ~100ms.
- The npm package runs as cli-entry.js under the launcher's Node (the
CLI needs Node 22), and a standalone install on its bundled Node, so
the system prompt never goes through cmd.exe and its length limit.
- cron_create, cron_list, cron_delete and loop_wakeup are excluded, as
scheduling inside a one-shot process never fires.
Minimum supported version is 0.16.0, the first release that accepts
--mcp-config.
Wiring
- registry/qwen-code.json with LLM_API_KEY, LLM_BASE_URL and LLM_MODEL
mapped to OPENAI_*, synced to the bundled and backend copies, icon in
every icon dir
- paths.js detects the standalone installer's Windows dir and its
QWEN_INSTALL_ROOT and QWEN_INSTALL_BIN_DIR overrides, and the
detection matrix covers npm and both standalone installers
- launcher CORE_AGENTS, model picker listing from Model Studio when the
base URL is blank, icon slug, en and zh descriptions
- workspace connect view brand colour, docs/agents/qwen-code.md
Tests
- qwen-code-stream.test.js and qwen-code.test.js (64), with a mock CLI
that replays the real CLI's success, MCP, missing key, 401, stale
resume and stop transcripts
- stop-control.test.js now covers qwen-code
- end to end with a real Model Studio key against a local workspace
backend, a reply, three turns on one session, a workspace MCP tool
writing todos, Stop mid tool clearing the CLI and its tool process in
about a second, and the conversation continuing after Stop
No package or launcher version is changed.
…tings a run needs
The model and base URL are now required fields, with the base URL prefilled
with Model Studio China.
- Left blank, the CLI runs qwen3.7-max, its most expensive tier, which a
Coding Plan account may not offer at all.
- The launcher's connection test probes what the form holds. A blank
model made it try the endpoint's first listed model, which this key was
not entitled to (a 403 that reads as a broken key), and a blank base
URL made it probe api.openai.com while the agent itself would have used
Model Studio. With both fields required, the test and the agent use the
same endpoint and model.
The workspace's own agent form can still create the agent with only a key,
so the adapter keeps its fallbacks (Model Studio for a blank base URL, the
CLI's default model).
The settings layer no longer turns off usage statistics. It changes only
what a headless run depends on, auto-memory and self-update, and leaves the
rest to the user.
The CLI writes a "$version" stamp back into the settings file it loads. The
adapter rewrote the file whenever its text differed, so every turn replaced
the file and every run migrated and wrote it again, while another channel's
run could be reading it. The comparison now ignores that stamp, and the file
is written once.
Verified again end to end with a real Model Studio key against a local
workspace backend, all checks passing, including the settings file staying
untouched after the first turn.
Fix saved-provider credential routing, UTF-8 stream decoding, legacy API error results, and pinned channel context. Preserve system settings and clean legacy migration backups, with mocked and real CLI regression coverage.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
Request, translated from the original:
Qwen Code (
@qwen-code/qwen-code, binaryqwen) is the first agent in the plan to add Chinese coding agents.Before and after
On
develop, Qwen Code is not in the catalog, the launcher cannot install it, and a workspace cannot run it:createAdapter('qwen-code')throws "Unknown agent type".~/.local/bin,%LOCALAPPDATA%\qwen-code\bin, andQWEN_INSTALL_ROOT/QWEN_INSTALL_BIN_DIR)How it works
One headless run per message:
resultframe; assistant frames only drive the progress ticker.--resume. Qwen files sessions by working directory, so a session is only resumed from the directory it was created in. If the CLI cannot find the saved session, the turn is retried once from scratch. A stopped session stays resumable.0600and deleted when the run ends.taskkill /T.cli-entry.jsruns under the launcher's Node (the CLI needs Node 22 or newer), and a standalone install runs on the Node it bundles. Either way, the system prompt never passes throughcmd.exeand its command-line length limit.CLI behaviour this relies on
Verified against Qwen Code 0.25.1. The minimum supported version is 0.16.0, the first release that accepts
--mcp-config.memory.enableManagedAutoMemory, a memory-extractor subagent runs after each turn and theresultframe waits for it. On a resumed session the answer was ready after 7s but the frame arrived after 194s, and the extractor used 100k+ extra tokens. A system-defaults settings layer (QWEN_CODE_SYSTEM_DEFAULTS_PATH) turns auto-memory and self-update off. The user's ownsettings.jsonstill takes precedence, and a machine-wide system-defaults file is merged in, not replaced. The CLI writes a$versionstamp back into the file; the adapter ignores it, so the file is written only once.--auth-type openaiis always passed with a key. Key, base URL and model are taken as one set, either all from the agent'sLLM_*fields or all fromOPENAI_*, never mixed.api.openai.com, so it is never sent to another provider.modelProvidersentry in~/.qwen/settings.jsonwith the same model id redirects the request to its own endpoint, and can even swap in its own key. When the agent supplies a key, a per-run system-settings file clearsmodelProviders. Machine-wide system settings are carried over, and the temporary file is deleted after the run.[API Error: …]assistant text, followed by anis_errorresult frame. Release 0.16.0 instead wraps them in a successful result and exits 0. Both forms are reported as errors and never posted as an answer.Configuration
LLM_API_KEY,LLM_BASE_URLandLLM_MODELmap toOPENAI_*. The base URL is required and prefilled with Model Studio China. The model is required for two reasons:qwen3.7-max, its most expensive tier, which a Coding Plan account may not offer.The workspace's own agent form can still create the agent with only a key. The adapter then falls back to Model Studio and the CLI's default model.
Compatibility
paths.jsonly gains detection directories.develop(v1.1). The Qwen tests and the full agent-connector suite were re-run on the merged tree.OPENAGENTS_REQUESTER_EMAILfor escalation tools. The Qwen adapter does not pass it yet, and neither does CodeBuddy's.Tests
qwen-code-stream.test.jsandqwen-code.test.js: 77 tests, using a mock CLI that replays real transcripts (success, MCP call, missing key, 401, a 0.16.0-style error, a UTF-8 character split across chunks, stale resume, Stop, settings handling).qwen-code-cli.test.js: an opt-in real-CLI regression test. SetQWEN_CODE_TEST_CLIto aqwenbinary; it uses a local HTTP endpoint and no paid key. It passes on 0.25.1 and 0.16.0 and fails on the code before the saved-provider fix.stop-control.test.js,agent-detection-matrix.test.jsand the registry sync check now coverqwen-code.--resume).workspace_put_todoscalled over MCP writes todos to the workspace.develop:wsl.test.js"an agent that only exists inside the distro" fails on the test machine because it reads the real~/.openagents/runtimes.index.test.tsxis flaky.tscpasses.Docs:
docs/agents/qwen-code.md.