Skip to content

"Failed to load API definition" error when using docs api from adk web server #3526

@zmy1116

Description

@zmy1116

Describe the bug
After launching dev server using adk web, when I want to see api definitions with http://localhost:8000/docs

I got error Failed to load API definition.

To Reproduce
Please share a minimal code and data to reproduce your problem.
Steps to reproduce the behavior:

  1. Install google-adk
  2. Run adk web
  3. Open http://localhost:8000/docs
  4. get error Failed to load API definition.
    First few lines of the error trace
ERROR:    Exception in ASGI application
Traceback (most recent call last):
  File "/home/envision/Documents/Test3/.venv/lib/python3.10/site-packages/pydantic/type_adapter.py", line 287, in _init_core_attrs
    self.core_schema = _getattr_no_parents(self._type, '__pydantic_core_schema__')
  File "/home/envision/Documents/Test3/.venv/lib/python3.10/site-packages/pydantic/type_adapter.py", line 56, in _getattr_no_parents
    raise AttributeError(attribute)
AttributeError: __pydantic_core_schema__

During handling of the above exception, another exception occurred:

Last few lines of error trace

pydantic.errors.PydanticSchemaGenerationError: Unable to generate pydantic-core schema for <class 'mcp.client.session.ClientSession'>. Set `arbitrary_types_allowed=True` in the model_config to ignore this error or implement `__get_pydantic_core_schema__` on your type to fully support it.

If you got this error by calling handler(<some type>) within `__get_pydantic_core_schema__` then you likely need to call `handler.generate_schema(<some type>)` since we do not call `__get_pydantic_core_schema__` on `<some type>` otherwise to avoid infinite recursion.

For further information visit https://errors.pydantic.dev/2.12/u/schema-for-unknown-type

Expected behavior
I can confirm it works in 1.17, but not in i.18

Screenshots

Image Image Image

Desktop (please complete the following information):

  • OS: linux
  • Python version(python -V): 3.10
  • ADK version(pip show google-adk): 1.18

Model Information:

  • Are you using LiteLLM: No
  • Which model is being used(e.g. gemini-2.5-pro): gemini-2.5-flash

Metadata

Metadata

Labels

web[Component] This issue will be transferred to adk-web

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions