Skip to content

fix(a2a): return answers instead of fallback notices - #152168

Merged
obviyus merged 7 commits into
openclaw:mainfrom
chelsealong:fix/a2a-fallback-notice-completion-152105
Sep 20, 2026
Merged

obviyus merged 7 commits into
openclaw:mainfrom
chelsealong:fix/a2a-fallback-notice-completion-152105

Conversation

@chelsealong

@chelsealong chelsealong commented Sep 18, 2026 •

Copy link
Copy Markdown
Contributor

Closes #152105

What Problem This Solves

Fixes: A2A tasks return a model-fallback notice instead of the agent's answer when a failed primary model is followed by a successful fallback.

User Impact

A2A clients receive the actual answer in the completed task artifact. Authentication, task retention, cancellation behavior, and the A2A protocol are unchanged.

Why This Change Was Made

A delivery marked final can still be a supplemental notice preceding the answer. A2A now uses the existing terminal-reply classifier through the reply-payload SDK instead of treating every final-lane payload as task completion. The SDK contract documents that classification is separate from content, sendability, and authority checks.

Evidence

  • Actual CLI-started Gateway, registered A2A JSON-RPC endpoints, and a local OpenAI-compatible HTTP provider: a primary HTTP 503 followed by a successful fallback returned only the fallback notice before the change and the exact answer afterward. Public chat history independently retained the answer in both cases.
  • Ordinary replies, terminal HTTP 401 diagnostics, cross-peer task isolation, both unsupported cancellation aliases, and slash-command rejection were exercised. Built runtime provenance and a separate public SDK consumer verified the shared classifier.
  • 207 focused tests passed; the A2A regression fails on the original production code. Build, scoped type-aware lint, documentation syntax, line-limit ratchets, SDK export registration, and the approved SDK surface check passed.
  • Known separate failure: the second queued followup stalls with Async work scope is closed on both baseline and candidate, consistent with the separately owned fix(auto-reply): keep followup queue drains alive after the triggering request ends #148025 work. This PR does not claim an all-green queued-delivery flow or repair that lifecycle.

The provider was a controlled local fixture; no paid-provider, native-client, or broader notice-only/TTS/abort proof is claimed.

A2A completed tasks with the first delivery marked kind:"final",
including supplemental model-fallback/status/reasoning/TTS notices,
so a later real assistant final answer was ignored once the task was
already terminal. Filter deliveries through the canonical
isReplyPayloadTerminalContent classifier before completing the task.
@clawsweeper

clawsweeper Bot commented Sep 18, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@clawsweeper clawsweeper Bot added P1 High-priority user-facing bug, regression, or broken workflow. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Sep 18, 2026
@clawsweeper

clawsweeper Bot commented Sep 18, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed September 20, 2026, 9:12 AM ET / 13:12 UTC (Revision 4).

ClawSweeper review

What this changes

The PR makes A2A tasks ignore supplemental notices before completing with the agent’s answer, exposes the existing reply classifier through the Plugin SDK, and updates its documentation, export budgets, and regression coverage.

Merge readiness

⛔ Blocked before merge - 3 items remain

This remains a useful fix for answer loss present on current main and the latest release. No introduced correctness defect was found. The updated runtime account improves the evidence, but the reported before/after run still needs an inspectable trace.

Priority: P1
Reviewed head: bfb159f9cebc1142789079130cc5fc8b870784bd

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The focused implementation and regression are sound, but the runtime result is currently summarized without inspectable output.
Proof confidence 🦐 gold shrimp (3/6) Needs stronger real behavior proof before merge: The updated body reports the correct production path: a CLI-started Gateway, registered A2A endpoints, an HTTP 503 primary failure, and a successful fallback returning the answer. However, no request/response excerpt, runtime log, or linked artifact shows those observations; the inspected screenshots concern separate task-expiry work. Publish a short redacted trace from the already-reported run. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Needs proof Needs stronger real behavior proof before merge: The updated body reports the correct production path: a CLI-started Gateway, registered A2A endpoints, an HTTP 503 primary failure, and a successful fallback returning the answer. However, no request/response excerpt, runtime log, or linked artifact shows those observations; the inspected screenshots concern separate task-expiry work. Publish a short redacted trace from the already-reported run. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Evidence reviewed 9 items Current main still accepts supplemental final replies: The fetched main callback checks only the final delivery kind before calling completeNext, so an earlier fallback notice can consume the pending task.
Latest supplied release remains affected: The v2026.9.5 source also completes tasks on every final-lane payload without applying the terminal-content classifier.
Fallback producer establishes the failure mechanism: The reply producer marks fallback notices with isFallbackNotice and prepends them to the answer payloads. The existing classifier rejects these notices while retaining terminal errors, command results, and fresh text carried with TTS.
Findings None None.
Security None None.

How this fits together

The A2A plugin accepts authenticated requests from other agents and sends them through OpenClaw’s reply pipeline. Its delivery callback completes an in-memory task that the requesting peer can retrieve.

flowchart TD
  A[Authenticated agent request] --> B[A2A task and agent execution]
  B --> C[Reply delivery]
  C --> D{Final terminal content?}
  D -->|No| E[Keep task working]
  D -->|Yes| F[Complete task with answer]
  F --> G[Peer retrieves task]
Loading

Before merge

  • Add real behavior proof - Needs stronger real behavior proof before merge: The updated body reports the correct production path: a CLI-started Gateway, registered A2A endpoints, an HTTP 503 primary failure, and a successful fallback returning the answer. However, no request/response excerpt, runtime log, or linked artifact shows those observations; the inspected screenshots concern separate task-expiry work. Publish a short redacted trace from the already-reported run. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
  • Resolve merge risk (P1) - The additive public SDK export creates a lasting compatibility commitment to distinguish reply lanes without implying sendability or authorization; collaborator acceptance is recorded.
  • Complete next step (P2) - Add inspectable output from the reported before/after A2A run to the PR body. Terminal screenshots or a recording are welcome; copied responses and logs also count. Redact keys, IP addresses, phone numbers, private endpoints, and other private data. Updating the body should trigger re-review; otherwise ask a maintainer to comment @clawsweeper re-review.
Agent review details

Security

None.

PR surface

Source +2, Tests -3, Docs +7, Other +2. Total +8 across 6 files.

View PR surface stats
Area Files Added Removed Net
Source 3 4 2 +2
Tests 1 5 8 -3
Docs 1 7 0 +7
Config 0 0 0 0
Generated 0 0 0 0
Other 1 4 2 +2
Total 6 20 12 +8

Review metrics

Metric Value Why it matters
Public SDK contract 1 callable export added; 2 surface budgets increased by 1 This exposes existing core behavior as a supported plugin contract without adding a subpath or configuration option.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #152105
Summary: This PR targets premature completion on supplemental notices; task expiry and followup lifecycle failures are distinct work.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Merge-risk options

Maintainer options:

  1. Retain the accepted narrow SDK contract (recommended)
    Keep the documented additive classifier and approved budget increases, preserving its existing semantics for future plugin consumers.

Technical review

Best possible solution:

Use the accepted shared SDK classifier at A2A completion while preserving peer-scoped FIFO delivery and terminal-error replies.

Do we have a high-confidence way to reproduce the issue?

Yes. Current source prepends a fallback notice to final replies, and A2A completes the pending task on that first payload; the linked report also documents the failure on an official release. This review did not execute the reproduction.

Is this the best way to solve the issue?

Yes. Reusing the existing classifier fixes the completion boundary without duplicating reply semantics or changing task correlation, authentication, or stored configuration.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 02e89c2683b8.

Labels

Label changes:

  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • remove rating: 🦪 silver shellfish: Current PR rating is rating: 🦐 gold shrimp, so this older rating label is no longer current.

Label justifications:

  • P1: A2A callers can receive a fallback notice instead of the successful agent answer on the current release.
  • merge-risk: 🚨 compatibility: The new public classifier establishes a plugin compatibility commitment, with collaborator acceptance now recorded.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs stronger real behavior proof before merge: The updated body reports the correct production path: a CLI-started Gateway, registered A2A endpoints, an HTTP 503 primary failure, and a successful fallback returning the answer. However, no request/response excerpt, runtime log, or linked artifact shows those observations; the inspected screenshots concern separate task-expiry work. Publish a short redacted trace from the already-reported run. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.

Evidence

What I checked:

  • Current main still accepts supplemental final replies: The fetched main callback checks only the final delivery kind before calling completeNext, so an earlier fallback notice can consume the pending task. (extensions/a2a/src/inbound.ts:113, 02e89c2683b8)
  • Latest supplied release remains affected: The v2026.9.5 source also completes tasks on every final-lane payload without applying the terminal-content classifier. (extensions/a2a/src/inbound.ts:113, ec9c1a13db89)
  • Fallback producer establishes the failure mechanism: The reply producer marks fallback notices with isFallbackNotice and prepends them to the answer payloads. The existing classifier rejects these notices while retaining terminal errors, command results, and fresh text carried with TTS. (src/auto-reply/reply/agent-runner-result-payloads.ts:429, bfb159f9cebc)
  • Narrow repair at the existing completion boundary: The introduced guard reuses the canonical classifier before the unchanged peer-scoped FIFO completion call. Authentication, peer routing, task storage, and cancellation behavior are unchanged; the classifier is explicitly not an authority check. (extensions/a2a/src/inbound.ts:114, bfb159f9cebc)
  • Regression protects observable task results: The changed test delivers a fallback notice through mocked dispatch, verifies that the real task store remains working, then verifies the completed artifact contains the answer. The PR reports a failing baseline and 207 passing focused tests; this read-only review did not execute them. (extensions/a2a/src/inbound.test.ts:64, bfb159f9cebc)
  • Updated proof account and remaining gap: The captured body, confirmed unchanged by REST at the reviewed head, reports a CLI-started Gateway, registered A2A endpoints, primary HTTP 503, successful fallback, and correct answer afterward. It contains no copied request/response output or linked runtime artifact. This supersedes the older claim that no runtime run was possible, but does not yet provide an inspectable trace of that run. (bfb159f9cebc)

Likely related people:

  • unknown: The claimed source-line change could not be verified from bounded local history. (role: source history unknown; confidence: low)
  • unknown: The claimed source-line change could not be verified from bounded local history. (role: source history unknown; confidence: low)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Attach the reported Gateway run’s redacted request/response or terminal output showing primary failure, fallback success, and the returned answer artifact.

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (3 earlier review cycles)
  • reviewed 2026-09-18T21:08:39.059Z sha d3e9aba :: needs real behavior proof before merge. :: none
  • reviewed 2026-09-18T22:02:53.443Z sha 654df34 :: needs real behavior proof before merge. :: none
  • reviewed 2026-09-18T22:20:59.201Z sha ba649e4 :: needs real behavior proof before merge. :: none

Clarify that the classifier only distinguishes terminal answer content
from supplemental notices (reasoning, commentary, status/compaction/
fallback notices, TTS supplements) and does not check whether the
payload is nonempty or otherwise sendable.
@chelsealong

Copy link
Copy Markdown
Contributor Author

Addressed the merge-risk (P1) doc ask: isReplyPayloadTerminalContent (src/plugin-sdk/reply-payload.ts) now has a doc comment stating its contract — it classifies terminal vs. supplemental payload lanes only (excludes reasoning/commentary/status/compaction/fallback notices/TTS supplements) and does not check whether the payload is nonempty or otherwise sendable; callers should pair it with content/media checks before treating a payload as a deliverable answer. Pushed as 654df34.

Verified: node scripts/run-vitest.mjs run src/plugin-sdk/api-baseline.test.ts src/plugin-sdk/reply-payload.test.ts src/auto-reply/reply-payload.test.ts extensions/a2a/src/inbound.test.ts (all pass, SDK export surface unaffected), pnpm tsgo:core / pnpm tsgo:extensions clean, oxfmt --check src/plugin-sdk/reply-payload.ts clean.

On the "real behavior proof" ask: I can't produce that from this sandbox. The linked issue's live canary needed a real configured model provider whose primary attempt fails and falls back to a second one, plus an authenticated peer hitting a running Gateway — this environment has no model-provider credentials (no ANTHROPIC_API_KEY/OPENAI_API_KEY/etc.) and no public A2A endpoint, so there's no way to trigger a genuine fallback here. The repo's offline mock-provider harness (extensions/qa-lab, aimock) isn't wired to A2A or to a fallback-forcing scenario, and building that wiring would be new harness code, not a proof run — leaving that to whoever has live credentials to re-run the reporter's canary against this branch.

@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. labels Sep 18, 2026
…alContent

The exported classifier added in d3e9aba increased the public SDK
export count by 1 without updating the pinned budget, failing
test/scripts/plugin-sdk-surface-report.test.ts in CI.
@chelsealong

Copy link
Copy Markdown
Contributor Author

Fixed the failing CI check (`checks-node-compact-small-28`): the new `isReplyPayloadTerminalContent` SDK export added one public export/callable export that the pinned budget in `scripts/plugin-sdk-surface-report.mts` (`publicExports`/`publicFunctionExports`) hadn't accounted for. Bumped both from 4485/2649 to 4486/2650 with a ledger comment. Pushed as ba649e4.

Verified: reverted the budget change alone and reran `node scripts/run-vitest.mjs run test/scripts/plugin-sdk-surface-report.test.ts` — reproduces the exact CI failure (`exports 4485 vs 4486`, `callableExports 2649 vs 2650`); with the fix, all 10 tests pass. Also reran `extensions/a2a/src/inbound.test.ts`, `src/plugin-sdk/reply-payload.test.ts`, `src/auto-reply/reply-payload.test.ts`, and `src/plugin-sdk/api-baseline.test.ts` (all pass), plus `node scripts/run-oxlint.mjs --tsconfig tsconfig.json scripts/plugin-sdk-surface-report.mts` and `oxfmt --check` on the file (both clean).

@openclaw-barnacle openclaw-barnacle Bot added the scripts Repository scripts label Sep 18, 2026
@clawsweeper clawsweeper Bot added the merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. label Sep 18, 2026
@chelsealong

Copy link
Copy Markdown
Contributor Author

Both remaining blockers need capabilities outside contributor scope in this sandbox:

Real behavior proof: Confirmed again — no model-provider credentials are present here (checked env for ANTHROPIC_API_KEY/OPENAI_API_KEY/etc., none set), and no existing harness wires a real HTTP-listening extensions/a2a server to a fallback-triggering mock provider: extensions/a2a/src/http.test.ts calls createA2aHttpHandler directly via mock request/response objects (no http.createServer/socket), and extensions/qa-lab/src/providers/mock-openai/server.ts's fallback fixture (MODEL-FALLBACK-VISIBLE-OK) is only ever exercised through the mock server's own request/response tests, never through a live A2A message/send → tasks/get round trip. Producing that proof needs new end-to-end glue code (real listener + gateway config + provider wiring) — out of scope for this fix-sized PR; leaving it to whoever runs the reporter's canary against this branch, or can accept the scope increase to build that harness.

SDK export/budget acceptance: Per the PR's own "Decision needed" table, this needs an explicit maintainer decision that I can't grant as the contributor. Flagging for maintainer sign-off.

@obviyus obviyus self-assigned this Sep 20, 2026
@openclaw-barnacle openclaw-barnacle Bot added the docs Improvements or additions to documentation label Sep 20, 2026
@obviyus obviyus changed the title fix(a2a): do not settle tasks on fallback/status delivery notices fix(a2a): return answers instead of fallback notices Sep 20, 2026
@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Sep 20, 2026
@obviyus
obviyus merged commit e9686ad into openclaw:main Sep 20, 2026
241 checks passed
@obviyus

obviyus commented Sep 20, 2026

Copy link
Copy Markdown
Collaborator

Merged as e9686ad. A2A tasks now retain the actual answer instead of completing on a fallback notice.

Verified the CLI-started Gateway and local HTTP-provider fallback round trip, 207 focused tests, and passing exact-head review/CI. The separate queued-followup failure tracked in #148025 remains outside this fix.

Thanks @chelsealong for the fix and @edgarstool for the report.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 21, 2026
Closes openclaw#152105

## What Problem This Solves

Fixes: A2A tasks return a model-fallback notice instead of the agent's answer when a failed primary model is followed by a successful fallback.

## User Impact

A2A clients receive the actual answer in the completed task artifact. Authentication, task retention, cancellation behavior, and the A2A protocol are unchanged.

## Why This Change Was Made

A delivery marked `final` can still be a supplemental notice preceding the answer. A2A now uses the existing terminal-reply classifier through the reply-payload SDK instead of treating every final-lane payload as task completion. The SDK contract documents that classification is separate from content, sendability, and authority checks.

## Evidence

- Actual CLI-started Gateway, registered A2A JSON-RPC endpoints, and a local OpenAI-compatible HTTP provider: a primary HTTP 503 followed by a successful fallback returned only the fallback notice before the change and the exact answer afterward. Public chat history independently retained the answer in both cases.
- Ordinary replies, terminal HTTP 401 diagnostics, cross-peer task isolation, both unsupported cancellation aliases, and slash-command rejection were exercised. Built runtime provenance and a separate public SDK consumer verified the shared classifier.
- 207 focused tests passed; the A2A regression fails on the original production code. Build, scoped type-aware lint, documentation syntax, line-limit ratchets, SDK export registration, and the approved SDK surface check passed.
- Known separate failure: the second queued followup stalls with `Async work scope is closed` on both baseline and candidate, consistent with the separately owned openclaw#148025 work. This PR does not claim an all-green queued-delivery flow or repair that lifecycle.

The provider was a controlled local fixture; no paid-provider, native-client, or broader notice-only/TTS/abort proof is claimed.

Co-authored-by: Ayaan Zaidi <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: a2a docs Improvements or additions to documentation merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. scripts Repository scripts size: XS status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: A2A task can complete on model fallback notice before the actual final answer

2 participants