Skip to content

A2A protocol documentation page ignores mount path #58

Description

@AnatoliyAksenov

Hello!
I have encountered an incomprehensible behavior of the framework.

First,
the code from the instruction does not work:

from pydantic_ai import Agent
from fasta2a.pydantic_ai import agent_to_a2a

agent = Agent('openai:gpt-5.5')
app = agent_to_a2a(agent)

It raises the following error:

TaskManager was not properly initialized.

After some googling I have got a working code:

import uvicorn

from contextlib import asynccontextmanager

from fasta2a.pydantic_ai import agent_to_a2a
from starlette.applications import Starlette
from pydantic_ai import Agent
from pydantic_ai.models.openai import OpenAIChatModel
from pydantic_ai.providers.openai import OpenAIProvider


provider = OpenAIProvider(
    base_url='http://localhost:8080/v1',
    api_key="pydantic-ai",
)

model = OpenAIChatModel(
    model_name="Qwen3.6-35B",
    provider=provider,
)

agent = Agent(
    name="Assistant",
    model=model
    )

a2a_app = agent_to_a2a(
    agent,
    name="agent",
    url="http://localhost:8000/agent",  
    version="1.0.0",
)

@asynccontextmanager
async def lifespan(app: Starlette):
    async with a2a_app.router.lifespan_context(a2a_app):
        yield 


app = Starlette(lifespan=lifespan)


app.mount("/agent", a2a_app)

if __name__ == '__main__':
    uvicorn.run(app, port=8000)

And if I visit http://localhost:8000/agent/docs I see the A2A protocol documentation page and chat. But the chat sends requests to the root, ignores the /agent part, and stops working.

And the application log looks like this:

INFO:     127.0.0.1:60182 - "GET /agent/docs HTTP/1.1" 200 OK
INFO:     127.0.0.1:60182 - "GET /.well-known/agent-card.json HTTP/1.1" 404 Not Found
INFO:     127.0.0.1:60182 - "POST / HTTP/1.1" 404 Not Found

If I modify the mount path to the root it works well:

- app.mount("/agent", a2a_app)
+ app.mount("/", a2a_app)

Is there a proper way to specify the root path for the docs page?

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions