Skip to content

refactor(tasks): simplify subagent activity tracking - #122198

Merged
steipete merged 3 commits into
mainfrom
steipete/subagent-activity-simplify
Aug 11, 2026
Merged

steipete merged 3 commits into
mainfrom
steipete/subagent-activity-simplify

Conversation

@steipete

@steipete steipete commented Aug 11, 2026 •

Copy link
Copy Markdown
Contributor

Related: #121528, #121549, #121840, #121815, #121813, #121899

What Problem This Solves

The subagent-activity series left file-mutation argument decoding and line accounting split between the live agent stream and the task-registry fold. The same write/edit/patch/Codex shapes therefore had two owners, while the shared Apple activity model retained three fields no state transition or renderer consumed. Android terminal activity expiry also mixed a captured event clock with a later wall-clock read inside its coroutine, allowing the deterministic 59,999ms retention boundary to expire early.

This is the maintainer-requested post-series consolidation for #121528, #121549, #121840, #121815, #121813, and #121899.

Why This Change Was Made

One concept-named file-mutation argument owner now handles write content, edit pairs, apply-patch text, and normalized Codex changes[].stat input. It exposes two deliberately separate counting contracts: streaming counts only completed newline delimiters over partial JSON, while the task fold counts complete logical lines. This preserves the existing monotonic streaming and completed-argument semantics without parallel shape readers.

The Apple activity state also drops unused startedAt, endedAt, and childSessionKey storage. The web terminal-observation map/timer and the Apple event-vs-snapshot source distinction remain unchanged after review: both preserve first-observation retention semantics and are not redundant.

Android now derives both the terminal expiry deadline and coroutine delay from the event's single captured clock value. The existing 59,999ms/60,000ms boundary regression remains unchanged. The native source inventory was refreshed only for the resulting one-line source shift.

The Codex file-change contract was checked directly against openai/codex app-server protocol sources: codex-rs/app-server-protocol/src/protocol/v2/item.rs and codex-rs/app-server-protocol/src/protocol/item_builders.rs.

Production LOC: +167/-180 (net -13) | Tests: +0/-0 | Generated native inventory: +2/-2

User Impact

No API, broadcast, ordering, or presentation changes. Android terminal activity now reliably retains for the intended full 60 seconds instead of occasionally expiring a few milliseconds early under coroutine scheduling delay.

AI-assisted: yes. The change was maintainer-directed, source-audited, and verified with the repository's Codex autoreview workflow.

Evidence

  • node scripts/run-vitest.mjs src/agents/embedded-agent-live-edit-diff.test.ts src/tasks/task-registry.test.ts src/gateway/server-methods/tasks.test.ts
    • Passed exact-head: 17 Gateway task tests, 123 task-registry tests, and 2 embedded-agent streaming-diff tests.
  • swift test --package-path apps/shared/OpenClawKit
    • Passed exact-head: 1,338 Swift Testing cases plus the package XCTest/native-state suites.
  • node scripts/check-changed.mjs
    • Passed formatting, core/test typechecks, Knip production/full-tree scans, core and Swift lint, Plugin SDK contracts, import-cycle, storage/schema, and macOS CI test lanes. The preferred remote backend was unavailable, so the repository wrapper completed through its documented local fallback.
  • node --import tsx scripts/native-app-i18n.ts verify
    • Passed after the generated inventory updated two existing ChatController.kt line numbers by +1 with no string changes.
  • .agents/skills/autoreview/scripts/autoreview --mode branch --base origin/main --stream-engine-output
    • Final full-branch review clean: no accepted/actionable findings (0.98 confidence).
  • Exact-head CI run 31523454254
    • Green on dbd065c8b5cccd8fa710264ef3a2aa449e161ff9, including android-test-play, native-i18n, macOS/iOS, and Periphery lanes; no rerun required.
  • git diff --check origin/main...HEAD
    • Clean.

@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 18:17
@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: M maintainer Maintainer-authored PR labels Aug 11, 2026
@openclaw-barnacle openclaw-barnacle Bot added the app: android App: android label Aug 11, 2026
@clawsweeper clawsweeper Bot added P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Aug 11, 2026
@clawsweeper

clawsweeper Bot commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 11, 2026, 3:05 PM ET / 19:05 UTC.

ClawSweeper review

What this changes

The PR centralizes file-mutation argument parsing and line counting for live agent progress and task activity, removes unused Apple activity fields, and makes Android terminal-row expiry use the event-time clock.

Merge readiness

⚠️ Ready for maintainer review - 3 items remain

Keep open for explicit maintainer handling: current main still has the duplicated parsing ownership, and the refactor is coherent with no discrete patch defect found; the protected maintainer label and unavailable direct Codex contract checkout prevent a merge-ready verdict here.

Priority: P3
Reviewed head: dbd065c8b5cccd8fa710264ef3a2aa449e161ff9
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The patch is a focused net-negative consolidation with existing owner-boundary coverage, pending only the maintainer-side Codex contract check.
Proof confidence 🌊 off-meta tidepool Not applicable: Not applicable to this maintainer-requested, non-user-visible refactor; the supplied focused test results are supplemental validation.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: Not applicable to this maintainer-requested, non-user-visible refactor; the supplied focused test results are supplemental validation.
Evidence reviewed 5 items Duplicated owner on current main: Current main separately owns streaming newline counts and completed task-fold deltas; the PR replaces both with a shared helper while preserving their deliberately different contracts.
Caller and existing behavioral coverage: The task fold calls the completed-argument helper only for recognized mutation tools; existing tests cover streamed edit/write/patch counters and Codex-style changes with stats.
Codex dependency signal and review gap: The Codex projector supplies normalized file-change changes and stats to the shared task path, so this PR’s Codex-shape preservation depends on the app-server contract; the required sibling ../codex checkout is absent in this read-only, offline environment.
Findings None None.
Security None None.

How this fits together

Model and Codex tool events feed live edit counters and the task registry’s ephemeral subagent-activity overlay, which Gateway clients render in web and native chat. The PR moves equivalent argument-shape handling into one shared agent helper while retaining separate streaming and completed-tool counting semantics.

flowchart LR
  A[Model and Codex tool events] --> B[Live edit progress counter]
  A --> C[File-mutation argument helper]
  C --> D[Task activity fold]
  B --> E[Agent event stream]
  E --> D
  D --> F[Gateway task events]
  F --> G[Web and native chat activity rows]
Loading

Decision needed

Question Recommendation
Should this protected maintainer refactor land after direct verification of the Codex app-server file-change contract in a checkout containing ../codex? Verify then land: Inspect the Codex app-server item contract and land if its file-change changes/stat shape matches the preserved helper boundary.

Why: The changed helper preserves a dependency-backed Codex shape, and repository policy requires the acting reviewer to inspect that sibling source before a merge-ready verdict.

Before merge

  • Resolve merge risk (P1) - The shared helper preserves Codex file-change statistics, but direct verification against the required sibling Codex app-server source must occur in a maintainer environment before merge because that checkout is unavailable here.
  • Complete next step (P2) - No repair job is appropriate: the protected maintainer item has no mechanical defect, and the remaining action is direct dependency verification plus maintainer judgment.
Agent review details

Security

None.

PR surface

Source -5, Other -8. Total -13 across 6 files.

View PR surface stats
Area Files Added Removed Net
Source 3 163 168 -5
Tests 0 0 0 0
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 3 6 14 -8
Total 6 169 182 -13

Review metrics

Metric Value Why it matters
Production versus test delta production +167/-180 (net -13); tests 0; generated i18n +2/-2 The net production reduction supports the stated consolidation; no test contracts were changed.

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    Land one shared file-mutation argument owner only after directly verifying the Codex file-change contract, retaining the separate streaming-newline and completed-logical-line semantics.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Technical review

Best possible solution:

Land one shared file-mutation argument owner only after directly verifying the Codex file-change contract, retaining the separate streaming-newline and completed-logical-line semantics.

Do we have a high-confidence way to reproduce the issue?

Not applicable: this PR reports duplicated internal ownership rather than a user-facing failure; source inspection shows the current duplicated parser boundary.

Is this the best way to solve the issue?

Yes, conditionally: one shared helper is the cleaner owner boundary than parallel shape readers, provided the direct Codex contract check confirms the preserved normalization shape.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against d76f71cee7d2.

Labels

Label changes:

  • add P3: This is a maintainer-directed internal consolidation with no intended user-visible behavior change.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: Not applicable to this maintainer-requested, non-user-visible refactor; the supplied focused test results are supplemental validation.

Label justifications:

  • P3: This is a maintainer-directed internal consolidation with no intended user-visible behavior change.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: Not applicable to this maintainer-requested, non-user-visible refactor; the supplied focused test results are supplemental validation.

Evidence

What I checked:

  • Duplicated owner on current main: Current main separately owns streaming newline counts and completed task-fold deltas; the PR replaces both with a shared helper while preserving their deliberately different contracts. (src/agents/file-mutation-args.ts:35, dbd065c8b5cc)
  • Caller and existing behavioral coverage: The task fold calls the completed-argument helper only for recognized mutation tools; existing tests cover streamed edit/write/patch counters and Codex-style changes with stats. (src/tasks/task-registry-activity.ts:134, 79701dfc84f9)
  • Codex dependency signal and review gap: The Codex projector supplies normalized file-change changes and stats to the shared task path, so this PR’s Codex-shape preservation depends on the app-server contract; the required sibling ../codex checkout is absent in this read-only, offline environment. (extensions/codex/src/app-server/event-projector-tool-items.ts:69, 79701dfc84f9)
  • Feature-history ownership: Blame assigns the pre-refactor parser and activity implementation to Peter Steinberger, and the merged subagent-activity series commits were authored by the same contributor. (src/tasks/task-registry-activity.ts:96, a496fd148ede)
  • Current-main status: The PR head is not an ancestor of current main, and the same six paths still differ from current main; this cleanup is not already implemented. (src/agents/embedded-agent-live-edit-diff.ts:1, dbd065c8b5cc)

Likely related people:

  • steipete: Blame and the merged subagent-activity series associate this contributor with the existing stream counter, task fold, Codex activity path, and native presentations. (role: feature owner and recent refactor author; confidence: high; commits: b985d5a1edad, e6b356f35ada, 8c3c8a2ab08b; files: src/agents/embedded-agent-live-edit-diff.ts, src/tasks/task-registry-activity.ts, apps/android/app/src/main/java/ai/openclaw/app/chat/ChatController.kt)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Inspect the relevant ../codex app-server file-change contract and record the result before landing.

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

@steipete
steipete merged commit 73ae583 into main Aug 11, 2026
137 checks passed
@steipete
steipete deleted the steipete/subagent-activity-simplify branch August 11, 2026 19:30
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling app: android App: android maintainer Maintainer-authored PR P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: M status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant