Skip to content

Python: [Bug]: Terminal A2A Task snapshots omit status messages #8998

Description

@quifox

Description

A terminal A2A Task snapshot with content in status.message drops that content in A2AAgent.run() and poll_task(). The terminal TaskStatusUpdateEvent path already surfaces the same status content. This can hide a failure explanation, including the kind of message emitted by the repository A2A hosting sample.

Expected: The failure note is available in the response, as it is for a terminal status-update event. Artifacts remain the protocol channel for task outputs.

Actual: The response text is empty although the terminal Task contains Agent execution failed..

Code Sample

This uses a mocked provider/client and makes no service request.

import asyncio
from unittest.mock import AsyncMock, MagicMock

from a2a.types import Message, Part, Role, Task, TaskState, TaskStatus
from agent_framework_a2a import A2AAgent, A2AContinuationToken


async def main():
    task = Task(
        id="example-task",
        context_id="example-context",
        status=TaskStatus(
            state=TaskState.TASK_STATE_FAILED,
            message=Message(
                message_id="failure-note",
                role=Role.ROLE_AGENT,
                parts=[Part(text="Agent execution failed.")],
            ),
        ),
    )
    client = MagicMock()
    client.get_task = AsyncMock(return_value=task)
    agent = A2AAgent(client=client, http_client=None)
    response = await agent.poll_task(A2AContinuationToken(task_id=task.id, context_id=task.context_id))
    print(repr(response.text))
    assert response.text == "Agent execution failed."


asyncio.run(main())

Package Versions

Source checkout e9857bd75a21843803431a2e7dfa41ee9b017ac7: agent-framework-core 1.20.0, agent-framework-a2a 1.0.0b261002; A2A SDK 1.2.1.

Python Version

Python 3.12.12.

Additional Context

I will submit a focused fix with regression coverage for this behavior.

Activity

  1. added
    pythonUsage: [Issues, PRs], Target: Python
    triageUsage: [Issues], Target: All issues that still need to be triaged
    on Oct 3, 2026
  2. added
    reproducedUsage: [Issues], Target: all issues that can be reproduced by the triage workflow
    on Oct 3, 2026
  3. github-actions commented on Oct 3, 2026

    @github-actions
    Contributor

    🤖 Automated triage reproduction notes (agent-authored — trust but verify)

    Agent analysis

    The bug reproduces in python/packages/a2a/agent_framework_a2a/_agent.py::_updates_from_task when a terminal Task has content only in status.message; both A2Agent.run() and poll_task() produce an empty response. Minimal repro: provide a mocked failed Task whose status message contains Agent execution failed., invoke either route, and assert that response.text preserves the message.

    • Failing test: python/packages/a2a/tests/test_a2a_agent.py
    • Files examined: python/packages/a2a/agent_framework_a2a/_agent.py, python/packages/a2a/tests/test_a2a_agent.py, python/packages/a2a/pyproject.toml
    • Tests run: test_poll_task_completed, test_streaming_status_update_event_yields_content, test_terminal_task_failed_surfaces_status_message[run], test_terminal_task_failed_surfaces_status_message[poll]
    • Reported version: 1.0.0b261002
    • Current version: 1.0.0b261002
  4. added
    a2aUsage: [Issues, PRs], Target: A2A
    and removed
    triageUsage: [Issues], Target: All issues that still need to be triaged
    on Oct 3, 2026
  5. eavanvalkenburg commented on Oct 27, 2026

    @eavanvalkenburg
    Member

    /plan Investigate the smallest backward-compatible fix through existing PR #8999 by quifox (@quifox), not a competing implementation. Current main terminal Task snapshots parse artifacts/history but omit status.message, whereas terminal status events expose it; a failure-only snapshot can therefore lose its explanation. Keep artifacts as task outputs and define supplemental status-message ordering/identity without duplicating history, standalone messages, repeated snapshots or status events. Reuse shared conversion/finalization helpers before adding parallel tracking abstractions; distinguish real final-response duplication from temporary metadata-only updates removed by finalization, and preserve task/message metadata. Compare current main rather than old patch snippets: terminal/background _operation_state and continuation clearing must survive every return path, including empty or fully deduplicated output, in both run modes and poll_task. Candidate PR touches more than a trivial boundary, so report a conservative production-code scope and meaningful compatibility choices before readiness. Reuse its existing tests and review evidence, then identify missing regressions for failed/completed/cancelled snapshots, status/history/artifact identity overlap, event-before-snapshot and reverse ordering, repeated tasks, metadata-only terminal updates and final continuation state. Coordinate with existing owner Eduard van Valkenburg (@eavanvalkenburg) and preserve #9051 closed state. No assignment, ready label, PR approval or reopening is implied.

  6. eavanvalkenburg commented on Nov 12, 2026

    @eavanvalkenburg
    Member

    /plan Investigate the smallest backward-compatible fix through existing PR #8999 by quifox (@quifox), not a competing implementation. Current main terminal Task snapshots parse artifacts/history but omit status.message, whereas terminal status events expose it; a failure-only snapshot can therefore lose its explanation. Keep artifacts as task outputs and define supplemental status-message ordering/identity without duplicating history, standalone messages, repeated snapshots or status events. Reuse shared conversion/finalization helpers before adding parallel tracking abstractions; distinguish real final-response duplication from temporary metadata-only updates removed by finalization, and preserve task/message metadata. Compare current main rather than old patch snippets: terminal/background _operation_state and continuation clearing must survive every return path, including empty or fully deduplicated output, in both run modes and poll_task. Candidate PR touches more than a trivial boundary, so report a conservative production-code scope and meaningful compatibility choices before readiness. Reuse its existing tests and review evidence, then identify missing regressions for failed/completed/cancelled snapshots, status/history/artifact identity overlap, event-before-snapshot and reverse ordering, repeated tasks, metadata-only terminal updates and final continuation state. Coordinate with existing owner Eduard van Valkenburg (@eavanvalkenburg) and preserve #9051 closed state. No assignment, ready label, PR approval or reopening is implied.

  7. github-actions commented on Nov 12, 2026

    @github-actions
    Contributor

    Summary

    A final (terminal) A2A Task snapshot that holds text only in status.message (for example a failed task saying "Agent execution failed.") returns empty text from A2AAgent.run() and poll_task(). The equivalent terminal status-update event does return that text. I read current main only. I did not inspect #8999's diff or reviews, and I ran no code. #9051 stays closed; nothing here assigns, labels, approves or reopens anything.

    Confirmed on main (python/packages/a2a/agent_framework_a2a/_agent.py)

    • _updates_from_task (~L882): for terminal states it uses only _parse_messages_from_task (L1373). That returns artifacts, or the last history item only if there are no artifacts. status.message is read only for INPUT_REQUIRED and for in-progress states with emit_intermediate.
    • _updates_from_task_update_event (~L1093): a terminal status event converts status.message into an update (message id, role, merged message and event metadata), marked terminal.
    • Terminal updates mark _operation_state="terminal" on the last update. Empty-output paths return a contentless update, but only when background=True for the artifact-only and event cases; in non-background mode they return [].
    • run (~L729-745) flushes buffered intermediate updates when the terminal snapshot has no content, and drops them when it has content. poll_task (L1171) calls the same function with background=True, so one fix in _updates_from_task covers run (both modes) and poll_task.

    Recommendation

    Code change is warranted: a small, bounded fix in the A2A package, plus tests. This is a real inconsistency between two terminal paths, and artifacts stay the output channel. No new public API is needed. Review the existing PR #8999 against the points below rather than starting a competing one.

    Proposed plan (no changes made)

    1. Conservative production scope. Only _updates_from_task in _agent.py, plus at most a small helper shared with the status-event path. Avoid new tracking state in run, changes to _deduplicate_user_input_request_updates, or changes to hosting. If the PR touches more than this, ask why each extra piece is needed.

    2. Reuse conversion. Build the status-message update with the same rules the event path already uses (role, message_id, message metadata merged with task metadata, merge_mode="replace") instead of a second implementation. Metadata-key precedence should match the event path.

    3. Ordering and identity (compatibility choice to decide). Suggested default: artifacts/history first, status message last, since it is a supplemental note. Skip it when it would repeat content already emitted: same message_id as the history item used, same id as an artifact, or identical parts. Decide explicitly whether text-only equality counts as duplication; id match is the safer minimum. Servers often put the status message in history too, so history/status overlap is the main duplicate risk.

    4. Duplicate vs. temporary updates. In run, the terminal-snapshot branch flushes buffered intermediate updates only when the snapshot has no content. A status message makes the snapshot "have content", which would now drop buffered intermediates. That is correct only if the status message is the real final answer. Tests must show a metadata-only terminal update (empty contents) still flushes pending updates and does not count as content.

    5. Final state on every return path. The last update returned (including the contentless fallbacks and the case where everything is deduplicated away) must still carry terminal state and no continuation token, in streaming, non-streaming, background=True and poll_task. Check that deduplicating the status message never leaves an empty list in background mode.

    6. Missing regressions to add or confirm (reuse the PR's tests where they already cover these):

      • failed, completed, and cancelled snapshots with status message only (run and poll);
      • status message equal to the last history item, and equal to an artifact (one copy expected);
      • artifacts plus a different status message (both present, artifacts first);
      • event-before-snapshot and snapshot-before-event ordering with the same message id (no duplicate);
      • a repeated snapshot for the same task, and a second task in the same stream;
      • standalone Message payloads unaffected;
      • metadata-only terminal update still flushing buffered intermediates;
      • final _operation_state and continuation token on each path above.
    7. Done when the issue's repro returns "Agent execution failed.", the matrix above passes, existing A2A tests are unchanged, and the diff stays within the scope in item 1.

    Coordination

    Eduard van Valkenburg (@eavanvalkenburg) owns the issue; please confirm the ordering/identity choice in item 3 before the PR is treated as ready. quifox (@quifox), please describe how #8999 maps to items 1-6.

    Generated by Issue Planning for #8998 · copilot · auto · ~18 AIC · ⌖ ~1 AIC · ⊞ 4.8K · ◷

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

a2aUsage: [Issues, PRs], Target: A2ApythonUsage: [Issues, PRs], Target: Pythonready-for-implementationMaintainers agree the problem and direction are ready for implementation.reproducedUsage: [Issues], Target: all issues that can be reproduced by the triage workflow

Type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions