Commit ff7e2b0
committed
fix(#245): codex-sdk MCP injection — commhub_send_task + per-node alias
Closes the codex-sdk side of #245 ("新成员都用不了 send_task"). Root cause
locked + verified by 通信龙 + TMCode 负责人 diagnostic (msg 459d1b6c) +
my own audit (cli.ts:1337-1340 had ZERO mcp_servers in CODEX_CONFIG;
createCommhubSdkMcpServer at agent-node/src/cli.ts:1126 is wired ONLY
into the claude-agent-sdk processWithSdk path).
Background
==========
Vincent's "new agents can't use send_task" was: new nodes default to
codex-sdk runtime (per [[feedback_new_node_codex_default]]); codex
inherits MCP servers from `~/.codex/config.toml [mcp_servers.*]`
(TOML — codex does NOT read cwd `.mcp.json`); for months the only
[mcp_servers.commhub-proxy] block was a global stale proxy with a
hardcoded `COMMHUB_ALIAS = "codex-硅谷"` pointing at a separate
proxy script (`proxy/commhub-proxy.ts`) that exposed only 4 tools
(get_task / report_result / get_status / send_message — NO send_task,
NO get_all_status), and that script got rm-rf'd in the 06-16 incident
so codex-sdk nodes started crashing "No such file or directory" on
top of being functionally limited. 通信龙 removed the broken block
this morning (~/.codex/config.toml.bak-20260617-245), exposing the
real underlying gap: agent-node never injected commhub MCP for
codex-sdk in the first place.
Fix (two-package commit)
========================
agent-node/src/cli.ts:
- Replace the bare CODEX_CONFIG constant with `buildCodexConfig(workdir)`
that adds `mcp_servers.commhub = { command: "bun", args: [<cwd>/.anet/node-server.js] }`.
- env intentionally OMITTED from the mcp_servers.commhub block — codex
CLI subprocess inherits this agent-node process's env, which anet's
launchAgent already sets per-node (COMMHUB_ALIAS = displayName,
COMMHUB_TOKEN, COMMHUB_URL). Hard-coding env here would re-introduce
the global-alias bug the 06-17 incident exposed.
- The MCP server points at agent-network's `.anet/node-server.js` (a
bun stdio MCP server bundled in agent-network's dist/), which exposes
the full commhub_send_task / commhub_get_all_status / commhub_get_task
/ commhub_send_message / commhub_send_reply / commhub_report_status /
commhub_get_session_status / commhub_list_tasks set.
agent-network/bin/cli.ts:
- ensureMcpJson runtime gate widened from `claude-code-cli only` to
`claude-code-cli OR codex-sdk`. For codex-sdk the function still
refreshes `.anet/node-server.js` from the npm package + self-heals
`@modelcontextprotocol/sdk` in `.anet/node_modules` + writes
`.anet/.env` (hub URL + token), but SKIPS the `.mcp.json` write
(codex does not read cwd `.mcp.json`; that file would be a silent
no-op + a debugging-trap).
Why this fix is per-node-safe
=============================
`Codex({ config })` (the SDK constructor) accepts the JSON object and
flattens it into `--config key=value` TOML literal overrides on the
codex CLI command line. The override is per-Codex-instance, in-memory,
and does NOT mutate `~/.codex/config.toml`. Two codex-sdk nodes running
simultaneously each get their own codex CLI subprocess with its own
inherited env from its own agent-node parent — so their commhub MCP
servers register against their own per-node alias.
Verified
========
Docker node:24-alpine, fresh `npm i -g @preview` of both packages:
- agent-node v2.4.11-preview.2 installed cleanly ✓
- agent-node bundle markers: `mcp_servers` ×1, `node-server.js` path ×1,
`commhub` ×36 ✓
- agent-network 2.2.14-preview.0 installed cleanly ✓
- agent-network bundle marker: `codex-sdk` ×14 (the new gate
addition + cross-references in existing #237 + #133 code) ✓
- `anet doctor` clean output ✓
Live verification (TMCode 副责人 codex-sdk node restart, agent self-
report) is the next gate before promote latest — fast-follow patch
flow per 通信龙 dispatch 478de9fe.
Co-changes:
- agent-network 2.2.13 → 2.2.14-preview.0
- agent-node 2.4.10 → 2.4.11-preview.2 (.0 and .1 occupied by
prior #211 / #168 shipping cycles)
Branch: fix/245-codex-mcp (forked from fix/245-connectivity-reliability
which carries the just-released 2.2.13 telegram series + bump commit
e409aff)
Refs: #245 (umbrella), 通信龙 dispatches d2814e67 + 7c7c7e1f + 478de9fe
+ 7507d1fb + 71675e69, TMCode 负责人 diagnostic 459d1b6c, agent-node
in-process commhub for claude-agent-sdk at cli.ts:1126
(createCommhubSdkMcpServer), agent-network ensureMcpJson at cli.ts:2233.
Author-Agent: 通信工程马1 parent e409aff commit ff7e2b0
4 files changed
Lines changed: 74 additions & 23 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2231 | 2231 | | |
2232 | 2232 | | |
2233 | 2233 | | |
2234 | | - | |
| 2234 | + | |
| 2235 | + | |
| 2236 | + | |
| 2237 | + | |
| 2238 | + | |
| 2239 | + | |
| 2240 | + | |
| 2241 | + | |
| 2242 | + | |
| 2243 | + | |
| 2244 | + | |
| 2245 | + | |
| 2246 | + | |
| 2247 | + | |
| 2248 | + | |
| 2249 | + | |
| 2250 | + | |
| 2251 | + | |
2235 | 2252 | | |
2236 | 2253 | | |
2237 | 2254 | | |
| |||
2322 | 2339 | | |
2323 | 2340 | | |
2324 | 2341 | | |
2325 | | - | |
2326 | | - | |
2327 | | - | |
2328 | | - | |
2329 | | - | |
2330 | | - | |
2331 | | - | |
2332 | | - | |
2333 | | - | |
2334 | | - | |
2335 | | - | |
| 2342 | + | |
| 2343 | + | |
2336 | 2344 | | |
2337 | 2345 | | |
2338 | 2346 | | |
2339 | 2347 | | |
2340 | 2348 | | |
2341 | 2349 | | |
2342 | | - | |
2343 | | - | |
2344 | | - | |
2345 | | - | |
2346 | | - | |
| 2350 | + | |
| 2351 | + | |
| 2352 | + | |
| 2353 | + | |
| 2354 | + | |
| 2355 | + | |
| 2356 | + | |
| 2357 | + | |
| 2358 | + | |
| 2359 | + | |
| 2360 | + | |
2347 | 2361 | | |
2348 | 2362 | | |
2349 | 2363 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1334 | 1334 | | |
1335 | 1335 | | |
1336 | 1336 | | |
1337 | | - | |
1338 | | - | |
1339 | | - | |
1340 | | - | |
| 1337 | + | |
| 1338 | + | |
| 1339 | + | |
| 1340 | + | |
| 1341 | + | |
| 1342 | + | |
| 1343 | + | |
| 1344 | + | |
| 1345 | + | |
| 1346 | + | |
| 1347 | + | |
| 1348 | + | |
| 1349 | + | |
| 1350 | + | |
| 1351 | + | |
| 1352 | + | |
| 1353 | + | |
| 1354 | + | |
| 1355 | + | |
| 1356 | + | |
| 1357 | + | |
| 1358 | + | |
| 1359 | + | |
| 1360 | + | |
| 1361 | + | |
| 1362 | + | |
| 1363 | + | |
| 1364 | + | |
| 1365 | + | |
| 1366 | + | |
| 1367 | + | |
| 1368 | + | |
| 1369 | + | |
| 1370 | + | |
| 1371 | + | |
| 1372 | + | |
| 1373 | + | |
| 1374 | + | |
| 1375 | + | |
| 1376 | + | |
| 1377 | + | |
1341 | 1378 | | |
1342 | 1379 | | |
1343 | 1380 | | |
| |||
0 commit comments