Skip to content

fix(a2a/comply): three-layer A2A timeout fix — pollTaskCompletion + comply signal + discovery (#1612) - #1613

Merged
bokelley merged 5 commits into
mainfrom
claude/issue-1612-a2a-comply-timeout
May 9, 2026
Merged

bokelley merged 5 commits into
mainfrom
claude/issue-1612-a2a-comply-timeout

Conversation

@bokelley

@bokelley bokelley commented May 8, 2026 •

Copy link
Copy Markdown
Contributor

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 a2a was timing out at 180s because pollTaskCompletion had no exit branch for status: 'unknown' — when a seller's tasks/get response didn't match any known envelope shape (flat AdCP, MCP structuredContent, or A2A DataPart artifact), the while-true loop fell through to sleep(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:

  1. status: 'unknown' exit branch (TaskExecutor.ts) — pollTaskCompletion now returns a failed TaskResult immediately when mapTasksGetResponseToTaskInfo returns status: 'unknown', with a message naming the likely seller-side cause.

  2. AbortSignal threading (TaskExecutor.ts, ConversationTypes.ts, runner.ts) — pollTaskCompletion gains an optional signal?: AbortSignal 5th param; SubmittedContinuation.waitForCompletion gains a matching signal?: AbortSignal 2nd param. The storyboard runner passes AbortSignal.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 to waitForCompletion().

  3. A2A transport-status fallback (TaskExecutor.ts unwrapTasksGetEnvelope) — when an A2A Task response has no DataPart artifacts, surface result.status.state + result.id as a last-resort hint so terminal transport states (completed, failed, etc.) propagate instead of collapsing to 'unknown'.

  4. Post-sleep abort re-check — a second if (signal?.aborted) continue after sleep(pollInterval) limits abort latency to one sleep interval rather than one full poll cycle.

Known follow-ups (not in this PR):

  • MCP sequential-call timeout — a second user confirmed that bare storyboard run on MCP (default 120s) also times out at comply() pre-flight. Root cause: complyImpl's for (const sb of applicableStoryboards) loop does not forward the AbortSignal into runStoryboard(), so the combined signal only fires between storyboards, not inside them. Fix: thread signal through StoryboardRunOptions into per-step MCP calls. Tracked in storyboard run: A2A pre-flight comply() ~3x slower than MCP, hits 180s timeout for healthy agents #1612.
  • tasks/get via message/send — tasks/get is dispatched via message/send skill invocation for A2A; the native A2A 0.3.0 tasks/get JSON-RPC method would be more correct for sellers that implement that path directly. Tracked separately.

What tested

  • npm run format:check — clean
  • npm run typecheck — no new errors (pre-existing TS2688/TS5107 environment-level errors unrelated to these changes)
  • Build toolchain (tsx) unavailable in CI environment; TypeScript compilation via tsc --noEmit confirmed clean

Pre-PR review

  • code-reviewer: approved — no blockers; issues noted (waitForCompletion signal threading, transport-status task_id fallback) were fixed in follow-up commit; remaining nits surfaced in PR body above
  • ad-tech-protocol-expert: approved — "Sound. All four changes are correct, consistent with AdCP's submitted-arm polling contract, and introduce no new protocol concerns." Confirmed blocker (waitForCompletion signal gap) resolved; optional-param addition is non-breaking per AdCP versioning policy

Triage-managed PR. This bot does not currently iterate on
review comments or PR conversation threads (only on the source
issue). To unblock:

  • Push fixup commits directly: gh pr checkout <num> →
    fix → push.
  • Or re-trigger: comment /triage execute on the source
    issue.

See adcp#3121
for context.

Session: https://claude.ai/code/session_01QQeuhhr7XAMjKg2qZGVaza


Generated by Claude Code

claude added 3 commits May 8, 2026 18:59
…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
bokelley and others added 2 commits May 9, 2026 04:06
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
bokelley marked this pull request as ready for review May 9, 2026 13:16
@bokelley bokelley changed the title fix(a2a): stop pollTaskCompletion spinning indefinitely on unrecognized tasks/get responses fix(a2a/comply): three-layer A2A timeout fix — pollTaskCompletion + comply signal + discovery (#1612) May 9, 2026
@bokelley

bokelley commented May 9, 2026

Copy link
Copy Markdown
Contributor Author

Pre-merge expert reviews — all three converged on approve.

  • code-reviewer: "Admin-merge — the third commit is correctly scoped, well-tested, and the residual issues are pre-existing or stylistic." Two nits filed as follow-ups (pre-existing CLI-parse parity bug at site 3; coverage gap on second getAdcpCapabilities call abort).
  • ad-tech-protocol-expert: "Sound-with-caveats. Protocol semantics do NOT block merge." Notes the 5xx→A2A reclassification could misclassify an MCP-at-root host behind a generic-503 WAF, but the cost is bounded (one extra A2A handshake) vs the 425s symptom this fixes. Open question (non-blocker): wire tasks/cancel so orphan A2A polls don't keep billing the seller.
  • security-reviewer: "Do not block admin-merge. All five concerns examined; no exploitable findings." Two low-severity defense-in-depth notes: (1) add a "do not log response bodies" comment in raceWithSignal — orphans carry auth-bearing responses; (2) consider an internal-IP denylist in detectA2AOrMcp if comply ever runs server-side against tenant-supplied URLs.

CI red-X is npm audit --audit-level=high flagging fast-uri (GHSA-q3j6-qgpj-74h6) — same advisory failing on main, not introduced by this PR. Admin-merging.

@bokelley
bokelley merged commit f3e3950 into main May 9, 2026
10 of 11 checks passed
@bokelley

bokelley commented May 9, 2026

Copy link
Copy Markdown
Contributor Author

Acknowledged — noted the three converged approvals and the admin-merge decision. The follow-up items (logging comment in raceWithSignal, internal-IP denylist consideration in detectA2AOrMcp, tasks/cancel wiring, coverage gap on second getAdcpCapabilities abort) are non-blocking and can be tracked as separate issues when the PR lands.


Triaged by Claude Code. Session: https://claude.ai/code/session_014GfvnvnfhuQW8sWpVYjKwa


Generated by Claude Code

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]>
@github-actions github-actions Bot mentioned this pull request May 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants