Expand description
§agent-framework-foundry
An Azure AI Foundry ChatClient and Prompt Agent surface for
agent-framework-rs, built on the Responses API
(POST {endpoint}/openai/v1/responses) rather than the older Agents
threads/runs data plane (removed upstream, along with the azure-ai-agents
SDK it wrapped — see this crate’s own history / UPSTREAM_DRIFT.md).
FoundryChatClient does not speak HTTP/SSE itself: it wraps an
agent_framework_azure::responses::AzureOpenAIResponsesClient
configured for a Foundry project endpoint (Microsoft Entra ID bearer auth
or a static API key), with
without_api_version
applied, since the Foundry v1 GA route is path-versioned
({endpoint}/openai/v1/responses, no ?api-version= query parameter).
All request/response conversion, streaming, and error classification are
reused verbatim from that client (which itself reuses
agent_framework_openai::responses), so wire fidelity comes for free
rather than being re-implemented here.
use std::sync::Arc;
use agent_framework_azure::AzureCliCredential;
use agent_framework_core::prelude::*;
use agent_framework_foundry::{FoundryChatClient, FOUNDRY_SCOPE};
let credential = Arc::new(AzureCliCredential::new(FOUNDRY_SCOPE));
let client = FoundryChatClient::with_token_credential(
"https://my-project.services.ai.azure.com",
"gpt-4o",
credential,
);
let agent = Agent::builder(client).instructions("You are concise.").build();
let reply = agent.run_once("Say hi").await?;
println!("{}", reply.text());§Prompt Agents
FoundryAgent realizes a Foundry Prompt Agent client-side: it
pairs a FoundryChatClient with a PromptAgentDefinition
(name/model/instructions/tools) and runs it over the Responses API through
an inner agent_framework_core::agent::Agent. FoundryAgent::to_prompt_agent
hands back the definition it was built from, mirroring upstream’s
Agent.to_prompt_agent() -> PromptAgentDefinition.
This does not bind to a server-hosted agent by id/name (the Foundry
Agents control plane, e.g. AIProjectClient.agents.get(...)) — see the
FoundryAgent docs for why that’s a documented extension point rather
than something wired up here.
use agent_framework_core::prelude::*;
use agent_framework_foundry::FoundryAgent;
let agent = FoundryAgent::builder(client)
.name("rust-example-agent")
.instructions("You are a helpful, concise assistant.")
.build();
let reply = agent.run(vec![Message::user("Say hi")], None).await?;
println!("{}", reply.text());
// Round-trips the definition the agent was built from.
let definition = agent.to_prompt_agent();
assert_eq!(definition.name, "rust-example-agent");Structs§
- Foundry
Agent - A
SupportsAgentRunthat runs a Foundry Prompt Agent over the Responses API. - Foundry
Agent Builder - Builds a
FoundryAgentfrom aFoundryChatClientplus the pieces of aPromptAgentDefinition(name/instructions/model/tools). - Foundry
Chat Client - A
ChatClientfor the Azure AI Foundry project Responses API. - Prompt
Agent Definition - The serializable definition of a Foundry Prompt Agent: a name, a model, optional instructions/description, and its tools.
Constants§
- FOUNDRY_
SCOPE - The Entra ID scope (audience) for the Azure AI Foundry data plane.