Skip to content

[BUG] An error occurred during processing at the end of agent chat #859

Closed

Description

@linsun

📋 Prerequisites

  • I have searched the existing issues to avoid creating a duplicate
  • By submitting this issue, you agree to follow our Code of Conduct
  • I am using the latest version of the software
  • I have tried to clear cache/cookies or used incognito mode (if ui-related)
  • I can consistently reproduce this issue

🎯 Affected Service(s)

Not Sure

🚦 Impact/Severity

No impact (Default)

🐛 Bug Description

using 0.5.5

This showed up in my demo in AI_Dev live, and pretty easy to reproduce with the AIRE-agent. The PR/Branch did get created not sure why it is reporting an errror. No obvious error in the log other than this in the agent log:

 Warning: Error during MCP session cleanup for session_no_headers: Attempted to exit cancel scope in a different task than it was entered in                                                   │
│ INFO:google_adk.google.adk.runners:Successfully closed toolset: MCPToolset

🔄 Steps To Reproduce

deploy AIRE-agent
ask it to debug a cluster. In the cluster, i had argo deployed my gen-ai-demo app with path kubernetes.
I used agentgateway as the ingress gw.

🤔 Expected Behavior

No error (everything appears to be working in my case) or a helpful error show to the user.

📱 Actual Behavior

see screenshot attached

💻 Environment

No response

🔧 CLI Bug Report

No response

🔍 Additional Context

No response

📋 Logs

📷 Screenshots

attached

🙋 Are you willing to contribute?

  • I am willing to submit a PR to fix this issue

Activity

  1. added theissue type on Sep 4, 2025
  2. linsun commented on Sep 4, 2025

    @linsun
    CollaboratorAuthor
  3. linsun commented on Sep 4, 2025

    @linsun
    CollaboratorAuthor
    Image
  4. EItanya commented on Sep 4, 2025

    @EItanya
    Contributor

    Here is a task history for more data:

            {
              "kind": "message",
              "messageId": "25c5de86-f3aa-446f-baf4-a6363e150846",
              "parts": [
                {
                  "kind": "data",
                  "data": {
                    "id": "adk-0badfaed-045d-4187-8988-eb45532bec11",
                    "name": "k8s_get_resource_yaml",
                    "response": {
                      "result": {
                        "content": [
                          {
                            "text": "<data_here>",
                            "type": "text"
                          }
                        ],
                        "isError": false
                      }
                    }
                  },
                  "metadata": {
                    "adk_type": "function_response"
                  }
                }
              ],
              "role": "agent"
            },
            {
              "kind": "message",
              "messageId": "8bdfd1c5-18e4-4eb8-ab46-12a545759f5d",
              "metadata": {
                "adk_error_code": "STOP"
              },
              "parts": [
                {
                  "kind": "text",
                  "text": "An error occurred during processing"
                }
              ],
              "role": "agent"
            }
    

    Notice that following the function call there is an adk_error_code: STOP.

    However, after digging into the code it seems as though this is a bug with ADK. After digging into the ADK code I found the following bit: https://github.com/google/adk-python/blob/14484065c64396cebc4a1dde84d6b8b51439b990/src/google/adk/models/llm_response.py#L122. Specifically when paired with the A2A conversion code: https://github.com/google/adk-python/blob/14484065c64396cebc4a1dde84d6b8b51439b990/src/google/adk/a2a/converters/event_converter.py#L382-L387.

    ADK seems to be setting the error_code erroneously if there are no results. However, it seems as though Gemini in this case is returning no results which is interpreted as an error, and ends up bubbling up as one.

  5. VinncentZHZ commented on Sep 5, 2025

    @VinncentZHZ

    When using kagent chat in multi-turn conversations, the following error also occurs:

    WARNING:google_adk.kagent.adk._agent_executor:Runner.close() was cancelled; suppressing during cleanup
    Warning: Error during MCP session cleanup for session_no_headers: Attempted to exit cancel scope in a different task than it was entered in
    ERROR:mcp.client.streamable_http:Error parsing SSE message
    Traceback (most recent call last):
    File "/.kagent/python/.venv/lib/python3.13/site-packages/mcp/client/streamable_http.py", line 174, in _handle_sse_event
    await read_stream_writer.send(session_message)
    File "/.kagent/python/.venv/lib/python3.13/site-packages/anyio/streams/memory.py", line 243, in send
    self.send_nowait(item)
    ~~~~~~~~~~~~~~~~^^^^^^
    File "/.kagent/python/.venv/lib/python3.13/site-packages/anyio/streams/memory.py", line 212, in send_nowait
    raise ClosedResourceError
    anyio.ClosedResourceError
    Warning: Error during MCP session cleanup for session_no_headers: Attempted to exit cancel scope in a different task than it was entered in

  6. EItanya commented on Sep 10, 2025

    @EItanya
    Contributor

    This issue was fixed by #875

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions