From b54e334a890e7f9cf0fa770a63b9bed2f28fe753 Mon Sep 17 00:00:00 2001 From: Pavlo Ratushnyi Date: Fri, 13 Nov 2026 01:53:12 +0100 Subject: [PATCH] Orchestrator sub-agent smoke: result page (model spawns two workers, no tool-call defects, queue gain about 1.08x, no-go for the full 6g matrix) Co-Authored-By: Claude Sonnet 5.5 --- .../orchestrator-subagents-smoke.md | 108 ++++++++++++++++++ 1 file changed, 108 insertions(+) create mode 100644 docs/experiments/orchestrator-subagents-smoke.md diff --git a/docs/experiments/orchestrator-subagents-smoke.md b/docs/experiments/orchestrator-subagents-smoke.md new file mode 100644 index 00000000..918d839c --- /dev/null +++ b/docs/experiments/orchestrator-subagents-smoke.md @@ -0,0 +1,108 @@ +# Orchestrator mode with sub-agents: smoke test of Qwen3.5 on Leleka (plan 6g, step P1) + +Question of the owner (2026-11-13): can OUR model (Qwen3.5 MoE IQ3, served by Leleka release 83bdd85bb482) work in the Codex orchestrator mode, i.e. when Codex is told that it +is an orchestrator and spawns sub-agents? In that mode concurrent requests reach Leleka for certain, which is the premise of the multiplexing idea (plan 6g, +`docs/experiments/async-park-compression-and-orchestrator-bench.md` section B). This page is the cheap smoke run that comes before the 3-3.5 GPU-hour matrix of that page. + +Labels: **M** = measured in this run (source named), **C** = read from the Codex binary or its documentation, **E** = estimate by arithmetic from M numbers. + +## 0. Result + +| Question | Answer | +|---|---| +| Does the model orchestrate? | **Yes, on the first try.** In its very first response it wrote one sentence and called `multi_agent_v1.spawn_agent` twice (parallel tool calls), a backend worker and a frontend worker, each with a self-contained 3.6 KB / 3.0 KB specification and the right directory restriction (M, round 1, 8.9 s, 1,849 output tokens). It then used `wait_agent` twice and `close_agent` twice, and did the integration (README, builds, tests) itself. | +| How many sub-agents | 2 (as asked; `agents.max_threads = 3` was the cap). 122 model requests: orchestrator 34, backend worker 69, frontend worker 19. | +| Tool-call integrity | **No defect.** 122 of 122 responses `response.completed`; 161 function calls (155 `exec_command`, 2 `spawn_agent`, 2 `wait_agent`, 2 `close_agent`), every name declared, every `arguments` valid JSON with the required fields and types (checker in `analyze_orchestrator_run.py`); no `generation failed` in `api.log` during the cell; no 429, no timeout. | +| Concurrency at the gateway | Up to **3 requests open at once** (18 s), 2 or more open for **250 s = 32 % of the wall**; 44 of 122 requests overlapped another one in time; the engine had work for 92 % of the wall (M, proxy timestamps). | +| How Leleka's queue handled it | FIFO, one generation at a time, as designed. Queue wait p50 2 ms, p90 5.0 s, max 51 s (sum 268 s); 42 of 122 requests waited more than 1 s, 4 more than 10 s. TTFT p50 0.68 s, p90 6.3 s, max 51.8 s. While both workers were alive each request took 13.0 s instead of 6.1 s (6.5 s queue + 6.5 s service): each session ran at half pace. | +| Cache switch cost | **Negligible.** 48 of 122 requests (39 %) switched the live session; import 29 ms median, 48 ms maximum (1.4 ms without a switch); cached share of the prompt tokens 98.1 %. Expert tier VRAM share 87.6 % on a switch against 90.4 % without (-2.8 points). | +| End result | Codex exit 0 after **791 s**. Acceptance **55/56 strict, 56/56 relaxed** (the gate of the ledger); the one strict failure is the board check that the single-agent cells fail too. | +| Faster than one agent? | **No.** Same boot, same task, single agent: 766 s, 96 requests, 55/56 strict, 56/56 relaxed. Orchestrator 791 s (1.03x slower, inside the run-to-run noise: the stored owner-default single-agent cells of this release took 427 / 539 / 651 s). The orchestrator generated 32 % more tokens (127,288 against 96,647) at the same decode speed (186 and 184 tok/s median), so the engine was simply busier: 724 s against 664 s of engine time. Against the sequential execution of the same 122 requests the overlap is worth about **1.08x** (E, section 5). | +| Go / no-go for the big 6g benchmark | **No-go for the full matrix as designed (3-3.5 GPU-h); the premise is answered.** See section 7. | + +## 1. How Codex 0.163.0 exposes sub-agents + +* **Feature flags (C, `codex features list` on the harness binary):** `multi_agent` is `stable` and **on by default**; `multi_agent_v2` is `stable` and off (the newer tool surface with path addressing, not used here). Because of that every request of this version already carried the `multi_agent_v1` tool namespace (10 KB) in the earlier runs; the model had simply never been asked to use it (`docs/experiments/multiplexing-feasibility.md`: no `multi_agent_v1` call in 750 recorded rounds). +* **Tools (M, tool list of the first request):** namespace `multi_agent_v1` with `spawn_agent` (`message` or `items`, `fork_context`, `model`, `reasoning_effort`), `wait_agent` (`targets` list of agent ids, `timeout_ms` default 30 s, min 10 s, max 1 h; returns when ANY of them reaches a final state), `send_input`, `resume_agent`, `close_agent`. A sub-agent has its own thread id; its tool list has 7 entries against the root's 8, because the whole `multi_agent_v1` namespace is missing (no spawning at depth 1, M). +* **When the model spawns (C, text of the `spawn_agent` description):** "Do not spawn sub-agents unless the user or applicable AGENTS.md/skill instructions explicitly ask for sub-agents, delegation, or parallel agent work." The prompt must ask. The public documentation says the same (spawn on request, "spawn two agents", "one agent per point", then wait and summarise). +* **Config (C, public docs and `--strict-config` on the binary):** `[agents]`: `enabled` (default true), `max_threads` (legacy alias of `max_concurrent_threads_per_session`; concurrent spawned threads), `max_depth` (default 1), `default_subagent_model`, `default_subagent_reasoning_effort`; `features.multi_agent`. This run set `features.multi_agent = true` and `agents.max_threads = 3` through `--config-extra`; `codex --strict-config exec` accepted both. +* **`codex exec` (non-interactive) works (M, step P0 and the run):** the root turn ends when the root model ends it; children run as threads of the same process, each with its own `thread-id` / `session-id` HTTP headers and `x-codex-turn-metadata` (`agent_name` is `/root` in every request of this version, so the thread id, not the name, tells the agents apart). Children's own tool calls are NOT in the root's `codex --json` event stream (38 `command_execution` events against 155 `exec_command` calls); the proxy log and the rollout files are the complete record. +* **Step P0 (CPU only, done):** `mock_subagent_server.py` scripts a root that spawns two children and waits. The real binary fanned out under `codex exec`, both children's requests overlapped for the whole 3-4 s the mock held them, and the spawn results carry `{"agent_id", "nickname"}`. This validated the config keys and the proxy chain before GPU time was spent. + +## 2. The job + +* Queue stub `codex-orchestrator-subagents-smoke-crm-release-83bdd85bb482` (server `~/work/gpu-runs/holder2/jobs/`, inserted into `PRIORITY` directly behind the running CPU-kernel A/B job; backup `PRIORITY.bak-orchestrator-smoke`). Job script `scripts/e2e/codex/orchestrator/orchestrator_smoke_job.sh` (sha256 9a3590bb... pinned in the stub), derived from `cmp_codex_job_profile.sh`: release package, `leleka up --foreground --kar-fd`, shipped configuration, the cell runner `cell.py` of the Codex comparison (logging proxy, temperature 0, real Codex CLI 0.163.0 sha256 399ff69c..., task acceptance). +* **Provenance and configuration proof (M, first lines of `job-LEL.log`):** package `PROVENANCE.json` `git_commit` 83bdd85bb48226a41bcec6034d87e1ea6528b570 equals the tag; tarball sha256 3837a32b... equals the one recorded by the owner-default series; `SHA256SUMS` ok; the line `engine environment:` of `up-foreground.txt` is byte-identical to the owner-default series (`LELEKA_ORIGINAL_SERVE_EXPERT_PER_LAYER=no`, `PCIE_FRAC=0.65`, `SEED=off`, ...) and `leleka.json` has the same sha256 (the job exits 8 before any cell otherwise). Inputs (cell runner, tasks, references) are frozen read-only with `INPUTS.sha256`; the job refuses to start when one differs. +* **Task `nestng-crm-orch`** (built by `make_orchestrator_tasks.py` from the frozen `nestng-crm`; same seed, same acceptance script, so the specification cannot drift): the original prompt cut at its Backend and Frontend sections, inside an orchestrator frame: "You are the orchestrator of a small team of sub-agents ... in your very first response call the spawn_agent tool twice ... each message must contain the full specification of its part ... do not write the backend or the frontend yourself while the sub-agents work; use wait_agent until both have finished; then write README.md and verify the result yourself; do not spawn any other sub-agents." +* Cells in ONE stack start: warm-up `smoke-mini`, orchestrator cell (wall limit 1,500 s), and, because it fitted, the single-agent control (unchanged `nestng-crm`, wall limit 900 s). One repetition each, so everything below is n = 1. +* Recording: the logging proxy of `cell.py`, patched only to add UNIX milliseconds (`t_start_unix_ms`, `t_end_unix_ms`) to every `rounds.jsonl` line (request and response bytes unchanged), so requests can be joined with `requests.log` (queue, TTFT) and `engine-slice.log` (prefix switch, import ms, tier shares). The analysis is `analyze_orchestrator_run.py`. +* Run: 2026-11-13 00:20-00:49 UTC, RTX 5090 server, ready after 118 s, orchestrator cell 791 s, control 766 s. Data: `/data/leleka-e2e/prefill-latency/runs/codex-orchestrator-subagents-smoke-crm-release-83bdd85bb482/` (`LEL//proxy`, `LEL/stack/{requests.log,engine.log,api.log,log-offsets.txt}`, `analysis/{orch,control}.{md,json}`, `analysis/accept/`). + +## 3. Timeline of the orchestrator cell (M) + +| t (s) | Event | +|---:|---| +| 0.0 | Root request 1 (10.6k prompt tokens). | +| 8.9 | Root answers: one message and two `spawn_agent` calls in one response. Both workers start at once. | +| 8.9-29 | The three sessions interleave on the one engine: the root inspects the scaffold (6 requests), the workers start (backend and frontend each begin with a 7.7k / 7.6k-token prompt, below the 8,192-token cache block, so `cached = 0`). | +| 26-81 | The backend worker writes one large file in a single request (10,239 tokens, 54 s). The frontend worker's request 12 arrives behind it and waits **51 s** (first-come-first-served, no preemption). | +| 29-260 | Both workers alive: requests alternate between them, each takes 13 s instead of 6 s. | +| 260 | The frontend worker finishes (19 requests, "Build is green"); root `wait_agent` returns for it. | +| 260-602 | Only the backend worker (and the root's idle `wait_agent`) is active: no queue wait (0 ms), 6.1 s per request. This tail is the critical path. | +| 602-790 | Root closes both workers, writes README.md and verifies everything itself (34 requests in all), including an in-process supertest shim because the sandbox forbids sockets (the same constraint hits the control). | + +The split was unbalanced (backend 602 s of its own session against frontend 260 s) and the root's final verification is serial; both limit what any scheduler could gain on this task. + +Per agent (M): root 34 requests, 30,199 output tokens, 179 s engine time; backend worker 69 / 73,135 / 413 s; frontend worker 19 / 23,954 / 132 s. Engine time in total 724 s of the 790 s span (92 %); the control 664 s of 766 s (87 %). + +## 4. Numbers against the single-agent control (same boot) + +| | Orchestrator | Control (single agent) | +|---|---:|---:| +| Wall (s) | 791 | 766 | +| Model requests | 122 | 96 | +| Output tokens | 127,288 | 96,647 | +| Aggregate output tok/s over the span | 161 | 126 | +| Decode tok/s (median, requests with > 200 tokens) | 186 | 184 | +| Engine busy (prefill + decode ms) | 724 s (92 %) | 664 s (87 %) | +| Time with no request open | 63 s | 100 s | +| Time with 2 / 3 requests open | 232 s / 18 s | 0 / 0 | +| Queue wait p50 / p90 / max | 2 ms / 5.0 s / 51 s | 2 ms / 3 ms / 4 ms | +| TTFT p50 / p90 / max | 0.68 s / 6.3 s / 51.8 s | 0.57 s / 5.8 s / 8.5 s | +| Sessions switched at the prefix store | 48 of 122 | 2 of 96 | +| Import ms on a switch (median / max) | 29 / 48 | 2 / 2 | +| Cached share of prompt tokens | 98.1 % | 90.3 % | +| Acceptance strict / relaxed | 55/56 / 56/56 | 55/56 / 56/56 | + +Reading: the aggregate tok/s (+28 %) is a fuller engine plus more work, not a shorter time to the result. The orchestrator did 32 % more generation than the single agent (three contexts to read, two worker summaries, a full re-verification) and finished in the same time because the engine, not the tool waits, was the limit. The cached-share difference comes from different trajectories (the workers' contexts stay shorter: at most 95k prompt tokens against 140k in the control); it is reported, not interpreted. + +## 5. Aggregate against sequential execution (E) + +Sequential execution of the same 122 requests (one agent after another, engine never shared) would cost the engine time (724 s) plus the tool gaps of a single session. The control shows 766 - 664 = 102 s of gaps for 96 requests = 1.06 s per request; for 122 requests that is 129 s. Sequential wall about 724 + 129 = **853 s** against 790 s measured: **1.08x**, the upper end of the 0.97-1.18x (central 1.03-1.08x) predicted in section B.6 of the 6g analysis. Against the single agent doing the whole task alone (766 s) there is no gain. n = 1 and a wall sd of 21-112 s on 430-650 s mean that an effect of this size is not resolvable by a three-repetition matrix. + +## 6. Failures and oddities + +* **Head-of-line blocking:** one 54-s generation (10k tokens in one tool call) held the other worker for 51 s. FIFO without preemption is the only queueing defect seen, and it is a latency, not a correctness, issue. +* First requests of each worker (prompt below 8,192 tokens) have `cached = 0`; the cache block grid is 8,192 (profile `rtx5090-32g`). Cost: two cold prefills of 7.6-7.7k tokens, 3-7 s. +* A child's tool list differs from the root's (no `multi_agent_v1` namespace), so the root and its children do not share the first prompt bytes (the children's first prompts are 7.6-7.7k tokens, below the 8,192 grid in any case). +* Codex printed `Model metadata for qwen-local not found` (harmless, same in all cells) and rejected one `rm -f /tmp/...` command by its own sandbox policy (once in each cell). Root commands: 38 of 38 exit 0; the workers' commands are not in the event stream; in their last requests 1 non-zero exit (a `git` call, 128). Control: 8 of 77 commands non-zero. +* One `generation failed: reasoning ended without ` was logged by the API during the warm-up cell `smoke-mini` (known pattern, the cell was accepted); none during the two task cells. +* The sandbox blocks sockets: neither the control nor the orchestrator could run `node dist/main.js` + curl; both verified with an in-process harness. +* Run output is 874 MB by `du` (the node_modules are hard links to the shared tree; the new bytes are small). + +## 7. Recommendation for the big 6g benchmark + +1. **The premise holds:** the model orchestrates correctly with Codex 0.163.0 and the gateway/engine path deals with the concurrency without a single protocol or tool-call failure; the cache switch costs 29 ms on average. So the "can it" question is closed, and the earlier fallback (N parallel `codex exec` sessions started by the harness) is not needed. +2. **No-go for the full matrix of B.4-B.7 (3-3.5 GPU-h, arms S1/S2/H2/O x 3 blocks).** The smoke already shows the thing the matrix would measure: with a strictly serial engine at 92 % duty the queue cannot give more than about 1.08x (E) and no gain over one agent; the resolution of n = 3 on this task (wall sd 21-112 s) cannot tell 1.08x from 1.0x. The money would buy the same conclusion with error bars. +3. **What would still be worth a GPU hour:** (a) a balanced split with long tool waits (four equal sub-tasks, builds and test suites in the workers) to see the gamma term of B.6 become large; (b) the real lever, simultaneous decode of two sessions (E 1.0-1.3x at N = 2 per `multiplexing-feasibility.md` 3.2), with this task as its workload; (c) a scheduling fix for the head-of-line case (a long generation delaying another session by 51 s), which affects TTFT p90, not throughput. +4. The harness for any later run exists: `orchestrator_smoke_job.sh` (change the cell list), `make_orchestrator_tasks.py`, `analyze_orchestrator_run.py` (agents, overlap histogram, queue, TTFT, switch cost, integrity check). + +## 8. Files + +* Added: `scripts/e2e/codex/orchestrator/{mock_subagent_server.py, make_orchestrator_tasks.py, setup_orchestrator_inputs.sh, orchestrator_smoke_job.sh, orchestrator_smoke_stub.sh, analyze_orchestrator_run.py}`, this page. +* Server (all under `/data/leleka-e2e/prefill-latency/`): `orchestrator-subagents-smoke/{tools,tasks,reference,INPUTS.sha256,p0}` (frozen inputs and the P0 capture), `runs/codex-orchestrator-subagents-smoke-crm-release-83bdd85bb482/`; the queue stub and the `PRIORITY` backup in `~/work/gpu-runs/holder2/jobs/`. The stack state, package and prefix directories of release 83bdd85bb482 under `codex-compare/ours-*-83bdd85bb482` were reused as the owner-default series left them (the job writes the stack's own logs there). + +## Sources + +* Repo: `docs/experiments/async-park-compression-and-orchestrator-bench.md` (B), `docs/experiments/multiplexing-feasibility.md`, `docs/e2e-run.md` 7, `scripts/e2e/codex/compare/cmp_codex_job.sh` and the server `cmp_codex_job_profile.sh`. +* Public (secondary for this exact version; the tool list, flags and gating text above were read from the 0.163.0 binary and its requests): [Codex subagents documentation](https://learn.chatgpt.com/docs/agent-configuration/subagents) (formerly developers.openai.com/codex/subagents), [Codex multi-agent notes](https://developers.openai.com/codex/multi-agent), third-party notes on `max_threads` / `max_depth` and `multi_agent_v2` at [codex.danielvaughan.com](https://codex.danielvaughan.com/2026/03/26/codex-cli-subagents-toml-parallelism/) and [morphllm.com/codex-multi-agent](https://www.morphllm.com/codex-multi-agent).