Skip to content

fix(subagents): report startup and completion lifecycle edges#77415

Closed
neilofneils404 wants to merge 4 commits into
openclaw:mainfrom
neilofneils404:cass/subagent-lifecycle-fixes-20260504
Closed

fix(subagents): report startup and completion lifecycle edges#77415
neilofneils404 wants to merge 4 commits into
openclaw:mainfrom
neilofneils404:cass/subagent-lifecycle-fixes-20260504

Conversation

@neilofneils404

@neilofneils404 neilofneils404 commented May 4, 2026

Copy link
Copy Markdown
Contributor

Summary

  • tighten subagent completion announce cleanup so late completion paths do not race cleanup
  • emit first-progress/startup-failed lifecycle signals for embedded subagent startup
  • cover startup failure/progress paths in subagent lifecycle and PI embedded tests

Validation

  • pnpm check:no-conflict-markers
  • node scripts/run-vitest.mjs run --config test/vitest/vitest.agents.config.ts src/agents/subagent-announce.test.ts src/agents/subagent-registry-lifecycle.test.ts
  • node scripts/run-vitest.mjs run --config test/vitest/vitest.agents-pi-embedded.config.ts src/agents/pi-embedded-subscribe.handlers.lifecycle.test.ts src/agents/pi-embedded-subscribe.handlers.tools.test.ts src/agents/subagent-registry.test.ts

Real behavior proof

  • Behavior or issue addressed: Gateway agent waits now preserve a startup-failed phase even when a trailing completion/end edge arrives, so callers can observe the startup failure instead of it being overwritten by a generic end state.

  • Real environment tested: Local OpenClaw checkout on SpicyTaco (macOS/Darwin), PR branch cass/subagent-lifecycle-fixes-20260504 at 83aefea574 after rebase onto origin/main d38e30e02c.

  • Exact steps or command run after this patch: node scripts/run-vitest.mjs run --config test/vitest/vitest.gateway.config.ts src/gateway/server-methods/server-methods.test.ts

  • Evidence after fix: Terminal capture from the local OpenClaw checkout after the fix:

    83aefea574 fix(gateway): preserve startup-failed agent waits
    RUN v4.1.5 /private/tmp/openclaw-pr77415
    ✓ gateway src/gateway/server-methods/server-methods.test.ts (82 tests) 245ms
    Test Files  1 passed (1)
    Tests       82 passed (82)
    Duration    5.17s
    
  • Observed result after fix: The focused gateway method regression suite passes on the patched branch, including the startup-failed lifecycle regression coverage added for this behavior.

  • What was not tested: I did not force a live production Gateway subagent startup failure; the after-fix behavior was verified in the local OpenClaw gateway method harness with terminal output above.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation gateway Gateway runtime agents Agent runtime and tooling size: M labels May 4, 2026
@clawsweeper

clawsweeper Bot commented May 4, 2026

Copy link
Copy Markdown
Contributor

Thanks for the context here. I swept through the related work, and this is now duplicate or superseded.

Close as duplicate/superseded: the remaining startup lifecycle work is already tracked by #58776, while this PR is no longer a safe landing branch because it is conflicting and still targets retired pi-embedded files instead of current embedded-agent runtime files.

Root-cause cluster
Relationship: fixed_by_candidate
Canonical: #58776
Summary: This PR is an obsolete candidate branch for the canonical subagent startup lifecycle-silence issue; related cleanup and sandbox reports overlap but do not safely replace the canonical issue.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Canonical path: Close this stale branch and keep #58776 as the canonical work item for a fresh current-main implementation of the lifecycle contract.

So I’m closing this here and keeping the remaining discussion on #58776.

Review details

Best possible solution:

Close this stale branch and keep #58776 as the canonical work item for a fresh current-main implementation of the lifecycle contract.

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

Yes, at source level. Current main lacks the requested phases, active consumers still handle only existing lifecycle states, and aborted terminal events still flow through timeout/killed paths instead of a typed startup-failure signal.

Is this the best way to solve the issue?

No, not as submitted. The lifecycle direction is plausible, but this stale PR targets retired files and should be replaced by a current-main implementation through the active embedded-agent, terminal outcome, gateway, session, SDK, and subagent surfaces.

Security review:

Security review cleared: No concrete security or supply-chain concern was found; the diff changes in-repo lifecycle logic, tests, docs, and changelog text only.

AGENTS.md: found and applied where relevant.

What I checked:

  • Repository policy read: Root and scoped AGENTS.md files were read; the review applied the OpenClaw guidance to inspect whole agent/gateway lifecycle surfaces and treat lifecycle/session/message changes as compatibility-sensitive. (AGENTS.md:1, 5361e5a0b455)
  • Current main lacks the requested lifecycle phases: Current main search found no active first-progress implementation and only an unrelated managed-service startup-failed string, so the useful behavior is not implemented on main. (src/agents/provider-local-service.ts:147, 5361e5a0b455)
  • Active embedded lifecycle is still start/end/error-oriented: The active embedded-agent subscribe lifecycle emits start and terminal finishing/error/end; there is no first-progress/startup-failed branch in the current runtime handler. (src/agents/embedded-agent-subscribe.handlers.lifecycle.ts:187, 5361e5a0b455)
  • Current consumers still ignore unknown phases: The subagent registry returns for lifecycle phases other than start, end, and error, and aborted terminal events still enter timeout or killed handling rather than a typed startup-failure path. (src/agents/subagent-registry.ts:1092, 5361e5a0b455)
  • Gateway wait/session projections are not updated on main: Current gateway agent wait snapshots accept only end | error, and session lifecycle projection recognizes only start, end, and error. (src/gateway/server-methods/agent-job.ts:218, 5361e5a0b455)
  • PR targets retired runtime filenames: The PR adds and modifies pi-embedded-subscribe* files, while current main has only embedded-agent-subscribe* files for this runtime surface. (src/agents/pi-embedded-subscribe.lifecycle-progress.ts:1, 83aefea57419)

Likely related people:

  • steipete: Authored prior subagent lifecycle stabilization and the split that established the current subagent registry lifecycle module. (role: subagent lifecycle and terminal outcome contributor; confidence: high; commits: d6bb36730b50, f862685ed8e4; files: src/agents/subagent-announce.ts, src/agents/subagent-registry-lifecycle.ts, src/agents/subagent-registry.ts)
  • vincentkoc: Recent commits touched embedded terminal abort lifecycle metadata and the shared gateway agent-run snapshot shape used by this lifecycle contract. (role: recent adjacent lifecycle contributor; confidence: high; commits: 0a08625d795f, bb673f47b207; files: src/agents/embedded-agent-subscribe.handlers.lifecycle.ts, src/agents/embedded-agent-subscribe.handlers.types.ts, src/gateway/server-methods/agent-job.ts)
  • ooiuuii: Recent merged work changed restart terminal precedence across embedded lifecycle, SDK normalization, gateway wait, and subagent registry surfaces. (role: recent restart lifecycle contributor; confidence: medium; commits: d20fdf3b3842; files: src/agents/agent-run-terminal-outcome.ts, src/agents/embedded-agent-subscribe.handlers.lifecycle.ts, src/agents/subagent-registry.ts)
  • Feelw00: Authored the merged subagent browser cleanup dedupe change that any refresh of this PR's cleanup ordering would need to preserve. (role: adjacent subagent cleanup contributor; confidence: medium; commits: a9a86f788b08; files: src/agents/subagent-registry-lifecycle.ts, src/agents/subagent-registry-run-manager.ts, src/agents/subagent-registry.types.ts)

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

@neilofneils404
neilofneils404 force-pushed the cass/subagent-lifecycle-fixes-20260504 branch from 98ed21d to 4e27a08 Compare May 4, 2026 17:33
@openclaw-barnacle openclaw-barnacle Bot added size: L triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup. and removed size: M triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup. labels May 5, 2026
(cherry picked from commit d6624ba17c7301b5784b730ddd80030720091fab)
(cherry picked from commit 2969df1)
(cherry picked from commit 77d4777f9975e1db692ad35a5ed181907495ba8f)
(cherry picked from commit 73dd5a227be8e63968755e25b162c067dd611e0e)
@openclaw-barnacle

Copy link
Copy Markdown

This pull request has been automatically marked as stale due to inactivity.
Please add updates or it will be closed.

@openclaw-barnacle openclaw-barnacle Bot added stale Marked as stale due to inactivity proof: supplied External PR includes structured after-fix real behavior proof. labels May 31, 2026
@clawsweeper clawsweeper Bot added the rating: 🌊 off-meta tidepool PR readiness rating does not apply to this item. label May 31, 2026
@barnacle-openclaw barnacle-openclaw Bot removed the stale Marked as stale due to inactivity label May 31, 2026
@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P1 High-priority user-facing bug, regression, or broken workflow. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. and removed rating: 🌊 off-meta tidepool PR readiness rating does not apply to this item. labels Jun 14, 2026
@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Jun 15, 2026
@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Jun 21, 2026
@steipete steipete closed this Jul 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling docs Improvements or additions to documentation gateway Gateway runtime merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. P1 High-priority user-facing bug, regression, or broken workflow. proof: supplied External PR includes structured after-fix real behavior proof. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: L status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants