Skip to content

Python: HandoffBuilder: Generated file cannot be retrieved #2718

Description

My scenario is that I receive a large response from an external tool that I want to transform into a file. Then, this file should be processed by other agents, who will create additional files from it. From my test this happens, as the 2 file agents pass this file id and generate new files. But at the end of the workflow I cannot download the file.

...
file_gen_agent = azure_ai_client.create_agent(
            name="FileGeneratorAgent",
            instructions=(
                "You are an excellent text file generator. "
                "Call the Code Interpreter tool to generate a txt file based on the user's request. "
            ),
            tools=HostedCodeInterpreterTool(),
            middleware=[
                override_middleware,
                comomon_session_data.inject_context_middleware,
            ],
            store=True,
        )
...
workflow_agent = (
            HandoffBuilder(
                name="SampleWorkflowAgent",
                participants=[coordinator_agent, file_gen_agent, pdf_file_gen_agent],
            )
            
            .set_coordinator(coordinator_agent)
            .add_handoff(coordinator_agent, file_gen_agent)
            .auto_register_handoff_tools(enabled=True)
            .add_handoff(file_gen_agent, pdf_file_gen_agent)
            .with_checkpointing(storage)
            .build()

events = workflow_agent.run_stream(prompt)
async for event in events:
....
testFile = await self.agents_client.files.get(file_id=file_id)

When running, I get this response

{
  "type": "agent_run_response",
  "messages": [
    {
      "type": "chat_message",
      "role": {
        "type": "role",
        "value": "assistant"
      },
      "contents": [
        {
          "type": "text",
          "text": "from fpdf import FPDF\n\n# Create instance of FPDF class\npdf = FPDF()\npdf.add_page()\npdf.set_font(\"Arial\", size=12)\n\n# Add sample content\nsample_content = \"\"\"\nSample PDF Document\n\nThis is a sample PDF file generated with Python.\nIt demonstrates how to create PDF files programmatically.\n\n- Item 1\n- Item 2\n- Item 3\n\nThank you for using this service!\n\"\"\"\n\nfor line in sample_content.split('\\n'):\n    pdf.cell(200, 10, txt=line, ln=True)\n\n# Save PDF file\npdf_file_path = \"/mnt/data/final.pdf\"\npdf.output(pdf_file_path)\n\npdf_file_path"
        },
        {
          "type": "text",
          "annotations": [
            {
              "type": "citation",
              "annotated_regions": [
                {
                  "type": "text_span",
                  "start_index": 97,
                  "end_index": 124
                }
              ],
              "url": "final.pdf",
              "file_id": "cfile_6937d9e89be8819090002bfae3a00fcf",
              "container_id": "cntr_6937d9df20508190a73b97efbacff0bc01c8c675e5b4f541"
            }
          ],
          "text": "Your PDF file named 'final.pdf' with sample content has been generated.\n\n[Download the PDF file](sandbox:/mnt/data/final.pdf)"
        }
      ],
      "author_name": "PDFFileGeneratorAgent",
      "additional_properties": {}
    }
  ],
  "response_id": "resp_00e0de3e0d80a057006937d9ddbe90819489c33df5e2180656",
  "created_at": "2025-12-09T10:12:13.000000Z",
  "usage_details": {
    "type": "usage_details",
    "input_token_count": 553,
    "output_token_count": 176,
    "total_token_count": 729
  },
  "additional_properties": {}
}

However if I search for the file id cfile_6937d9e89be8819090002bfae3a00fcf I don't get it, also if I list the files it isn't there and also if I check Azure Foundry (new) I don't see the file.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

orchestrationUsage: [Issues, PRs], Target: multi-agent orchestration (high-level patterns)pythonUsage: [Issues, PRs], Target: Python

Type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions