Repository navigation
fix(agent-client): narrow pendingTaskId auto-thread to same-skill same-context (#1590) - #1593
Merged
Merged
Conversation
…e-context (closes #1590) Pair the retained server-side task handle with the `(contextId, taskName)` it was returned under. `withSession()` now auto-threads `pendingTask.taskId` onto an outbound call only when the call is plausibly a continuation of the SAME task — same skill name AND same effective `contextId`. A different skill or switched contextId signals new work; the retained handle is stale per A2A 0.3.0 §3.4, and sending it produces "Task not found" against spec-compliant sellers. Defense in depth on top of the storyboard-runner reset (#1588). Runner level fix protects `comply()`-style harnesses that own client lifecycle; SDK-level narrowing protects every adopter who reuses one AgentClient across logically distinct conversations without an explicit reset. HITL flows (createMediaBuy → input-required → createMediaBuy resume) match same-skill same-context and continue to thread. Caller-supplied `options.taskId` always wins. Public surface unchanged: `getPendingTaskId()` returns the same value, `resetContext()` clears the handle as before. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
…view nit) Per code-reviewer feedback on #1593: the original "(e.g., deferred without serverTaskId)" example understated the surface — non-spec A2A Tasks missing `contextId` or `taskName` ALSO land in this branch by design and are deliberately NOT retained as a fresh handle, since auto-threading a partially-keyed taskId into the next call is exactly the leak class the narrowing closes. No behavior change. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
bokelley
added a commit
that referenced
this pull request
May 8, 2026
…evicted task Catch "Task <id> not found" errors from getTaskStatus in pollTaskCompletion and return a TaskResultFailure with an actionable error message instead of letting an opaque exception escape the loop. A2A 0.3.x defines no minimum retention TTL for completed tasks, so a seller may evict a task between the buyer observing the working-state response and the first explicit tasks/get poll firing. The error now suggests using push notifications (reporting_webhook) or configuring a longer task retention TTL on the seller. Defense-in-depth follow-up to #1585. The cross-storyboard root cause was already addressed in #1588 (resetContext per storyboard) and #1593 (narrowed pendingTaskId auto-thread to same-skill same-context); this change improves the error surface for any residual case where an evicted task is queried. The not-found regex is bounded (\S{1,128}) to satisfy the CodeQL polynomial-regex check on uncontrolled error strings. Closes/supersedes #1592 (which proposed this same descriptive-error fix bundled with two other changes that #1588 and #1593 obviated). Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
bokelley
added a commit
that referenced
this pull request
May 8, 2026
…evicted task (#1596) Catch "Task <id> not found" errors from getTaskStatus in pollTaskCompletion and return a TaskResultFailure with an actionable error message instead of letting an opaque exception escape the loop. A2A 0.3.x defines no minimum retention TTL for completed tasks, so a seller may evict a task between the buyer observing the working-state response and the first explicit tasks/get poll firing. The error now suggests using push notifications (reporting_webhook) or configuring a longer task retention TTL on the seller. Defense-in-depth follow-up to #1585. The cross-storyboard root cause was already addressed in #1588 (resetContext per storyboard) and #1593 (narrowed pendingTaskId auto-thread to same-skill same-context); this change improves the error surface for any residual case where an evicted task is queried. The not-found regex is bounded (\S{1,128}) to satisfy the CodeQL polynomial-regex check on uncontrolled error strings. Closes/supersedes #1592 (which proposed this same descriptive-error fix bundled with two other changes that #1588 and #1593 obviated). Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
pendingTaskIdonto a NEW skill call (different tool name) is not spec-correct under A2A 0.3.0 §3.4 (`Message.taskId` continues the parent task).Change
`AgentClient` now pairs the retained server-side task handle with the `(contextId, taskName)` it was returned under (`PendingTaskHandle`). `withSession()` only auto-threads `pendingTask.taskId` onto an outbound call when:
A different skill or switched contextId signals new work; the retained handle is stale, and sending it produces "Task not found" against spec-compliant sellers.
HITL flows (`createMediaBuy` → `input-required` → `createMediaBuy` resume) match same-skill same-context and continue to thread as before. Caller-supplied `options.taskId` always wins regardless of skill match — explicit > implicit.
Public surface
Test plan
🤖 Generated with Claude Code