Repository navigation
fix(a2a/comply): three-layer A2A timeout fix — pollTaskCompletion + comply signal + discovery (#1612) - #1613
Merged
Merged
Conversation
…ed tasks/get responses (#1612) Three-part fix for A2A comply() 180s timeout: - Exit on status:'unknown' instead of spinning forever - Thread AbortSignal from storyboard race timer to cancel orphaned loops - Fall back to A2A transport-layer status when DataPart artifact is absent https://claude.ai/code/session_01QQeuhhr7XAMjKg2qZGVaza
…d to transport-status fallback - SubmittedContinuation.waitForCompletion now accepts optional signal?: AbortSignal and threads it to pollTaskCompletion so public API callers also get cancellation - transport-status fallback in unwrapTasksGetEnvelope now preserves r.id as task_id - Re-check signal?.aborted after sleep to bound abort latency to one sleep interval - Correct comment: transport-status mapping is not lossless for auth-required https://claude.ai/code/session_01QQeuhhr7XAMjKg2qZGVaza
This was referenced May 8, 2026
Before: complyImpl's combined timeout_ms / external-signal AbortController fired throwIfAborted() only between storyboards. Inside a single storyboard, executeStoryboardPass had no signal awareness — sequential per-step calls burned the full comply() budget regardless of when the abort fired. Three changes: - StoryboardRunOptions.signal?: AbortSignal (new optional field) - complyImpl forwards its combined signal into runOptions - executeStoryboardPass calls options.signal?.throwIfAborted() at every phase iteration AND every step iteration Verified against wonderstruck.sales-agent.scope3.com/mcp with --timeout 60: wall-clock 150s → 60.8s (timeout + 0.8s tail). Note: the A2A path against the same agent still leaks ~250s past abort. Separate root cause (A2A discovery/probe loop with no signal awareness), tracked under the same issue but not addressed here. Also adds a regression test for adcp-client#1614 — captures the actual enrichRequest output for invalid_transitions/update_unknown_package and asserts both account and a real-UUID idempotency_key reach the wire, locking in the fixture-aware envelope re-injection so a future refactor of omitEnvelopeFields can't silently drop spec-required fields. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Investigation of the original #1612 symptom found three independent bugs whose interaction produced the 307s+ wall-clock against an A2A agent: 1. CLI silently ignored `--transport`; accept it as an alias for `--protocol` (A2A SDK convention used in the original repro). 2. detectProtocol fell back to 'mcp' on any non-200 from the well-known card path. 5xx/401/403/429/network-error now upgrade to A2A suspect; only 4xx (other than auth/rate) and clean miss fall back to MCP. 3. discoverAgentProfile had no AbortSignal awareness — comply()'s combined timeout couldn't bound an unhealthy-agent getAgentInfo() that spun for ~7 minutes against a non-MCP root. comply() now passes its signal to discoverAgentProfile, which races the transport calls. Orphan request still resolves in the background; this bounds caller-visible latency. Empirical against wonderstruck.sales-agent.scope3.com: --transport a2a (typo for --protocol): 425s → 31s bare URL auto-detect: 425s → 41s --protocol mcp /mcp: 60.8s → 31s Tests: - protocol-detection-1612.test.js: 8 cases covering 200/4xx/5xx/auth/network - discover-agent-profile-signal.test.js: 4 cases covering pre-aborted, mid-call abort, no-signal completion, no-signal backward compat Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
bokelley
marked this pull request as ready for review
May 9, 2026 13:16
Contributor
Author
|
Pre-merge expert reviews — all three converged on approve.
CI red-X is |
Contributor
Author
|
Acknowledged — noted the three converged approvals and the admin-merge decision. The follow-up items (logging comment in Triaged by Claude Code. Session: https://claude.ai/code/session_014GfvnvnfhuQW8sWpVYjKwa Generated by Claude Code |
This was referenced May 9, 2026
Closed
bokelley
added a commit
that referenced
this pull request
May 9, 2026
…gnal security note, second-call coverage) (#1619) * chore(comply): #1612 review follow-ups Three small follow-ups from the parallel expert review of #1613: - bin/adcp.js: parse-site 3 now validates the trailing-flag case for --protocol/--transport, matching the other two parse sites. Pre-existing parity bug where a trailing --transport produced protocolFlag=undefined that snuck past the truthiness gate downstream. - src/lib/testing/client.ts: raceWithSignal gains a security warning in its JSDoc and an inline comment on the orphan-promise resolver. Do not log v there — the orphaned promise still carries an authenticated agent response after the buyer has moved on past the abort. Behavior unchanged. - test/lib/discover-agent-profile-signal.test.js: new test exercises an abort firing during the second getAdcpCapabilities call (existing coverage was first getAgentInfo only). Asserts capabilities_probe_error records the abort reason and that the wrapper exits fast. Two larger follow-ups tracked separately: #1617 — wire A2A tasks/cancel on comply abort #1618 — SSRF denylist on detectProtocol/discoverAgentProfile Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]> * chore(review): address #1619 expert review notes Two low-severity nits from the parallel review of #1619: - src/lib/testing/client.ts (code-reviewer): extend the "do not log" warning to the error branch. Error.message from a transport rejection can carry an echoed response body, same trust-boundary concern. - bin/adcp.js (security-reviewer): parse-site 3 now hard-fails with exit 2 + clear error when --protocol/--transport has no value, matching sites 1 and 2. Was a UX asymmetry where the same typo silently fell through to auto-detect on this site only. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]> --------- 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.
Refs #1612 — fixes the A2A transport path only; the MCP sequential-call timeout is a separate root cause tracked in #1612.
storyboard run media_buy_seller --transport a2awas timing out at 180s becausepollTaskCompletionhad no exit branch forstatus: 'unknown'— when a seller'stasks/getresponse didn't match any known envelope shape (flat AdCP, MCPstructuredContent, or A2A DataPart artifact), the while-true loop fell through tosleep(pollInterval)and retried indefinitely. Compounded by orphaned poll promises that kept firing A2A calls after the outer 30s storyboard race timer resolved, accumulating across multiple storyboard steps until comply() burned its full 180s budget.Four-part fix:
status: 'unknown'exit branch (TaskExecutor.ts) —pollTaskCompletionnow returns afailedTaskResultimmediately whenmapTasksGetResponseToTaskInforeturnsstatus: 'unknown', with a message naming the likely seller-side cause.AbortSignal threading (
TaskExecutor.ts,ConversationTypes.ts,runner.ts) —pollTaskCompletiongains an optionalsignal?: AbortSignal5th param;SubmittedContinuation.waitForCompletiongains a matchingsignal?: AbortSignal2nd param. The storyboard runner passesAbortSignal.timeout(timeoutMs)so the inner loop exits when the outer race timer fires — no more orphaned A2A calls. Public buyers can now also pass a signal towaitForCompletion().A2A transport-status fallback (
TaskExecutor.tsunwrapTasksGetEnvelope) — when an A2A Task response has no DataPart artifacts, surfaceresult.status.state+result.idas a last-resort hint so terminal transport states (completed,failed, etc.) propagate instead of collapsing to'unknown'.Post-sleep abort re-check — a second
if (signal?.aborted) continueaftersleep(pollInterval)limits abort latency to one sleep interval rather than one full poll cycle.Known follow-ups (not in this PR):
storyboard runon MCP (default 120s) also times out at comply() pre-flight. Root cause:complyImpl'sfor (const sb of applicableStoryboards)loop does not forward the AbortSignal intorunStoryboard(), so the combined signal only fires between storyboards, not inside them. Fix: threadsignalthroughStoryboardRunOptionsinto per-step MCP calls. Tracked in storyboard run: A2A pre-flight comply() ~3x slower than MCP, hits 180s timeout for healthy agents #1612.tasks/getviamessage/send—tasks/getis dispatched viamessage/sendskill invocation for A2A; the native A2A 0.3.0tasks/getJSON-RPC method would be more correct for sellers that implement that path directly. Tracked separately.What tested
npm run format:check— cleannpm run typecheck— no new errors (pre-existingTS2688/TS5107environment-level errors unrelated to these changes)tsx) unavailable in CI environment; TypeScript compilation viatsc --noEmitconfirmed cleanPre-PR review
Session: https://claude.ai/code/session_01QQeuhhr7XAMjKg2qZGVaza
Generated by Claude Code