Skip to content

Add the option to specify the tool descriptions in markdownΒ #3130

@ryx2

Description

@ryx2

Description

Our system prompt and tool descriptions are in markdown. However, when pydantic-ai creates the tool description strings that are passed in, the only option is to wrap it in xml.

So I'm wondering if we could specify an option to allow the tool descriptions to instead be in markdown format.

In pydantic_ai_slim/pydantic_ai/_griffe.py:

         type_tag = f'<type>{return_type}</type>\n' if return_type else ''
         return_xml = f'<returns>\n{type_tag}<description>{return_desc}</description>\n</returns>'
 
         if main_desc:
             main_desc = f'<summary>{main_desc}</summary>\n{return_xml}'
         else:
             main_desc = return_xml

But instead of this, with the .md option, this could be:

type_line = f'**Type:** `{return_type}`\n\n' if return_type else ''
return_md = f'### Returns\n\n{type_line}{return_desc}'

if main_desc:
    main_desc = f'## Summary\n\n{main_desc}\n\n{return_md}'
else:
    main_desc = return_md

References

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions