Skip to content

A2A message:stream against a deployed Agent Engine (reasoningEngines) target truncates after TASK_STATE_WORKING, or fails with 'append=True for nonexistent artifact_id' #6680

Closed

Description

@virktapvir

Describe the bug

Calling a genuinely deployed Vertex AI Agent Engine (reasoningEngines) resource via the A2A protocol's streaming endpoint either:

(a) silently stops after reporting TASK_STATE_WORKING, never delivering an artifact or completion event, or
(b) — after upgrading to a2a-sdk==1.1.2 / google-adk==2.6.3 on both client and server — fails with an explicit client-side error:

A2A request failed: append=True for nonexistent artifact_id='<uuid>' in task '<uuid>'.
The artifact must be created (append=False) before appending parts to it.

The non-streaming message:send call against the identical deployed target, same agent code, same question, completes successfully and returns the full answer every time. The bug is specific to streaming (message:stream) against a deployed Agent Engine target — the same code against a local A2A server (plain uvicorn, no Agent Engine) streams correctly with no truncation.

To Reproduce

  1. Deploy an ADK agent to Vertex AI Agent Engine via client.agent_engines.create(agent_engine=AdkApp(...)) (standard AdkApp wrapping, not a BYOD custom container).
  2. From a separate client process, call the deployed engine's A2A REST endpoint directly:
    from a2a.client.transports.rest import RestTransport
    from a2a.types import Message, Part, Role, SendMessageRequest
    
    # base_url = https://{region}-aiplatform.googleapis.com/v1beta1/{resource_name}/a2a
    transport = RestTransport(httpx_client=http, agent_card=None, url=base_url)
    message = Message(role=Role.ROLE_USER, message_id=..., context_id=..., parts=[Part(text="<any question that triggers a tool call>")])
    async for event in transport.send_message_streaming(SendMessageRequest(message=message)):
        print(event.WhichOneof("payload"))
  3. Observed sequence: task(state=SUBMITTED) -> status_update(state=SUBMITTED) -> status_update(state=WORKING) -> stream ends. No further events, no exception raised, no TASK_STATE_COMPLETED, no artifact.
  4. Server-side logging (Cloud Logging on the Agent Engine resource) confirms the agent completes its work in the same window (tool calls, model calls, etc. all succeed server-side) -- the completion event is simply never delivered to the streaming client.
  5. Calling the same deployed resource with message:send (non-streaming) instead, with an identical request, returns the complete, correct Task result immediately, every time.

Second failure mode (reproduced only after the 1.1.2/2.6.3 upgrade)

Using google.adk.agents.remote_a2a_agent.RemoteA2aAgent with ClientConfig(streaming=True), pointed at a second deployed Agent Engine agent that the first agent delegates to (orchestrator -> specialist, both independently deployed as their own reasoningEngines resources), on a2a-sdk==1.1.2 / google-adk==2.6.3 on both ends:

ERROR: A2A request failed: append=True for nonexistent artifact_id='...' in task '...'.
The artifact must be created (append=False) before appending parts to it.

Reproduced twice, on two separate calls with different task/artifact IDs, same failure shape both times. Using ClientConfig(streaming=False) for the identical delegation call works correctly every time (this is the workaround currently in place).

Versions tested (all four combinations)

Client Server (deployed) Result
a2a-sdk 1.1.1 / google-adk 2.5.0 a2a-sdk 1.1.1 / google-adk 2.5.0 Truncates after WORKING
a2a-sdk 1.1.2 / google-adk 2.6.3 a2a-sdk 1.1.1 / google-adk 2.5.0 (unchanged) Identical truncation
a2a-sdk 1.1.2 / google-adk 2.6.3 a2a-sdk 1.1.2 / google-adk 2.6.3 RestTransport raw call: identical truncation. RemoteA2aAgent delegation call: the "append=True for nonexistent artifact_id" error above

Expected behavior

message:stream against a deployed Agent Engine target should deliver the same events a message:send call resolves to, in the correct order, without a gap between WORKING and the final artifact/completion -- matching the behavior already observed against a local (non-Agent-Engine) A2A server with byte-identical agent code.

Environment

  • Deployment: google-cloud-aiplatform[agent_engines,adk], Vertex AI Agent Engine / Reasoning Engine, standard AdkApp wrapping (not BYOD custom container)
  • Python 3.12
  • a2a-sdk: 1.1.1 and 1.1.2 (both tested, both affected)
  • google-adk: 2.5.0 and 2.6.3 (both tested, both affected)

Additional context

This looks like it lives in Agent Engine's own REST-wrapped proxy layer between the client and the deployed container's A2A server, rather than in either Python library directly -- the identical agent code, unmodified, streams correctly end-to-end against a local (non-Agent-Engine) A2A server. Happy to share a minimal repro repo if useful.

Activity

  1. chelsealong commented on Aug 11, 2026

    @chelsealong
    Contributor

    Picking this one up now — opening a PR shortly. Flagging it here so nobody duplicates the work; if someone is already on it, say so and I will drop mine.

  2. surajksharma07 commented on Aug 12, 2026

    @surajksharma07
    Collaborator

    @virktapvir Looks like the streamed artifact's last chunk was going out with append=false against an artifact_id that already existed, which explains the overwrite.
    #6686 flips that flag so it should append correctly.

    Could you try that branch against your actual deployed Agent Engine setup and confirm it clears both symptoms before it merges?
    If it still drops after that the rest is likely on the Agent Engine proxy side and that minimal repro repo you offered would help us chase it down.

  3. added
    request clarification
    a2a
    on Aug 12, 2026
  4. virktapvir commented on Aug 12, 2026

    @virktapvir
    Author

    @surajksharma07 @chelsealong — tested #6686 against a real deployed Agent Engine target today. Results, both confirmed live:

    Fixed by #6686: the append=True for nonexistent artifact_id crash on the RemoteA2aAgent-mediated delegation path (orchestrator → specialist) is gone with the fix applied.

    Not fixed by #6686: direct message:stream against a deployed target still truncates after TASK_STATE_WORKING/TASK_STATE_SUBMITTED, with the PR branch applied. Reproduced cleanly against a minimal, tool-free, single-purpose test agent (no QBR-specific complexity) — sometimes 0 chunks delivered, sometimes a small fraction, never a completion event.

    Per your suggestion, I dug further to localize the remaining bug rather than just report the symptom:

    • Read the persisted session directly (VertexAiSessionService.get_session, bypassing the stream entirely) for a run where the client received 0 characters — the full, complete, coherent ~15k-character response was sitting there, correctly generated. The model/generation side is not at fault.
    • Deployed the same agent (same model config, same prompt) via the classic AdkApp template instead of A2aAgent, and called it through the native async_stream_query/:streamQuery operation — bypassing A2A's message:stream/RestTransport entirely. That delivered the complete response cleanly in one shot, every time tested.

    So: model generation works, Agent Engine's own native streaming operation works, A2A's message:stream specifically does not. That's consistent with your instinct that "the rest is likely on the Agent Engine proxy side" — this doesn't look like it's in adk-python or a2a-sdk's client code at this point, but in Agent Engine's own A2A SSE relay.

    Happy to share the minimal repro agent + test script if it'd help narrow it down further on your end.

  5. virktapvir commented on Aug 12, 2026

    @virktapvir
    Author
    import asyncio
    import sys
    import uuid
    
    import google.auth
    import google.auth.transport.requests
    import httpx
    from a2a.client.transports.rest import RestTransport
    from a2a.types import Message, Part, Role, SendMessageRequest
    from a2a.utils.constants import PROTOCOL_VERSION_CURRENT, VERSION_HEADER
    
    REGION = "northamerica-northeast1"
    
    # A long, open-ended prompt is deliberate: it forces a genuinely multi-chunk
    # streamed response, so streaming and non-streaming delivery would visibly
    # differ -- a short answer completes in one chunk either way and proves
    # nothing about streaming behavior specifically.
    QUESTION = (
        "Write a long, detailed explanation of how photosynthesis works, "
        "covering the light-dependent reactions, the Calvin cycle, the role of "
        "chlorophyll, and how environmental factors like light intensity, CO2 "
        "concentration, and temperature affect the overall rate."
    )
    
    
    def _read_default_resource_name() -> str:
        import os
        from pathlib import Path
    
        from dotenv import load_dotenv
    
        repo_root = Path(__file__).resolve().parents[2]
        load_dotenv(repo_root / ".env")
        resource_name = os.environ.get("STREAMING_TEST_ENGINE_ID")
        if not resource_name:
            raise SystemExit(
                "STREAMING_TEST_ENGINE_ID is not set (.env or environment) -- deploy "
                "first via scripts/adk_pilot/deploy_streaming_test.py, or pass the "
                "resource name as an argument."
            )
        return resource_name
    
    
    async def main(resource_name: str, out_path: str) -> None:
        base_url = f"https://{REGION}-aiplatform.googleapis.com/v1beta1/{resource_name}/a2a"
        print(f"Target: {resource_name}")
        print(f"URL: {base_url}")
    
        creds, _ = google.auth.default(scopes=["https://www.googleapis.com/auth/cloud-platform"])
        creds.refresh(google.auth.transport.requests.Request())
    
        context_id = str(uuid.uuid4())
        # user_id has to match what HdaipA2aAgentExecutor derives from the
        # message metadata (see _extract_from_context/resolve equivalents) --
        # '[email protected]' below, hardcoded to match -- so
        # get_session(session_id=context_id, user_id=...) can find the same
        # session this run created, for a direct persisted-session comparison.
        user_id = "[email protected]"
        print(f"context_id (session_id): {context_id}")
        print(f"user_id: {user_id}")
    
        async with httpx.AsyncClient(
            timeout=300.0,
            headers={
                "Authorization": f"Bearer {creds.token}",
                VERSION_HEADER: PROTOCOL_VERSION_CURRENT,
            },
        ) as http:
            transport = RestTransport(httpx_client=http, agent_card=None, url=base_url)
    
            message = Message(
                role=Role.ROLE_USER,
                message_id=str(uuid.uuid4()),
                context_id=context_id,
                metadata={"user_email": user_id},
                parts=[Part(text=QUESTION)],
            )
    
            print("\nStreaming message:stream ...\n")
            event_count = 0
            last_state = None
            artifact_texts = []
            try:
                async for event in transport.send_message_streaming(
                    SendMessageRequest(message=message)
                ):
                    event_count += 1
                    which = event.WhichOneof("payload")
                    payload = getattr(event, which)
                    print(f"[{event_count}] {which}", end="")
                    state = getattr(getattr(payload, "status", None), "state", None)
                    if state is not None:
                        last_state = state
                        print(f" state={state}", end="")
                    artifact = getattr(payload, "artifact", None)
                    if artifact is not None:
                        parts_text = "".join(
                            p.text for p in artifact.parts if getattr(p, "text", None)
                        )
                        append = getattr(payload, "append", None)
                        last_chunk = getattr(payload, "last_chunk", None)
                        print(
                            f" artifact_id={artifact.artifact_id} append={append} "
                            f"last_chunk={last_chunk} len(text)={len(parts_text)}",
                            end="",
                        )
                        artifact_texts.append(parts_text)
                    print()
            except Exception as exc:  # noqa: BLE001 -- this IS the thing under test
                print(f"\n*** STREAM RAISED: {type(exc).__name__}: {exc}")
                raise
            finally:
                print(f"\nTotal events: {event_count}")
                print(f"Last status state seen: {last_state}")
                total_len = sum(len(t) for t in artifact_texts)
                print(f"Total streamed artifact text length: {total_len} chars "
                      f"across {len(artifact_texts)} artifact event(s)")
    
                full_text = "".join(artifact_texts)
                print(f"\nFULL reconstructed text delivered before cutoff "
                      f"({len(full_text)} chars) -- written to {out_path}")
                from pathlib import Path
                Path(out_path).write_text(
                    f"context_id: {context_id}\nuser_id: {user_id}\n"
                    f"resource_name: {resource_name}\n\n{full_text}\n"
                )
                expected_completed = 3  # TaskState.TASK_STATE_COMPLETED, confirmed via a2a.types
                if last_state != expected_completed:
                    print(
                        f"\n*** TRUNCATED: stream ended at state={last_state}, never "
                        f"reached TASK_STATE_COMPLETED ({expected_completed})."
                    )
    
    
    if __name__ == "__main__":
        target = sys.argv[1] if len(sys.argv) > 1 else _read_default_resource_name()
        output_path = sys.argv[2] if len(sys.argv) > 2 else "/tmp/streaming_test_full_text.txt"
        asyncio.run(main(target, output_path))
    
    
  6. surajksharma07 commented on Aug 17, 2026

    @surajksharma07
    Collaborator

    @virktapvir Glad #6686 clears the delegation crash, getting it moving toward merge. The remaining message:stream truncation is a different animal though. Your isolation (full response persisted server-side, native :streamQuery clean, only A2A's stream broken) lines up with this living in Agent Engine's own SSE relay rather than anything in adk-python or a2a-sdk so it's not something we can fix from this repo. Keeping this issue open for that half.

    Could you route it through Cloud Support so it lands with the team that owns that layer?
    Happy to reference this thread and your repro script there if that helps move it along.

    Team is looking more into it.
    Thanks!

  7. virktapvir commented on Sep 17, 2026

    @virktapvir
    Author

    @surajksharma07
    GCP fixed the issue on their end and Confirmed resolved on our end — thank you. Re-tested message:stream. Stream is terminating correctly at TASK_STATE_COMPLETED.
    One related item: our passing configuration depends on an unmerged client-side fix, google/adk-python PR #6686 (issue #6680). When this can be merged?

  8. surajksharma07 commented on Sep 18, 2026

    @surajksharma07
    Collaborator

    @virktapvir Glad to hear GCP closed out the proxy half, thanks for tracking that all the way through and confirming it live.

    On #6686 merging: not yet, and need to flag something I found while re-verifying it rather than just merge it on your confirmation.

    @chelsealong #6686's source change conflicts with a test you added yourself. Applied #6686's from_adk_event.py hunk in isolation against current main and ran the existing suite: it fails test_convert_event_to_a2a_events_final_chunk_replaces, which your commit 81873e2 ("test: add test for final chunk replacing accumulated artifact", PiperOrigin-RevId 966350716, 2026-08-17, after #6686 was opened) added specifically to pin append=False on the final chunk with the docstring reasoning "because it contains the accumulated content."

    That reasoning checks out against the actual streaming code. google_llm.py's SSE path (~line 296-301) explicitly says the final non-partial event is "an accumulated event which contains all the previous partial content," not a delta. And traced append=True all the way through: both ADK's server-side task path and RemoteA2aAgent's own client-side stream normalizer (a2a/_compat.py::make_stream_normalizer) go through the same append_artifact_to_task which does existing_artifact.parts.extend(...) on append=True. So if the final chunk really does carry the full accumulated text and #6686 forces append=True on it every multi-chunk streamed response gets its full text appended on top of everything already streamed, trading the crash for a silent duplication bug in the far more common single-agent streaming case.

    Don't think this means #6686 fixed nothing. @virktapvir's delegation-crash repro was real and reproducible and something in that path does need fixing. But given your own Aug 17 commit already concluded the opposite of what #6686's fix does I'd rather understand why before merging either one. @chelsealong does the "nonexistent artifact_id" crash on the delegation path have a distinct root cause from the append/partial flag, something specific to how RemoteA2aAgent's client-side normalizer handles the first chunk of a delegated sub-agent's stream maybe rather than the last? Worth re-diagnosing with the accumulated-final-chunk fact in hand rather than reworking #6686 in place.

  9. chelsealong commented on Sep 22, 2026

    @chelsealong
    Contributor

    @surajksharma07 — you were right, and the answer to your question is yes: the delegation-path crash has a distinct root cause, and it is on the client side, in how make_stream_normalizer handles a running-Task snapshot — not the first or last chunk's flag.

    if kind == "task":
      state["task"] = payload   # replaces the aggregate wholesale

    A snapshot carries status and (from servers and proxies alike) no artifacts. When one arrives after the first append=False chunk has been folded in, that artifact is gone from the aggregate, and the next append=True chunk raises inside append_artifact_to_task with exactly the reported message. Reproduced through the real normalizer on a2a-sdk 1.1.5, using the flags the server actually sends:

      ok     A: chunk1(append=F), chunk2(append=T)
      ok     B: snapshot, chunk1, chunk2
      CRASH  C: chunk1, SNAPSHOT, chunk2   → append=True for nonexistent artifact_id=...
    

    So #6686 was fixing the wrong thing, and would have introduced the duplication you traced through append_artifact_to_task. I've closed it. #7230 merges the snapshot into the running aggregate instead of replacing it (artifacts the snapshot lacks are carried over; ones it carries win), leaves from_adk_event.py and the final-chunk-replaces semantics untouched, and pins sequence C as a regression test — it fails on main with the reported error and passes with the fix; the full a2a suite is 725 passed.

    @virktapvir — your passing configuration should not need #6686. If you can re-run the deployed Agent Engine delegation repro against #7230's branch without #6686, that would confirm it on the real path; the sequence above is the one your trace implies (the proxy emitting a Task state between artifact events). Sorry for the slow reply here.

  10. virktapvir commented on Sep 23, 2026

    @virktapvir
    Author

    @chelsealong @surajksharma07 I re-ran the deployed repro against #7230 without #6686. #7230 fixes it.

    Setup

    Results

    • Stock RemoteA2aAgent → deployed streaming test agent: 4/4 runs clean. Each streamed ~2,000–2,900 words, and none hit a nonexistent artifact_id error.
    • Full delegation path (client → orchestrator engine → specialist engine):
      • The stream reaches TASK_STATE_COMPLETED.
      • It carries 13 status updates and 1 artifact update.
      • The complete answer (~1.3k chars of JSON) arrives intact, in about 51s.

    So with snapshot-merge in place, keeping append=False on the final chunk (per 81873e2) behaves correctly end to end. Thanks for tracking down the real cause.

    One observation, in case it's useful

    On 2.9.2 with streaming enabled, the stock RemoteA2aAgent yields only partial=True events for a delegated turn and never a terminal non-partial Event. ADK doesn't persist partial events to the session. That means the parent agent never gets the specialist's answer as a final response unless something assembles it.

    We work around this with a small subclass: it passes the partial events through (so live streaming still works), buffers their text, and emits one non-partial event when the stream ends.

    Is that expected on the streaming path, or should RemoteA2aAgent emit an aggregated final event itself? If you'd prefer, I can open a separate issue for it.

    @samvallad33, on your question

    In our case those were two separate bugs, and neither fix is "create the artifact before append":

    • nonexistent artifact_id: the artifact was created. The client's make_stream_normalizer then replaced its aggregate with an incoming Task snapshot, which dropped the artifact, so the next append=True chunk had nothing to append to. fix(a2a): keep streamed artifacts when a Task snapshot arrives mid-stream #7230 merges the snapshot instead, and the error is gone in the runs above.
    • Truncation after TASK_STATE_WORKING: this was Agent Engine's SSE relay dropping the terminal event, which Google fixed on the server side around 2026-09-17. It was a race, so it only showed up on some runs.

    I do agree with the second half of your suggestion as separate hardening. A stream that closes without reaching a terminal state (COMPLETED / FAILED / CANCELED / INPUT_REQUIRED) should raise an error instead of silently returning a partial result.

  11. added
    spam
    on Sep 24, 2026
  12. adk-bot commented on Sep 24, 2026

    @adk-bot
    Collaborator

    🚨 Automated Spam Detection Alert 🚨
    @maintainers, a suspected spam comment was detected in this thread.

    Reason:

    @samvallad33 posted promotional content for a 3rd-party service/website named 'Vestige' ('a digital sanctuary to help curate and preserve personal life milestones and memories'), which is completely unrelated to the repository and the issue.
    
  13. surajksharma07 commented on Sep 24, 2026

    @surajksharma07
    Collaborator

    Thanks @virktapvir for re-running it on the deployed engines without #6686 and @chelsealong for tracking down the real cause. Checked #7230 locally with a2a-sdk 1.1.5. On current main and on 2.9.2 the normalizer still swaps its aggregate for the Task snapshot so chunk -> snapshot -> chunk fails with the exact "append=True for nonexistent artifact_id" error. With #7230 it completes and the final append=False chunk still replaces the text rather than duplicating it. Its two new tests fail on main's source and pass with the fix and the a2a suite is 726 passed with it merged on top of main.

    Not in a release yet (2.9.2 is still the latest) so keep your #7230 pin or streaming=False on the delegation call until it's merged and shipped. Getting it in front of the reviewers now. One small thing for the review: a status-only snapshot still replaces the running task's history so any status messages collected before it are dropped. Probably fine but a comment or a test for it would help.

    The partial-only events question is now in #7255/#7256 so let's continue it there. With the truncation fixed on the Agent Engine side and #6686 closed this issue can close once #7230 lands.

  14. virktapvir commented on Oct 2, 2026

    @virktapvir
    Author

    Status check against the latest releases, in case it helps the review of #7230.

    #7230 is not in v2.10.0 or v2.11.0. On the v2.11.0 tag, make_stream_normalizer in src/google/adk/a2a/_compat.py still replaces the aggregate when a running Task snapshot arrives:

    if kind == "task":
      state["task"] = payload

    So the chunk -> snapshot -> chunk sequence that raises append=True for nonexistent artifact_id should still fail on stock v2.11.0. This is from reading the source at the tag; I have not re-run the deployed repro on 2.11.0. #7230 is still open with no review activity since Sep 22.

    One adjacent change did ship in v2.10.0: e29ee23 ("report an A2A stream that ends before the remote task finishes", closes #6585). It touches a2a/_compat.py and agents/remote_a2a_agent.py. That looks like the hardening discussed earlier in this thread (a stream that closes without a terminal state should raise instead of returning a partial result). We haven't tested it, so I can't say whether it covers every case.

    We are staying on the #7230 build (plus #7256 for the final aggregated event, see #7255) until #7230 is merged and released. Thanks for getting it in front of reviewers — happy to re-run the deployed delegation repro against a newer branch or release if that helps.

  15. added a commit that references this issue on Oct 5, 2026
    71c4fd7
  16. surajksharma07 commented on Nov 3, 2026

    @surajksharma07
    Collaborator

    Thanks @virktapvir for the status checks. Quick update since then: #7230 merged as 71c4fd7 on Oct 4 and is in v2.12.0 (and v2.13.0). Checked make_stream_normalizer at those tags: it now merges a Task snapshot into the running aggregate and carries over any artifacts the snapshot lacks, so chunk -> snapshot -> chunk no longer hits “append=True for nonexistent artifact_id”. It also works on a copy of the snapshot now instead of mutating the payload in place.

    So you can drop the #7230 pin and the streaming=False workaround on the delegation call by upgrading to 2.12.0 or later. If a re-run of your deployed delegation repro on 2.13.0 comes out clean that would close the loop here.

    The partial-only events gap is the one piece left. That’s tracked in #7255, which @willie3838 has picked up internally, building on #7256. Keep #7256 in your fork until that lands and let’s continue there. Nothing else is pending on this issue so it can stay closed.

  17. virktapvir commented on Nov 3, 2026

    @virktapvir
    Author

    Thanks @surajksharma07, that matches what we see. We moved to 2.13.0 and re-ran the deployed delegation path on Agent Runtime: an orchestrator engine delegating over message:stream (stock RemoteA2aAgent, no streaming=False workaround) to two specialist engines. The #7230 pin is gone.

    Results, measured at a client streaming from the orchestrator engine (RestTransport.send_message_streaming):

    Turn Events Stream Final answer
    Conversational question, one specialist 17 (1 task, 15 WORKING status updates from 0.6s to 39s, 1 artifact update) 55s one artifact, 1,222 chars, then TASK_STATE_COMPLETED
    Long structured report, other specialist 7 (1 task, 5 status updates, 1 artifact update) 290s one artifact, 26,446 chars, then TASK_STATE_COMPLETED

    One thing others may hit on the same upgrade: on 2.13.0, VertexAiMemoryBankService.add_events_to_memory needs google-cloud-agentplatform>=2.2 (it raises an ImportError otherwise), so deployments pinned to google-cloud-aiplatform 1.x get no Memory Bank writes until they bump both packages.

    From our side nothing else is pending on this issue, so it can stay closed.

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

Metadata

Metadata

Labels

a2arequest clarificationspam

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions