Skip to content

fix(agents): preserve background completion across parent turns - #597

Merged
rynfar merged 2 commits into
pylonfrom
fix/native-agent-completion-state
Sep 17, 2026
Merged

rynfar merged 2 commits into
pylonfrom
fix/native-agent-completion-state

Conversation

@rynfar

@rynfar rynfar commented Sep 17, 2026 •

Copy link
Copy Markdown
Collaborator

Native agents stayed marked Working after completing whenever their parent had moved to another turn. Read-only inspection of the reported conversation confirmed Codex emitted canonical idle/completion events with the original spawn-turn ID and correct session incarnation, but ingestion rejected them at the parent-turn admission gate. Both the persisted Agents roster and in-memory sidebar liveness retained running state.

Treat the four task lifecycle event kinds as session-scoped at the parent admission gates, including while the next parent turn is starting. Preserve provider-instance, session-incarnation, Stop, failed-admission and runtime-current fences. Parent output remains turn-scoped and rejected when stale. No provider-specific protocol or wire changes; the common lifecycle path serves all providers and clients over existing transports.

The sidebar also used the parent's latest session timestamp to time Delegating, so each response restarted its clock. Only Working now shows that timer; the helper refuses settled-parent timestamps. No new UI surface or polling.

Validation:

  • 111 focused ingestion tests passed, including completion during ready/running/starting crossed with absent/old admission IDs, both task.updated idle and task.completed, late progress persistence, and stale parent-output rejection.
  • The new regressions fail in all six healthy-session cases against the unpatched implementation; all four provider/incarnation/stopped/failed-admission fence tests still pass.
  • 239 focused sidebar, subagent-fold, and background-liveness tests passed.
  • Server and web typechecks passed; scoped lint/formatting and whitespace checks passed (existing lint warnings remain).
  • Independent adversarial review caught the pending-admission race and a malformed test fixture; both resolved, final review found no blockers. No paid-provider trial or live-data writes.

Recovery limitation: this prevents future completion loss. It does not reconstruct already-discarded events in persisted agent history. Restart clears the in-memory sidebar liveness, but old roster entries require fresh authoritative provider status; the patch does not invent completion or time out legitimate long-running agents.

Implemented with GPT-6 Astra in Codex; independent adversarial review used a built-in agent.


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.

@vercel

vercel Bot commented Sep 17, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
pylon-marketing Ready Ready Preview Sep 17, 2026 5:50pm UTC

@github-actions github-actions Bot added vouch:trusted PR author is trusted by repo permissions or the VOUCHED list. size:S labels Sep 17, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Thread transfer impact

✅ Thread transfer remains within every enforced ceiling.

Provider Metric Main baseline This PR Impact PR ceiling
Codex Total thread wire 13.9 KiB 14.0 KiB +9 B (+0.1%) 15.1 KiB ✅
Codex Thread snapshot wire 7.2 KiB 7.2 KiB 0 B (0.0%) 7.3 KiB ✅
Codex Live turn WebSocket wire 6.7 KiB 6.7 KiB +9 B (+0.1%) 7.8 KiB ✅
Codex Live turn WebSocket decoded 58.0 KiB 58.0 KiB 0 B (0.0%) 66.4 KiB ✅
Codex Live turn messages 9 9 0 (0.0%) 21 ✅
Claude Total thread wire 13.9 KiB 14.0 KiB +35 B (+0.2%) 15.1 KiB ✅
Claude Thread snapshot wire 7.2 KiB 7.2 KiB +10 B (+0.1%) 7.3 KiB ✅
Claude Live turn WebSocket wire 6.7 KiB 6.8 KiB +25 B (+0.4%) 7.8 KiB ✅
Claude Live turn WebSocket decoded 58.9 KiB 58.9 KiB 0 B (0.0%) 66.4 KiB ✅
Claude Live turn messages 9 9 0 (0.0%) 21 ✅

Baseline: 66dc934 · PR result: 2c05062 · Source CI: success

Scenario and decoded snapshot size

10 historical turns, 5 command tools per turn, 878.9 KiB retained MCP result per historical turn, and a 1.05 MiB retained result in the measured turn.

  • Codex decoded thread snapshot: 115.7 KiB
  • Claude decoded thread snapshot: 116.4 KiB

Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed.

@rynfar
rynfar merged commit 629f3ac into pylon Sep 17, 2026
20 checks passed
@rynfar
rynfar deleted the fix/native-agent-completion-state branch September 17, 2026 18:22

This branch was successfully deployed

1 active deployment
Preview — 2c05062c Deployed Sep 17, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:S vouch:trusted PR author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant