संपादित करें

Foundry Local

Foundry Local lets you run supported Microsoft Foundry models on your local machine while still using the standard Agent Framework Python Agent experience.

Note

Foundry Local is not currently supported in .NET.

Prerequisites

Install Foundry Local and its local runtime components before running Agent Framework against a local model. The first run can take a while because the selected model may need to be downloaded and loaded.

Installation

pip install agent-framework-foundry-local --pre

Configuration

Set the default local model with:

FOUNDRY_LOCAL_MODEL="phi-4-mini"

You can also pass the model explicitly with FoundryLocalClient(model="phi-4-mini").

Note

FoundryLocalClient lives in the agent_framework.foundry namespace. It is a local chat client, so you typically pair it with a standard Agent.

Create a local agent

import asyncio

from agent_framework import Agent
from agent_framework.foundry import FoundryLocalClient

async def main():
    agent = Agent(
        client=FoundryLocalClient(model="phi-4-mini"),
        name="LocalAgent",
        instructions="You are a helpful local assistant.",
    )
    result = await agent.run("What's the weather like in Seattle?")
    print(result)

asyncio.run(main())

Tools

FoundryLocalClient is a local chat client paired with a standard Agent, so the supported tools are the ones the chosen local model can actually call — they are not provided by a hosted runtime. Hosted Foundry tool types (get_code_interpreter_tool, get_web_search_tool, etc.) are not available on FoundryLocalClient.

Tool Status Notes
Function Tools ⚠️ Supported only if the selected local model supports function calling. Use FoundryLocalClient.manager to inspect model capabilities.
Tool Approval Provided by the framework's function-invoking chat client; works with any function-tool call.
Code Interpreter No hosted runtime.
File Search No hosted runtime.
Web Search No hosted runtime.
Hosted MCP Tools Not exposed by the local runtime.
Local MCP Tools Runs in your process and works with any chat client.

Model capabilities

Not every local model supports the same features. Function calling and structured outputs depend on the selected model. The FoundryLocalClient.manager helper can be used to inspect the local catalog and supported capabilities before you run an agent.

For additional runtime controls, FoundryLocalClient also supports options such as device, bootstrap, and prepare_model.

Next steps