Skip to content

fix(tasks): stream Codex subagent activity - #121899

Merged
steipete merged 2 commits into
mainfrom
steipete/subagent-activity-acp-runtime
Aug 11, 2026
Merged

steipete merged 2 commits into
mainfrom
steipete/subagent-activity-acp-runtime

Conversation

@steipete

@steipete steipete commented Aug 11, 2026 •

Copy link
Copy Markdown
Contributor

Related: #121549

What Problem This Solves

Fixes an issue where task rows for Codex/ACP native subagents stayed at bare lifecycle status while the child was actively producing assistant text and tool calls. The task registry keyed those rows as codex-thread:<childThreadId>, but the child activity never reached the global agent-event fold under that identity, so lastActivity, diffStat, toolUseCount, and lastToolName remained empty.

The same live probe also exposed two adjacent task-stream defects: identical summaries could be broadcast repeatedly during one burst, and an ordinary host-owned subagent run could receive both its authoritative subagent row and a redundant gateway cli row for the same run.

Why This Change Was Made

The Codex native-subagent monitor is the gateway boundary that observes child-thread app-server notifications. It now projects child assistant, reasoning-summary, and normalized tool events onto the existing global agent bus using the task's canonical codex-thread:<childThreadId> run ID. The existing task-registry activity fold remains the only overlay owner; it additionally accepts Codex's normalized fileChange change/stat arguments while preserving the existing success-gated pending/result accounting, one-second throttle, overlay-only storage, and terminal flush/clear semantics.

Task broadcasts now suppress only identical consecutive mapped summaries per task. Status changes remain immediate because status is part of the mapped summary. Gateway task tracking also consults the already-recorded run fact before creating a CLI row: when the same run ID and child session already own a subagent task, the redundant CLI producer stays off. Standalone CLI, ACP manual-spawn, and plugin-subagent tracking remain unchanged.

No protocol, UI, SQLite schema, or persistence shape changed.

Codex dependency contract checked

Personally inspected sibling openai/codex at c2bcb9a26b5bdbdc66c48cf3bc3bb382568e800c:

  • codex-rs/app-server-protocol/src/protocol/v2/item.rs:1242-1252,1316-1346 defines item/started, item/completed, and item/agentMessage/delta with the authoritative thread_id.
  • codex-rs/app-server-protocol/src/protocol/event_mapping.rs:362-418,428-463 preserves that thread ID while mapping assistant deltas, generic item lifecycle, command starts, and command completions into app-server notifications.
  • On the OpenClaw side, the ordinary per-attempt projector filters to one exact thread/turn and stamps the outer harness run ID, while the client-wide native-subagent monitor is the component that receives child-thread notifications. That proves the monitor is the producer boundary for the missing child activity; there is no alternate child run ID to adopt or dual-index.

Sibling coverage

  • Cron task rows pass their task-run ID into agent execution, so embedded and Codex harness events already share the same fold key.
  • Detached media and background-exec rows represent one non-agent operation and do not emit nested agent tool streams under their task IDs; toolUseCount is not an equivalent contract for those records.

User Impact

Clients receive one enriched task row for Codex native subagents, with live activity text, file-change totals, and tool metadata matching embedded subagents. Rapid no-op updates no longer produce identical task-event bursts, and ordinary subagent runs no longer appear twice as subagent plus cli.

ClawSweeper rank-up moves

  • No moves published. The latest exact-head ClawSweeper comment remains the review started placeholder for 5616934f857a22151bcc40d9b78a0b631d38fee3, with no findings or Rank-up moves: list. There is therefore nothing to apply or skip; the maintainer approved this landing, and the queued review publisher is non-blocking under repository policy.

Evidence

  • Maintainer live pre-fix evidence: a dev gateway emitted running -> completed for a codex-thread:* task with no activity/tool enrichment; rapid tool bursts produced roughly 14 identical task summaries in one second; each ordinary subagent run produced matching subagent and cli rows.
  • Negative control: removing the new native-monitor handoff makes publishes child assistant and tool activity under the mirrored thread run id fail with an empty event list; restoring it passes.
  • Exact rebased subagent head: node scripts/run-vitest.mjs src/tasks/task-registry.test.ts src/gateway/server-runtime-subscriptions.test.ts src/gateway/server-methods/agent.test.ts extensions/codex/src/app-server/native-subagent-monitor.test.ts --testNamePattern "folds Codex native child activity|publishes child assistant and tool activity|suppresses identical task summaries|keeps a host-owned subagent run" — 4 files passed, 4 selected tests passed.
  • Final rebased-head sanity covered the four task regressions, the task access boundary, and main's repaired poll suites: 7 files passed, 16 selected tests passed.
  • Additional focused proof covered the existing one-minute durable-liveness bound, existing tool counting, task activity throttle/terminal flush, and streamed native-child completion paths.
  • node scripts/check-changed.mjs — passed the complete core/extension plan locally after configured remote providers reported unavailable: formatting, Plugin SDK closure, dead exports, production/test typechecks, lint, database-first, sidecar, import-cycle, webhook, and pairing guards.
  • Codex-backed autoreview — clean, no accepted/actionable findings.

Production LOC: +157/-35 (net +122) | Tests: +212/-0

The production growth establishes the missing native-child event producer, reuses the canonical Codex tool normalization, adds normalized file-change folding, suppresses identical wire summaries, and removes redundant CLI bookkeeping. Live post-change verification on a dev gateway remains the maintainer follow-up for this investigation.

@clawsweeper

clawsweeper Bot commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@steipete
steipete marked this pull request as ready for review August 11, 2026 06:28
@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime extensions: codex size: M maintainer Maintainer-authored PR labels Aug 11, 2026
@steipete
steipete force-pushed the steipete/subagent-activity-acp-runtime branch from 4cae7e9 to 5616934 Compare August 11, 2026 07:07
@steipete
steipete merged commit e6b356f into main Aug 11, 2026
198 of 200 checks passed
@steipete
steipete deleted the steipete/subagent-activity-acp-runtime branch August 11, 2026 07:32
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 12, 2026
* fix(tasks): stream Codex subagent activity

* fix(tasks): honor registry access boundary
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

extensions: codex gateway Gateway runtime maintainer Maintainer-authored PR size: M

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant