Skip to content

[Refactor] Unify agent safety pass lifecycle ownership - #3659

Open
roomote-roomote[bot] wants to merge 1 commit into
developfrom
feature/unify-agent-safety-lifecycle-2xw3mp6uq6get
Open

roomote-roomote[bot] wants to merge 1 commit into
developfrom
feature/unify-agent-safety-lifecycle-2xw3mp6uq6get

Conversation

@roomote-roomote

Copy link
Copy Markdown
Contributor

​Created by Roomote. View the session or mention @roomote-roomote for follow-up asks.

Related issue

Maintenance follow-up to #3658, which added finite agent execution safety limits. No separate issue.

Why this PR exists

  • A maintainer explicitly invited this PR in the linked issue or discussion
  • I am a maintainer / this is internal Roomote work

The worker harness and control-plane prompt runner independently owned pass maps, deadline sweeps, event counting, stop latches and settlement cleanup. Consolidating that lifecycle makes policy differences explicit and avoids maintaining the same safety orchestration twice.

What changed

  • Add a worker-safe AgentSafetyLifecycle alongside the existing per-pass counter. It owns pass creation, normalized tool/message counting, deadlines (including pending child spawns), settlement tombstones, one-shot stop claims and disposal.
  • Use the owner in both runtimes and route bulk worker watchdog cleanup through its existing single-watchdog teardown path. Cancellation transport, durable persistence, prompt rejection and transcript notices remain runtime adapters.
  • Preserve the worker root's exemption from child step/wall caps, background work surviving parent turn completion, recursive descendants and explicit resumed child spawns. Native control-plane sessions retain activity-based child resumption after idle, bounded root passes and their existing shorter prompt timeouts.

There is no intended user-facing behavior change. This reduces independent lifecycle ownership without changing durable request admission, safety notice text or error classification.

How it was tested

293 focused tests passed:

  • @roomote/types: safety counter and new lifecycle suites — 14 tests covering deduplication, sibling and pending-spawn deadlines, root policies, late events, explicit/native resumption, one-shot stops and disposal.
  • @roomote/worker: subagent watchdog suite — 59 tests, including new cancellation/disposal deadline cleanup and fresh safety accounting for a resumed child.
  • @roomote/worker: harness and stall-watchdog suites — 96 tests.
  • @roomote/cloud-agents: non-task provider usage suite — 124 tests, including replayed completions, resumed child sessions and failed persistence/abort adapters.

Affected package typechecks and the normal pre-push gates (oxlint, worker/web ESLint, repository-wide fast typechecks and knip) passed. Changed files were formatted by the commit hook. The formatting-inclusive pnpm lint / pnpm check-types commands were not run separately. Browser proof is not applicable to this in-memory lifecycle refactor.

Checklist

  • The PR title follows the repo convention: [Fix], [Feat], [Improve], [Refactor], [Docs], or [Chore] followed by a user-facing description
  • This PR is small and scoped to one change
  • pnpm lint and pnpm check-types pass locally
  • I added tests or included a clear manual validation note above
  • I removed secrets, tokens, private keys, and customer data from code, logs, and screenshots
  • If this change should appear in the changelog, I ran pnpm changeset

No changeset: internal behavior-preserving refactor.

@roomote-community

roomote-community Bot commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

No code issues found. See session

Reviewed 9e11006

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant