You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 84a49b2
Browse filesBrowse the repository at this point in the historyBrowse files
fix: restore subagent resume after restart and harden web open, telemetry, and journal paths (#296)
## Summary
- What changed and why: four reconciliation fixes from the September
reference pass, adapted to local architecture:
1. **Subagent resume after restart** — `Agent(resume=<id>)` now rebuilds
a persisted subagent from session metadata when it is not live in the
current process, instead of failing with "does not exist". The rebuilt
subagent syncs to the caller's current permission mode (unless
tower-pinned) and approval rules match its persisted profile label.
2. **Ambient telemetry model context** — the bound model alias is
written into the ambient telemetry context (and restored after a cold
resume), so `pfc_*` events carry `model` alongside
`provider_type`/`protocol`.
3. **Gateway journal close** — the session event broadcaster drains
in-flight state creations on close, skips global-state creation when
closed, and the event journal ignores appends after close, so no journal
writes land after server shutdown.
4. **Web auto-open on wildcard binds** — `--open` now rewrites a
wildcard bind origin (`0.0.0.0` / `::`) to `localhost` for the browser,
and the ready banner parses the port without `new URL` (which throws on
`::`).
- User-visible behavior: resuming a subagent by id works across process
restarts; telemetry events gain the model field; no stray journal writes
after gateway shutdown; browser opens a navigable localhost URL on
wildcard binds.
- Scope deliberately excluded: remaining September reference items
(loop-machine batch, file history, staleGuard removal, survey, web
reconstruction, docs restructure, flag graduation) — tracked separately.
## Risk
- Risk level and affected boundaries: low. Engine subagent lifecycle
(resume path only — spawn/fork untouched), telemetry context payload
(additive field), gateway WS event journal (shutdown path), CLI web
auto-open (open path only).
- Failure, security, data, concurrency, dependency, and lifecycle
considerations: resume validates ownership and subagent type before
rebuild and keeps the running-state guard; journal close now awaits
pending state creations (bounded by existing pending map); no new
dependencies; lifecycle impact is the fix itself (post-close writes
eliminated).
- New dependency or telemetry approval, if applicable: none; telemetry
change is additive to existing payloads and preserves the `pfc_`
contract.
## Verification
- Exact commands and outcomes: `pnpm run build` 0 · `pnpm run typecheck`
0 · `pnpm run lint` 0 errors (3271 pre-existing warnings) · `pnpm run
sherif` 0 · `pnpm test` 21,381 passed, 8 load-flake failures each re-run
green in isolation (5s timeouts, one ENOTEMPTY teardown, one 120s perf
baseline) · `pnpm -C apps/vscode run typecheck` 0 · `pnpm -C apps/vscode
test` 0 · `nix build .#pythinker-code` 0 · `node
scripts/check-nix-workspace.mjs` 0 · targeted suites: agent-core-v2
lifecycle/tool 170, telemetry-affected 364, gateway broadcaster/journal
98, web CLI 68 — all green.
- Tests added or updated: 6 subagent rebuild/sync tests, 2 lifecycle
metadata tests, 3 ambient-model tests, 3 journal-close tests, 5 web-open
tests; exact telemetry payload assertions updated for the new `model`
field.
- Checks not run, warnings, or limitations: lint warnings are the
pre-existing baseline; mutation checks run on the three new guards
(permission-mode sync, rebuild path, journal close guard) — each kills
its test.
## Rollback and review
- Rollback path: revert the four commits; no schema, wire, or
config-format changes.
- Residual risk: rebuilt subagents start from persisted metadata + wire
replay, identical to fresh process startup; cold-resume telemetry
restore covered by test.
- Human review required: normal review; changesets included for the
three user-perceivable changes.
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit
- **Bug Fixes**
- Subagents can be resumed after reopening a session or starting a new
process, with labels, profiles, and permission settings restored.
- The Web UI opens at `localhost` instead of a wildcard network address,
with improved IPv6 URL handling.
- Telemetry includes the selected model, including after session
restoration.
- Session event handling is more reliable during shutdown, preventing
late events from recreating closed journals.
- **Tests**
- Added coverage for subagent recovery, model telemetry persistence, Web
UI URLs, IPv6 handling, and session event shutdown behavior.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
0 commit comments