-
Notifications
You must be signed in to change notification settings - Fork 1.5k
docs: Add clarifying documentation for FoundryAgent vs FoundryChatClient #5161
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
beyondszine
wants to merge
4
commits into
microsoft:main
Choose a base branch
from
beyondszine:fix/5160-foundry-docs
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+134
−0
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
3eaa5a2
docs: Add clarifying documentation for FoundryAgent vs FoundryChatClient
openhands-agent 28533cd
docs: Fix method name in FoundryChatClient example
openhands-agent b1de7da
Merge branch 'main' into fix/5160-foundry-docs
beyondszine af9f226
docs: Fix Copilot review comments
openhands-agent File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,134 @@ | ||
| # Azure AI Foundry Integration | ||
|
|
||
| ## Overview | ||
|
|
||
| The Agent Framework provides two primary integration points for Azure AI Foundry: | ||
|
|
||
| | Class | Purpose | When to Use | | ||
| | --- | --- | --- | | ||
| | `FoundryAgent` / `RawFoundryAgent` | Connect to **existing** Foundry agents | When you want to use an agent that's already configured in Foundry (PromptAgent or HostedAgent) | | ||
| | `FoundryChatClient` / `RawFoundryChatClient` | Create a chat client for **model deployments** | When you want direct chat access to a model through Foundry without using a pre-configured agent | | ||
|
|
||
| ## Key Differences | ||
|
|
||
| ### FoundryAgent — Connect to Existing Agents | ||
|
|
||
| Use `FoundryAgent` (recommended) when: | ||
|
|
||
| - You have an existing **PromptAgent** or **HostedAgent** in Foundry | ||
| - You want the agent's predefined behavior, tools, and instructions | ||
| - You need agent-level middleware, telemetry, and function invocation support | ||
|
|
||
| Use `RawFoundryAgent` when: | ||
|
|
||
| - You want the lower-level agent wrapper without agent-level middleware/telemetry layers | ||
| - You want to provide a custom client via `client_type` parameter | ||
|
|
||
| **Required parameters:** | ||
| - `project_endpoint` — The Foundry project endpoint URL | ||
| - `agent_name` — The name of the existing Foundry agent to connect to | ||
| - `agent_version` — Required for PromptAgents, optional for HostedAgents | ||
| - `credential` — Azure credential for authentication | ||
|
|
||
| **Example:** | ||
| ```python | ||
| from agent_framework.foundry import FoundryAgent | ||
| from azure.identity import AzureCliCredential | ||
|
|
||
| # Connect to a PromptAgent | ||
| agent = FoundryAgent( | ||
| project_endpoint="https://your-project.services.ai.azure.com", | ||
| agent_name="my-prompt-agent", | ||
| agent_version="1.0", | ||
| credential=AzureCliCredential(), | ||
| ) | ||
| result = await agent.run("Hello!") | ||
|
|
||
| # Connect to a HostedAgent (no version needed) | ||
| agent = FoundryAgent( | ||
| project_endpoint="https://your-project.services.ai.azure.com", | ||
| agent_name="my-hosted-agent", | ||
| credential=AzureCliCredential(), | ||
| ) | ||
| ``` | ||
|
|
||
| ### FoundryChatClient — Direct Model Access | ||
|
|
||
| Use `FoundryChatClient` (recommended) when: | ||
|
|
||
| - You want to chat directly with a model deployment through Foundry | ||
| - You don't need a pre-configured agent — you provide the instructions | ||
| - You want full control over the chat interaction | ||
| - You need chat middleware, telemetry, and function invocation support | ||
|
|
||
| Use `RawFoundryChatClient` when: | ||
|
|
||
| - You want the lower-level chat client without wrapper layers | ||
| - You want to build a custom client via subclassing | ||
|
|
||
| **Required parameters:** | ||
| - `project_endpoint` — The Foundry project endpoint URL | ||
| - `model` — The model deployment name | ||
| - `credential` — Azure credential for authentication | ||
|
|
||
| **Example:** | ||
| ```python | ||
| from agent_framework import Message | ||
| from agent_framework.foundry import FoundryChatClient | ||
| from azure.identity import AzureCliCredential | ||
|
|
||
| client = FoundryChatClient( | ||
| project_endpoint="https://your-project.services.ai.azure.com", | ||
| model="gpt-4o", | ||
| credential=AzureCliCredential(), | ||
| ) | ||
|
|
||
| response = await client.get_response(messages=[Message(user_content="Hello!")]) | ||
| print(response.text) | ||
| ``` | ||
|
|
||
| ## When to Use Each | ||
|
|
||
| | Scenario | Recommended Class | | ||
| | --- | --- | | ||
| | Use a PromptAgent configured in Foundry with specific instructions, tools, and behavior | `FoundryAgent` | | ||
| | Use a HostedAgent (custom runtime agent) in Foundry | `FoundryAgent` | | ||
| | Chat directly with a model deployment without an agent wrapper | `FoundryChatClient` | | ||
| | Build a custom agent experience with your own instructions | `FoundryChatClient` + `Agent` | | ||
| | Need full middleware/telemetry support | Use `FoundryAgent` or `FoundryChatClient` (not raw variants) | | ||
| | Need minimal overhead, custom client subclass | Use `RawFoundryChatClient`, or for agent connections provide a raw agent chat client via `client_type=RawFoundryAgentChatClient` | | ||
|
|
||
| ## Raw vs. Recommended Variants | ||
|
|
||
| Each class has both a **raw** and **recommended** variant: | ||
|
|
||
| | Recommended | Raw | Description | | ||
| | --- | --- | --- | | ||
| | `FoundryAgent` | `RawFoundryAgent` | Connects to an existing Foundry agent, but without the additional **agent-level** middleware and telemetry layers that `FoundryAgent` adds | | ||
| | `FoundryChatClient` | `RawFoundryChatClient` | Chat client variant without the recommended wrapper's middleware and telemetry layers | | ||
|
|
||
| The raw variants are lower-level building blocks, but they are not identical: | ||
|
|
||
| - `RawFoundryAgent` still defaults to an internal client stack that includes function invocation, chat middleware, and chat telemetry. Compared to `FoundryAgent`, it omits the extra **agent-level** middleware and telemetry layers. | ||
| - `RawFoundryChatClient` is the lower-level chat client variant when you do not want the recommended wrapper layers. | ||
|
|
||
| If you truly need a raw Foundry agent chat client, use `client_type=RawFoundryAgentChatClient`. | ||
|
|
||
| Use raw variants when you need lower-level control or want to build a custom client composition via subclassing. | ||
|
|
||
| ## Environment Variables | ||
|
|
||
| Both integrations support environment variable configuration: | ||
|
|
||
| | Variable | Used By | Description | | ||
| | --- | --- | --- | | ||
| | `FOUNDRY_PROJECT_ENDPOINT` | Both | Foundry project endpoint URL | | ||
| | `FOUNDRY_AGENT_NAME` | `FoundryAgent` | Name of the Foundry agent | | ||
| | `FOUNDRY_AGENT_VERSION` | `FoundryAgent` | Version of the agent (PromptAgents) | | ||
| | `FOUNDRY_MODEL` | `FoundryChatClient` | Model deployment name | | ||
|
|
||
| ## Packages | ||
|
|
||
| | Package | Source | | ||
| | --- | --- | | ||
| | `agent-framework-foundry` | [`python/packages/foundry`](../../../python/packages/foundry) | | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.