Skip to content

feat(runtime): restore checklist and inspect delegate traces - #1584

Closed
AuhNijGnahz wants to merge 1 commit into
vastsa:mainfrom
AuhNijGnahz:codex/collaboration-context
Closed

AuhNijGnahz wants to merge 1 commit into
vastsa:mainfrom
AuhNijGnahz:codex/collaboration-context

Conversation

@AuhNijGnahz

Copy link
Copy Markdown
Contributor

Restoring a session or compacting its context can leave the model without the current Host-owned Todo checklist. The parent also receives only a delegate's final report, so it cannot selectively reuse that delegate's recorded intermediate evidence.

This change restores a bounded checklist snapshot before request budget checks and keeps it in an independent chronological system section. Updates, empty revisions, read failures, restart, compaction and temporary recovery prompts preserve current state without duplicating checklist text. Host storage and existing mode/permission rules remain authoritative.

TaskList() keeps its existing status response. Optional delegationId, literal query, after and limit inspect a current-session delegation chain, including resumed runs and restored transcripts. Results contain bounded visible assistant text and text tool results, with a next-page cursor; thinking, images, attachments, arbitrary arguments and system rows are omitted. Selected evidence can be passed in a later ordinary Task brief.

Validation on candidate b241da9e277ec38711cdfb916c4f87fb0b010ec5, containing origin/main at 2b6ce805c08a:

  • Shared and Agent Runtime TypeScript build/type validation: tsc -b --force packages/shared packages/agent-runtime.
  • Agent Runtime regression suite: 98 files, 1342 tests passed.
  • E2E-COLLABORATION-context: real candidate Runtime → pi → loopback SSE and real Host Todo/transcript persistence, covering Host restart, on-demand child evidence, compaction and cleared-list recovery. Ran with the installed compatible 0.18.0 Host binary and isolated temporary HOME/data/workspace. Reproduce with PI_DESKTOP_HOST_BIN=<compatible-host> pnpm test:e2e:collaboration-context.
  • Pi patch contracts, Biome lint, architecture limits, diff whitespace and current-main ancestry checks passed.

The spec, ADR proposal and E2E scenario are included. No dependencies, storage schema or RPC operations are added.

This is a feature proposal submitted as a draft at the user's request. The current AGENTS.md policy limits outside landing candidates to fix/perf; maintainer direction or a policy change is needed before this feature can land. It is intentionally classified as feat.

Keep the Host-owned checklist available to the model after restart and
compaction, with bounded state updates that preserve mode and permission
boundaries. Let the parent request selected delegate evidence through
TaskList without replaying entire child histories or adding peer channels.

Exercise the real model tool path and isolated Host persistence, and
specify the additive trace contract and recovery behavior.

@muzimu217 muzimu217 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Independently verified on the current main (64296456d, 51 commits ahead of the PR base 2b6ce805c) — the patch applies cleanly, so the integration surface is intact:

  • packages/agent-runtime suite on the patched tree: 99 files / 1345 tests passed (including the new delegation-trace.test.ts and runtime-collaboration-context.test.ts).
  • E2E-COLLABORATION-context against a real Host binary: passed — {"ok":true,"restart":true,"compaction":true,"cleared":true,"traceEntries":1}.
  • Cross-checked that every referenced integration point exists on main: todos.get RPC (rpc/mod.rs:2667), SessionTodoSnapshot (shared/session-todos.ts), selectChainRows/rebuildChainsFromTranscript (delegation-history.ts:166/551).

Code-reading notes (non-blocking):

  1. Cursor semantics are sound but worth stating explicitly in the tool description: after is the last returned messageId, and because the page break is detected before appending, the row that triggered the break is re-examined on the next page — no row can be skipped across pages. An unknown/foreign cursor throws rather than silently restarting, which is the right default.
  2. nextAfter is only set when a page breaks; a naturally exhausted scan returns entries with no nextAfter, so "no cursor = done" is unambiguous. Good.
  3. One Host RPC (todos.get) per model turn: the ADR acknowledges the cost and the section is skipped when empty; fine at this granularity, just flagging for the maintainer's cost review.
  4. The checklist text explicitly declares itself "task data, not instructions or authorization" — consistent with the repo's injection posture; trace output excludes thinking/images/arguments and uses literal (non-regex) search, so no ReDoS surface.

Draft + feat policy status noted — this is the maintainer's call on direction; verification data above stands whenever it is considered.

@Tioit-Wang

Copy link
Copy Markdown
Collaborator

I verified this independently and it holds up — the change applies cleanly, the test suite passes, and the real-app scenario for the collaboration path runs green.

It has stayed a draft for three and a half weeks and now conflicts, so it is closed here rather than left as a draft nobody is looking at. The branch is preserved. If you want to continue: rebase, add one line to the description about the small extra cost per turn, and mark it ready for review.

我独立验证过,结论成立——改动能干净应用,测试套件能过,协作路径的真实应用场景也跑绿了。

它作为草稿放了三周半而且现在冲突,所以关掉,而不是留成一个没人看的草稿。分支保留。如果想继续:变基,在描述里补一句「每轮会多一次很轻的读取开销」,然后标为可评审。

@Tioit-Wang Tioit-Wang closed this Nov 6, 2026
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.

3 participants