Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions src/google/adk/cli/adk_web_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@
from ..sessions.base_session_service import BaseSessionService
from ..sessions.session import Session
from ..utils.context_utils import Aclosing
from ..utils.pydantic_v2_compatibility import create_robust_openapi_function
from ..utils.pydantic_v2_compatibility import patch_types_for_pydantic_v2
from .cli_eval import EVAL_SESSION_ID_PREFIX
from .utils import cleanup
from .utils import common
Expand Down Expand Up @@ -686,6 +688,13 @@ async def internal_lifespan(app: FastAPI):
tracer_provider = trace.get_tracer_provider()
register_processors(tracer_provider)

# Apply Pydantic v2 compatibility patches before creating FastAPI app
patches_applied = patch_types_for_pydantic_v2()
if patches_applied:
logger.info("Pydantic v2 compatibility patches applied successfully")
else:
logger.warning("Pydantic v2 compatibility patches could not be applied")

# Run the FastAPI server.
app = FastAPI(lifespan=internal_lifespan)

Expand All @@ -698,6 +707,12 @@ async def internal_lifespan(app: FastAPI):
allow_headers=["*"],
)

# Replace default OpenAPI function with robust version
app.openapi = create_robust_openapi_function(app)
logger.info(
"Robust OpenAPI generation enabled with Pydantic v2 error handling"
)

@app.get("/list-apps")
async def list_apps() -> list[str]:
return self.agent_loader.list_agents()
Expand Down
Loading