Skip to content

Python: Add Python A2A agent-as-function-tools sample#4889

Open
giles17 wants to merge 2 commits intomicrosoft:mainfrom
giles17:new-a2a-samples
Open

Python: Add Python A2A agent-as-function-tools sample#4889
giles17 wants to merge 2 commits intomicrosoft:mainfrom
giles17:new-a2a-samples

Conversation

@giles17
Copy link
Contributor

@giles17 giles17 commented Mar 24, 2026

What this does

Adds a new sample at python/samples/04-hosting/a2a/a2a_agent_as_function_tools.py that:

  • Resolves a remote A2A agent card and discovers its skills
  • Converts each skill into a FunctionTool via A2AAgent.as_tool()
  • Registers those tools with a host agent using AzureOpenAIResponsesClient
  • The host agent autonomously selects and invokes the appropriate A2A skill

Also updates the README.md with the new sample entry, environment variables, and quick-start instructions.

Port of the .NET A2AAgent_AsFunctionTools sample to Python.
Resolves a remote A2A agent card, converts each skill to a
FunctionTool via as_tool(), and registers them with a host agent
using AzureOpenAIResponsesClient.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings March 24, 2026 21:37
@markwallace-microsoft markwallace-microsoft added documentation Improvements or additions to documentation python labels Mar 24, 2026
@giles17 giles17 enabled auto-merge March 24, 2026 21:37
@github-actions github-actions bot changed the title Add Python A2A agent-as-function-tools sample Python: Add Python A2A agent-as-function-tools sample Mar 24, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a Python sample demonstrating how to discover a remote A2A agent’s skills and expose each skill as a FunctionTool so a host AzureOpenAIResponsesClient agent can autonomously choose and invoke those skills.

Changes:

  • Added a2a_agent_as_function_tools.py sample that resolves an AgentCard, turns skills into tools, and runs a host agent.
  • Updated the A2A samples README with the new entry, required environment variables, and quick-start steps.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
python/samples/04-hosting/a2a/a2a_agent_as_function_tools.py New runnable sample: resolve AgentCard, map skills → FunctionTools, run host agent against Azure OpenAI Responses.
python/samples/04-hosting/a2a/README.md Documents the new sample and adds quick-start guidance and env vars.

as_tool() only auto-sanitizes when name is omitted. Since we pass
skill.name explicitly, we need to strip special characters ourselves.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation python

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants