[Python] Pydantic agent - the agent tool/toolset decorator does not work on top of methods...

Discussão em 'Python' iniciado por Stack, Agosto 21, 2025.

  1. Stack

    Stack Membro Participativo

    I am trying to build a pydantic AI agent When defining my tools, when I pass in my tools along with my agent as parameter as

    chat_agent = Agent(
    model=create_chat_model(),
    output_type=ChatResponse,
    deps_type=ChatAgentDeps,
    tools=[xyz, abc, tst],
    ):


    it works totally fine as expected

    However if i add the decorator as below. it never works and registers the tools. What could be the reasons and how can I fix this? I want my code to look cleaner and easier to extent thus just adding the decorator seemed like a better way for me to register the tool

    @chat_agent.tool
    def xyz(ctx: RunContext[Deps],
    qry,
    ):
    pass


    @chat_agent.tool
    def abc(
    _: RunContext[Deps]
    ):
    pass



    I tried tools, toolset and tool_plain decorators and none of them seem to work

    Continue reading...

Compartilhe esta Página