Skip to content

Upgrade agent-framework to latest RC#50

Merged
pamelafox merged 6 commits intoAzure-Samples:mainfrom
pamelafox:upgrademaf
Mar 24, 2026
Merged

Upgrade agent-framework to latest RC#50
pamelafox merged 6 commits intoAzure-Samples:mainfrom
pamelafox:upgrademaf

Conversation

@pamelafox
Copy link
Copy Markdown
Contributor

@pamelafox pamelafox commented Mar 24, 2026

Summary

This PR updates the Microsoft Agent Framework examples to the latest API shape and refreshes the related dependencies.

What changed

  • Upgrade agent-framework to >=1.0.0rc5
  • Refresh uv.lock for the updated Agent Framework dependency graph
  • Migrate the Agent Framework examples from the older ChatAgent pattern to Agent
  • Switch the Azure client setup in the Agent Framework examples to the OpenAIChatClient + async DefaultAzureCredential / get_bearer_token_provider pattern
  • Register MCP tools on the agent (tools=[mcp_server]) instead of passing tools at run(...) time
  • Update example response handling to print result.text
  • Update default model IDs in the examples to gpt-4.1-mini
  • Remove the Tavily examples

Tavily removal

The Tavily examples were deleted because the Tavily API key was not being handled in a secure way for these samples, and the Tavily examples were not referenced from the README or slide materials.

Files updated

  • agents/agentframework_http.py
  • agents/agentframework_learn.py
  • pyproject.toml
  • uv.lock

Files removed

  • agents/agentframework_tavily.py
  • agents/langchainv1_tavily.py

Notes

This branch also includes a merge from upstream/main. If GitHub shows additional changes relative to this repository's main, those are from bringing the branch up to date with upstream before applying the Agent Framework migration.

Validation

  • uv sync

The Tavily examples were removed after confirming they were not referenced by the project README or slide-like documentation files.

Copy link
Copy Markdown
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

This PR upgrades the project’s agent-framework dependency to the 1.0.0rc5 release candidate and updates the example agent scripts to align with the newer agent-framework API and dependency graph.

Changes:

  • Bump agent-framework from 1.0.0b251016 to 1.0.0rc5 in pyproject.toml and refresh uv.lock.
  • Update agentframework_* examples to use Agent + OpenAIChatClient (including async Azure credential/token provider flow).
  • Adjust Tavily MCP configuration to pass the Tavily API key via URL query parameters.

Reviewed changes

Copilot reviewed 5 out of 6 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
uv.lock Updates lockfile for agent-framework==1.0.0rc5, introducing new transitive deps/integrations.
pyproject.toml Bumps project dependency requirement to agent-framework>=1.0.0rc5.
agents/langchainv1_tavily.py Updates Tavily MCP connection URL construction (now includes API key in query string).
agents/agentframework_tavily.py Migrates to new agent-framework API and updates Tavily MCP usage.
agents/agentframework_learn.py Migrates to new agent-framework API and updates MCP tool usage.
agents/agentframework_http.py Migrates to new agent-framework API and updates MCP tool usage / long-running behavior.
Comments suppressed due to low confidence (1)

agents/agentframework_tavily.py:72

  • async_credential.close() is only reached on the success path; if an exception occurs during MCP/tool setup or agent.run(), the credential won't be closed. Wrap the agent execution in a try/finally (or use an async context manager, if available) to ensure the Azure credential is always closed.
    if async_credential:
        await async_credential.close()

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Copy Markdown
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

Copilot reviewed 6 out of 7 changed files in this pull request and generated 3 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +26 to +27
client = OpenAIChatClient(
base_url=f"{os.environ['AZURE_OPENAI_ENDPOINT']}/openai/v1/",
Copy link

Copilot AI Mar 24, 2026

Choose a reason for hiding this comment

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

AZURE_OPENAI_ENDPOINT in .env-sample includes a trailing slash, so base_url=f"{os.environ['AZURE_OPENAI_ENDPOINT']}/openai/v1/" will end up with //openai/v1/. Consider stripping any trailing / from the endpoint before appending /openai/v1/.

Suggested change
client = OpenAIChatClient(
base_url=f"{os.environ['AZURE_OPENAI_ENDPOINT']}/openai/v1/",
azure_endpoint = os.environ["AZURE_OPENAI_ENDPOINT"].rstrip("/")
client = OpenAIChatClient(
base_url=f"{azure_endpoint}/openai/v1/",

Copilot uses AI. Check for mistakes.
"langchain-mcp-adapters>=0.1.11",
"azure-ai-agents>=1.1.0",
"agent-framework>=1.0.0b251016",
"agent-framework>=1.0.0rc5",
Copy link

Copilot AI Mar 24, 2026

Choose a reason for hiding this comment

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

Depending on the agent-framework meta-package now pulls in agent-framework-core[all] (see uv.lock), which brings a large set of optional integrations and heavy transitive deps (e.g., pythonnet, durabletask, etc.). If these examples only need the core OpenAI client + MCP tool support, consider depending on agent-framework-core (or a smaller extra set) instead to keep installs lighter and reduce platform-specific dependency risk.

Suggested change
"agent-framework>=1.0.0rc5",
"agent-framework-core>=1.0.0rc5",

Copilot uses AI. Check for mistakes.
Comment on lines +33 to +34
client = OpenAIChatClient(
base_url=f"{os.environ['AZURE_OPENAI_ENDPOINT']}/openai/v1/",
Copy link

Copilot AI Mar 24, 2026

Choose a reason for hiding this comment

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

AZURE_OPENAI_ENDPOINT in .env-sample ends with a trailing slash, so building base_url as f"{os.environ['AZURE_OPENAI_ENDPOINT']}/openai/v1/" produces a double-slash (...azure.com//openai/v1/). This can break request routing in some HTTP stacks. Consider normalizing the endpoint first (e.g., rstrip('/')) before appending the path.

Suggested change
client = OpenAIChatClient(
base_url=f"{os.environ['AZURE_OPENAI_ENDPOINT']}/openai/v1/",
azure_endpoint = os.environ["AZURE_OPENAI_ENDPOINT"].rstrip("/")
client = OpenAIChatClient(
base_url=f"{azure_endpoint}/openai/v1/",

Copilot uses AI. Check for mistakes.
@pamelafox
Copy link
Copy Markdown
Contributor Author

I'm okay with those comments.

@pamelafox pamelafox merged commit edb8aed into Azure-Samples:main Mar 24, 2026
6 checks passed
@pamelafox pamelafox deleted the upgrademaf branch March 24, 2026 14:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants