Skip to content

with get_fast_api_app method agent running stops in between with error:Unclosed client session. #2804

@pavan-moe

Description

@pavan-moe

** Please make sure you read the contribution guide and file the issues in the right place. **
Contribution guide.

Describe the bug
While using the FastAPI app, the requests stop suddenly, which is quite random. However, with ADK Web, it is running correctly.

INFO:google_genai.models:AFC is enabled with max remote calls: 10.
ERROR:asyncio: Unclosed client session
client_session: <aiohttp.client.ClientSession object at 0x16f898d10>
INFO:google_adk.google.adk.models.google_llm:Sending out request, model: gemini-2.5-flash, backend: GoogleLLMVariant.GEMINI_API, stream: True

This error is being thrown.

Screenshots
If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • OS: MAC OS 15.5
  • Python version(python -V): 3.12
  • ADK version(pip show google-adk):Name: google-adk Version: 1.13.0

Model Information:
using 2.5-pro and 2.5-flash

from google.adk.cli.fast_api import get_fast_api_app
from config import config

agent_config = config.get_agent_config()
app = get_fast_api_app(
    agents_dir=agent_config["agents_dir"],
    session_service_uri=agent_config["session_service_uri"],
    allow_origins=["*"],
    web=agent_config["web"],
)

Metadata

Metadata

Assignees

No one assigned

    Labels

    mcp[Component] Issues about MCP supporttools[Component] This issue is related to tools

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions