Repository navigation
feat(serve): expose the background agents the supervisor is running #10954
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 7 commits
dbe9950
8879852
06741f4
6eb41f0
eaa0a23
cb77045
85c5e36
a4baf7c
7d20281
3620141
9b14578
94610b3
3e3dac5
4d84fbc
29a69d0
993944c
2031747
02b87ee
6c194f9
572de7a
2fde009
6b2c711
e5e0b6d
6a96db5
7614b86
136e783
cd68e10
1077718
04735cc
5315cc4
2416476
edddf36
1f84edb
318237d
a5f3bb7
ad24822
3bc3f95
ebf5c1d
8294768
7f43e6b
1b58fbb
b2e1fea
0c5f997
420ab83
4467b79
3b97553
4f275d0
d5627a0
4ae0857
ec7f7ae
b98dfa1
728f08a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -707,10 +707,13 @@ These commands are run from the shell as `qwen <subcommand>` before starting an | |
|
|
||
| ### Session Management | ||
|
|
||
| | Command | Description | Usage Examples | | ||
| | -------------------- | ------------------------------------------- | ------------------------------------------------------------ | | ||
| | `qwen sessions list` | List recent conversation sessions | `qwen sessions list`, `qwen sessions list --json --limit 50` | | ||
| | `qwen sessions ps` | List interactive sessions running right now | `qwen sessions ps`, `qwen sessions ps --json` | | ||
| | Command | Description | Usage Examples | | ||
| | ---------------------- | --------------------------------------------- | ------------------------------------------------------------ | | ||
| | `qwen sessions list` | List recent conversation sessions | `qwen sessions list`, `qwen sessions list --json --limit 50` | | ||
| | `qwen sessions ps` | List the sessions running right now | `qwen sessions ps`, `qwen sessions ps --json` | | ||
| | `qwen sessions peek` | Show what a background session is doing | `qwen sessions peek 0f8e1c42` | | ||
| | `qwen sessions answer` | Answer a background session waiting for input | `qwen sessions answer 0f8e1c42 "yes, go ahead"` | | ||
| | `qwen sessions stop` | Stop a background session | `qwen sessions stop 0f8e1c42` | | ||
|
|
||
| #### `qwen sessions list` | ||
|
|
||
|
|
@@ -750,14 +753,35 @@ qwen sessions list --limit 50 | |
| qwen sessions list --json | jq . | ||
| ``` | ||
|
|
||
| #### `qwen --bg "<prompt>"` | ||
|
|
||
| Experimental. Runs a prompt as a background session and returns immediately, printing the session id. | ||
|
|
||
| The session is owned by a supervisor process that outlives the shell you started it from, so closing that terminal does not stop the work. `qwen sessions ps` lists it, and says whether it is `working` or has stopped to ask you something. It is a full Qwen Code session, so — when `agents.crossSessionMessaging` is on — it also appears in another session's `list_agents` and can be addressed with `send_message` (see [Messaging Another Running Session](#6-messaging-another-running-session)). | ||
|
yiliang114 marked this conversation as resolved.
Resolved
|
||
|
|
||
| ```bash | ||
| qwen --bg "find out why the release job is flaky" | ||
| # Started background session 0f8e...c31 | ||
|
Comment on lines
+775
to
+776
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Re-checked at head The wait is armed by default. Nothing can satisfy it. The So the documented success path is unreachable. One narrowing, so a fix does not chase the wrong mechanism: No code lands this round: the PR is +3193/-71, 2.1x over patrol's 1500-addition scope fuse, with a maintainer scope ruling pending. This one is docs-only and small —
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Held at Site status at the live head. Re-read at Why it is held rather than reworded. The correct text is different depending on which branch of N1 is chosen, so writing anything now means writing it twice:
Round 4 measured the shipped behaviour on this head: 2/2 real launches exit 1 after ~15 s with Leaving this thread open until the N1 ruling lands. 中文在 站点状态:在当前 head 上重读, 为什么挂起而不改文案:正确的文字取决于 N1 选哪条分支,所以现在写等于要写两遍:
第 4 轮在这个 head 上量到了实际行为:2/2 次真实启动都在约 15 秒后以退出码 1 结束、报 在 N1 裁决落地前保持本线程不 resolve。
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Held for the N1 decision, as recorded on this thread before: whether the shipped 中文说明按此前在该线程记录的处置,本条随 N1 一并等待:已发布的
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Re-checked at head Disclosure first: I built and ran nothing this round. No install, no bundle, no The published promises, re-read at head (line numbers moved since the finding was filed; wording did not):
wenshao's measurement of those four lines, on a fresh build of this head: with the same My own reading of the mechanism at head agrees, and it is the same root as N1. The only functions that can send a worker One narrowing, so a rewording does not chase the wrong token. Routing. Not deferred, not out of scope: this is N1's user-visible surface, and N1 is the reason wenshao says "do not merge the stack". His landable path is the route-only split plus the round-9 candidate (+76/−5, which still applies unchanged and still closes R13-4/R4-4), and that split explicitly leaves What I will state plainly: the docs must not keep promising a launch the stack cannot perform. Whichever branch is picked, No code lands this round and nothing is pushed: the PR is |
||
| # See it with: qwen sessions ps | ||
| ``` | ||
|
|
||
| See what it is doing with `qwen sessions peek`, reply to it with `qwen sessions answer`, and end it with `qwen sessions stop`. What is still missing: attaching to a background session's terminal and reading its full transcript. Those land with the Agent View roster. | ||
|
|
||
| #### `qwen sessions ps` | ||
|
|
||
| Lists the interactive Qwen Code sessions running on this machine right | ||
| now. `sessions list` walks saved transcripts ("what have I worked on"); | ||
| this walks the live-process registry ("what is running at this moment"). | ||
| Records left behind by a killed session are swept as they are found. | ||
| Headless sessions (`qwen -p`) do not register with the live-process | ||
| registry, so they are not shown. | ||
| Lists the Qwen Code sessions running on this machine right now. | ||
|
yiliang114 marked this conversation as resolved.
Resolved
|
||
| `sessions list` walks saved transcripts ("what have I worked on"); this | ||
| answers "what is running at this moment". | ||
|
|
||
| Two kinds of session are listed. An **interactive** session is one you | ||
| started in a terminal; it registers in the live-process registry, and | ||
| records left behind by a killed session are swept as they are found. A | ||
| **managed** session is an Agent View session owned by a supervisor: it | ||
| writes no registry record, so it used to be invisible here. Managed | ||
|
yiliang114 marked this conversation as resolved.
Resolved
|
||
| sessions are listed first, because one of them may be waiting for an | ||
| answer. | ||
|
|
||
| Headless sessions (`qwen -p`) register nowhere and are not shown. | ||
|
qwen-code-dev-bot marked this conversation as resolved.
Resolved
qwen-code-dev-bot marked this conversation as resolved.
Resolved
|
||
|
|
||
| **Flags:** | ||
|
|
||
|
|
@@ -767,20 +791,38 @@ registry, so they are not shown. | |
|
|
||
| **Human-readable output (default):** | ||
|
|
||
| A table with columns: NAME, PID, AGE, DIRECTORY. | ||
| A table with columns: NAME, PID, AGE, STATE, DIRECTORY. | ||
|
|
||
| STATE is `interactive` for a session you started yourself. For a managed | ||
| session it is what that session is actually doing — `needs input`, | ||
| `working`, `ready`, `stopped` or `failed`. PID and AGE print `-` for a | ||
| managed session with no process behind it (one that has exited, or has | ||
| not started its worker yet). | ||
|
|
||
| **JSON output (`--json`):** | ||
|
|
||
| Outputs JSON Lines on stdout, newest session first. Each line is a JSON | ||
| object with fields: | ||
| Outputs JSON Lines on stdout, managed sessions first. Every line carries | ||
| a `managed` field saying which kind it is. | ||
|
|
||
| An interactive session is emitted as its whole registry record, plus | ||
| `managed: false`: | ||
|
yiliang114 marked this conversation as resolved.
Resolved
|
||
|
|
||
| ``` | ||
| schemaVersion, pid, procStart, pidNs, sessionId, cwd, name, startedAt, | ||
| qwenVersion | ||
| qwenVersion, managed | ||
| ``` | ||
|
|
||
| A managed session has no such record and is emitted as the row itself: | ||
|
|
||
| ``` | ||
| name, pid, startedAt, cwd, state, sessionId, managed | ||
| ``` | ||
|
|
||
| Nothing else is written to stdout — an empty listing prints nothing at | ||
| all — so `qwen sessions ps --json | jq .` is safe to script against. | ||
| all — so `qwen sessions ps --json | jq .` is safe to script against. If | ||
| the supervisor's own bookkeeping cannot be read, the interactive half is | ||
| still listed and the reason is reported on stderr, which leaves stdout | ||
| parseable. | ||
|
|
||
| JSON output is raw data: field values are emitted exactly as recorded, | ||
| with no terminal sanitization. Treat them as data, and sanitize before | ||
|
|
@@ -796,8 +838,36 @@ qwen sessions ps | |
| # Note: `jq -r` renders the raw recorded value in your terminal (see the | ||
| # raw-data note above); pipe through a sanitizer if the path is untrusted. | ||
| qwen sessions ps --json | jq -r .cwd | ||
|
|
||
| # Which background sessions are waiting on me? | ||
| qwen sessions ps --json | jq -r 'select(.state == "needs input") | .name' | ||
| ``` | ||
|
|
||
| #### `qwen sessions peek|answer|stop <session>` | ||
|
|
||
| A background session started with `--bg` runs with nobody watching it. These three commands are how you catch up with one. Each takes a session id or any unique prefix of one — the short form `qwen sessions ps` and `--bg` print is enough. | ||
|
yiliang114 marked this conversation as resolved.
Resolved
|
||
|
|
||
| `peek` shows what the session is doing, and what it has stopped to ask: | ||
|
|
||
| ```bash | ||
| $ qwen sessions peek 0f8e1c42 | ||
| find out why the release job is flaky [0f8e1c42] | ||
| State: waiting | ||
| Directory: /w/app | ||
| Waiting: permission to write scripts/flake-report.md | ||
|
Comment on lines
+910
to
+912
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Re-checked at head What the page publishes, verbatim at Neither line can render in the shipped CLI:
So a user whose background session really is stuck on a tool approval follows the table at Consistency with the earlier verdict: the No code lands this round: the PR is +3193/-71, 2.1x over patrol's 1500-addition scope fuse, with a maintainer scope ruling pending. Worth saying plainly, though — unlike the other two open Criticals this one is cheap and local: it is a docs-only reword of one transcript in
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Held at Site status at the live head. Re-read at Why it is held. The finding is that nothing in the shipped CLI can write So the correct wording here is decided by the same (a)/(c) ruling: under (a) the transcript becomes accurate once worker reporting ships and only the framing sentence needs adjusting; under (c) the Leaving this thread open until the N1 ruling lands. 中文在 站点状态:在当前 head 上重读, 为什么挂起:finding 说的是——已发布的 CLI 里没有任何位置写入 所以这里的正确措辞由同一个 (a)/(c) 裁决决定:选 (a),等 worker 上报落地后这段转录就准确了,只需调整那句引导语;选 (c),后台会话的 在 N1 裁决落地前保持本线程不 resolve。
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Held for the N1 decision: whether anything ever reports 中文说明随 N1 决定一并等待:是否会有代码上报
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Re-verified at head The site, verbatim (
Producer sweep I ran myself rather than inheriting batch 1's pre-confirmation:
So the shipped build renders The standing ruling is respected, not contradicted: dev-bot's hold of 2026-09-27 ("Held for the N1 decision") and my two earlier replies still describe the situation. Because the receive half is already merged, option (a) needs only a caller — which would make this transcript accurate as written — while option (c) removes the 中文在 head 站点原文: 我自己跑的生产者扫描:四个 sideband 符号在非测试代码里 7 处命中全部位于 维持既有裁决:dev-bot 2026-09-27 的 N1 挂起与我先前两条回复仍然成立。由于接收半边已合并,选 (a) 只差一个调用方,这段转录届时即如实;选 (c) 则文档随 |
||
|
|
||
| Answer it with: qwen sessions answer 0f8e1c42 "<your answer>" | ||
| ``` | ||
|
|
||
| `answer` replies to a session that is waiting, and `stop` ends one, leaving its transcript in place: | ||
|
|
||
| ```bash | ||
| qwen sessions answer 0f8e1c42 "yes, write the report" | ||
| qwen sessions stop 0f8e1c42 | ||
| ``` | ||
|
|
||
| All three talk to a supervisor that is already running and never start one: if none is, they say so rather than spawning a process to report that nothing exists. | ||
|
|
||
| ## 6. Messaging Another Running Session | ||
|
|
||
| Two interactive sessions on the same machine can send each other | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.