Skip to content

fix(agent-runtime): accept job plus multi-id TaskWait selectors - #2489

Merged
vastsa merged 1 commit into
vastsa:mainfrom
koeria:fix/taskwait-job-delegationids-2487
Nov 21, 2026
Merged

vastsa merged 1 commit into
vastsa:mainfrom
koeria:fix/taskwait-job-delegationids-2487

Conversation

@koeria

@koeria koeria commented Nov 20, 2026

Copy link
Copy Markdown
Contributor

Fixes #2487

Problem

#2188 (the fix for #2173) let TaskWait/TaskStop accept a delegation job together with an omitted/empty delegationIds, or a list containing only that job's id. target() still threw when the same job arrived with a delegationIds array naming any other id. Strict Responses-style models (reported with gpt-6.2-astra) fill optional parameters and send the job plus every id when collecting several completed subagent reports. Every TaskWait then failed, so the parent never received the report bodies: 21 failures over 32 minutes and roughly 12 KB of subagent output lost in the report.

The guard was stricter than the implementation: buildJobTools() already falls through to delegates.wait/stop.execute(id, params) when target() returns no job, and those delegates honor the full delegationIds list.

Change

  • target() now returns undefined (no job) when a valid delegation delegationIds array selects ids other than job.id, so the existing multi-target path handles the call and keeps the original wait options.
  • The fix(runtime): accept redundant delegation job selectors #2188 behavior is unchanged: omitted/empty arrays or arrays containing only job.id (including duplicates) still resolve to the single job.
  • Genuinely malformed selectors (non-arrays or arrays with non-string entries) still throw, now with an actionable message telling the model to drop job and retry with delegationIds: [...].
  • TaskList no longer echoes job={"kind":"delegation",...} per delegation; it prints delegationIds=["<id>"], so it no longer advertises the shape that led the model to send job.
  • Bash job selection/control is untouched: conflicting or invalid Bash selectors are still rejected as before.

Tests

  • pnpm --filter @pi-desktop/shared build
  • packages/agent-runtime: vitest run src/background-job-tools.test.ts — 42 passed
  • packages/agent-runtime: vitest run src/runtime.test.ts — 429 passed
  • packages/agent-runtime: vitest run src/subagent.test.ts src/delegation-chain.test.ts src/delegation-history.test.ts — 120 passed
  • pnpm --filter @pi-desktop/shared typecheck and pnpm --filter @pi-desktop/agent-runtime typecheck — pass

New coverage: ["other"] and ["delegate", "other"] now fall through to the delegate with the original params; malformed values ("delegate", null, ["delegate", null], [42]) keep throwing; the existing same-id/empty/omitted single-job cases still pass; TaskList output asserts the delegationIds form and no job=.

vastsa#2188 relaxed target() to accept an omitted/empty delegationIds or one
containing only job.id. It still threw when a delegation job accompanied a
delegationIds array naming other subagents, even though the wrapper already
falls through to delegates.wait/stop.execute(id, params) and that path honors
the full multi-target list. Strict Responses-style models send both shapes
when collecting several completed reports, so every TaskWait failed and the
reports never reached the parent.

Return undefined instead of throwing for a valid delegationIds array that
selects other ids, letting the existing multi-target path handle it. Keep the
single-job path for omitted/empty/same-id arrays and keep rejecting malformed
selectors (non-array values or non-string entries) with an actionable error
that tells the model to drop job and retry with delegationIds. Bash job
selectors are unchanged.

Also stop TaskList from echoing `job={"kind":"delegation",...}` for each
delegation; it now prints the delegationIds form the model should pass.

Fixes vastsa#2487

@aiuo-codepilot aiuo-codepilot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

AIUO CodePilot · Preliminary review

Diff-only preliminary review of PR 2489 (delegation TaskWait/TaskStop selectors). The change relaxes target() so a conflicting delegationIds array falls through to multi-target delegates, narrows malformed selectors to a new error, and rewrites TaskList output from job= to delegationIds=. Logic and tests appear consistent with the stated intent; I could not run tests or inspect surrounding runtime code, so findings are limited to what is visible in the patch.

No evidenced findings in the supplied diff.

Head: aef5ada
Base: 48a6558
CI: success; mergeable: true.

Validation: code/tests NOT EXECUTED. Diff-only preliminary analysis; not approval. Human review and repository gates remain required.

@vastsa
vastsa merged commit ec03cba into vastsa:main Nov 21, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants