Declarative chat agent node for Azure AI Foundry agents V2.
This module implements the V2 agent node using the azure-ai-projects >= 2.0
library. The main paradigm shift from V1 is:
project_client.agents.create_version() using a
PromptAgentDefinition.openai_client.responses.create() with a conversation context, rather
than the Threads / Runs model of V1.ResponseFunctionToolCall
items in the response output, and results are sent back as
FunctionCallOutput items in the next request.Synthetic tool name used for MCP approval request tool calls.
Extended AgentState that carries per-invocation agent context.
By storing conversation IDs and pending-call type in the graph state (rather than on the node instance), the node becomes thread-safe: concurrent invocations each operate on their own copy of the state, and the graph's checkpointer can persist / restore it across interrupts.
azure_ai_agents_conversation_id : str | None
The Responses-API conversation ID. Created lazily on the first
HumanMessage and reused for subsequent turns.
azure_ai_agents_previous_response_id : str | None
The ID of the most recent Response object, used to chain
tool-call outputs within a single turn.
azure_ai_agents_pending_type : str | None
Indicates whether the last response left unresolved calls:
"function_call", "mcp_approval", or None.
A tool that interacts with Azure AI Foundry Agent Service V2.
Use this class to wrap tools from Azure AI Foundry for use with PromptBasedAgentNodeV2.
Example:
from langchain_azure_ai.agents.prebuilt.tools_v2 import AgentServiceBaseToolV2
from azure.ai.projects.models import CodeInterpreterTool
code_interpreter_tool = AgentServiceBaseTool(tool=CodeInterpreterTool())
Some tools require extra HTTP headers when calling the Responses API.
For example, ImageGenTool requires an
x-ms-oai-image-generation-deployment header:
from azure.ai.projects.models import ImageGenTool
image_tool = AgentServiceBaseToolV2(
tool=ImageGenTool(model="gpt-image-1", quality="low", size="1024x1024"),
extra_headers={
"x-ms-oai-image-generation-deployment": "gpt-image-1",
},
)
All extra_headers from every tool are merged and sent with each
responses.create() call made by the agent node.
A LangGraph node for an existing Azure AI Foundry agent (V2 Responses API).
This node wraps a prompt-based agent that has already been created in Azure AI Foundry. It handles building requests and processing responses using the V2 Responses/Conversations API.
Use :meth:~langchain_azure_ai.agents.v2.AgentServiceFactory.create_prompt_agent_node
to create an agent and obtain a node in a single step, or instantiate this
class directly to reference an existing agent by name.
Example:
from azure.ai.projects import AIProjectClient
from azure.identity import DefaultAzureCredential
from langchain_azure_ai.agents.prebuilt import ResponsesAgentNode
client = AIProjectClient(
endpoint="https://resource.services.ai.azure.com/api/projects/demo-project",
credential=DefaultAzureCredential(),
)
coder = ResponsesAgentNode(
client=client,
name="code-interpreter-agent",
version="latest",
)