Description
Summary
When an Agent Framework agent invokes Code Interpreter through a Foundry FoundryToolbox, Code Interpreter creates the requested file, but the hosted Responses API does not return a native container_file_citation. The customer therefore receives no container_id or file_id and cannot download the generated file through the container-files API.
Reproduction
- Configure a Foundry Toolbox with a
code_interpreter tool
- Create an Agent Framework agent using
FoundryToolbox and ResponsesHostServer
- Ask the agent to write
/mnt/data/result.txt and attach it
- Invoke the hosted agent through its Responses endpoint
- Inspect the response output and message annotations
Observed behavior
The hosted response exposes the tool result as a regular function_call_output, with no file citation. However, a direct MCP tools/call to the same Toolbox returns the required metadata on the text content block:
{
"type": "text",
"text": "...",
"_meta": {
"container_id": "cntr_...",
"container_file_citations": "[{\"file_id\":\"cfile_...\",\"filename\":\"result.txt\",\"container_id\":\"cntr_...\"}]"
}
}
This indicates that Code Interpreter and the Toolbox service produce the artifact identifiers, but Agent Framework does not carry them through to the hosted Responses output. In the Python path, per-content MCP _meta appears to be dropped during MCP result conversion. The hosting adapter also has no conversion from this metadata to a Responses container_file_citation annotation.
Expected behavior
Agent Framework should preserve the per-content metadata and emit an annotation equivalent to:
{
"type": "container_file_citation",
"container_id": "cntr_...",
"file_id": "cfile_...",
"filename": "result.txt"
}
Code Sample
import asyncio
import os
from agent_framework import Agent
from agent_framework.foundry import FoundryChatClient
from agent_framework_foundry_hosting import FoundryToolbox, ResponsesHostServer
from azure.identity import DefaultAzureCredential
async def main():
credential = DefaultAzureCredential()
agent = Agent(
client=FoundryChatClient(
project_endpoint=os.environ["FOUNDRY_PROJECT_ENDPOINT"],
model=os.environ["AZURE_AI_MODEL_DEPLOYMENT_NAME"],
credential=credential,
),
instructions=(
"Use Code Interpreter when asked to create a file. Write files to "
"/mnt/data and attach them to the response."
),
tools=FoundryToolbox(credential),
default_options={"store": False},
)
await ResponsesHostServer(agent).run_async()
if __name__ == "__main__":
asyncio.run(main())
services:
agent-tools:
host: azure.ai.toolbox
uses:
- ai-project
tools:
- type: code_interpreter
name: code_interpreter
repro-agent:
host: azure.ai.agent
project: src/repro-agent
uses:
- ai-project
- agent-tools
protocols:
- protocol: responses
version: 2.0.0
environmentVariables:
- name: AZURE_AI_MODEL_DEPLOYMENT_NAME
value: ${AZURE_AI_MODEL_DEPLOYMENT_NAME}
- name: TOOLBOX_NAME
value: agent-tools
Error Messages / Stack Traces
Package Versions
agent-framework-core==1.10.0 agent-framework-foundry==1.8.2 agent-framework-foundry-hosting==1.0.0a260630 mcp==1.28.0
Python Version
Python 3.14
Additional Context
No response
Description
Summary
When an Agent Framework agent invokes Code Interpreter through a Foundry
FoundryToolbox, Code Interpreter creates the requested file, but the hosted Responses API does not return a nativecontainer_file_citation. The customer therefore receives nocontainer_idorfile_idand cannot download the generated file through the container-files API.Reproduction
code_interpretertoolFoundryToolboxandResponsesHostServer/mnt/data/result.txtand attach itObserved behavior
The hosted response exposes the tool result as a regular
function_call_output, with no file citation. However, a direct MCPtools/callto the same Toolbox returns the required metadata on the text content block:{ "type": "text", "text": "...", "_meta": { "container_id": "cntr_...", "container_file_citations": "[{\"file_id\":\"cfile_...\",\"filename\":\"result.txt\",\"container_id\":\"cntr_...\"}]" } }This indicates that Code Interpreter and the Toolbox service produce the artifact identifiers, but Agent Framework does not carry them through to the hosted Responses output. In the Python path, per-content MCP
_metaappears to be dropped during MCP result conversion. The hosting adapter also has no conversion from this metadata to a Responsescontainer_file_citationannotation.Expected behavior
Agent Framework should preserve the per-content metadata and emit an annotation equivalent to:
{ "type": "container_file_citation", "container_id": "cntr_...", "file_id": "cfile_...", "filename": "result.txt" }Code Sample
import asyncio import os from agent_framework import Agent from agent_framework.foundry import FoundryChatClient from agent_framework_foundry_hosting import FoundryToolbox, ResponsesHostServer from azure.identity import DefaultAzureCredential async def main(): credential = DefaultAzureCredential() agent = Agent( client=FoundryChatClient( project_endpoint=os.environ["FOUNDRY_PROJECT_ENDPOINT"], model=os.environ["AZURE_AI_MODEL_DEPLOYMENT_NAME"], credential=credential, ), instructions=( "Use Code Interpreter when asked to create a file. Write files to " "/mnt/data and attach them to the response." ), tools=FoundryToolbox(credential), default_options={"store": False}, ) await ResponsesHostServer(agent).run_async() if __name__ == "__main__": asyncio.run(main()) services: agent-tools: host: azure.ai.toolbox uses: - ai-project tools: - type: code_interpreter name: code_interpreter repro-agent: host: azure.ai.agent project: src/repro-agent uses: - ai-project - agent-tools protocols: - protocol: responses version: 2.0.0 environmentVariables: - name: AZURE_AI_MODEL_DEPLOYMENT_NAME value: ${AZURE_AI_MODEL_DEPLOYMENT_NAME} - name: TOOLBOX_NAME value: agent-toolsError Messages / Stack Traces
Package Versions
agent-framework-core==1.10.0 agent-framework-foundry==1.8.2 agent-framework-foundry-hosting==1.0.0a260630 mcp==1.28.0
Python Version
Python 3.14
Additional Context
No response