Share via

AI Foundry agent produces unexpected responses

Chris 0 Reputation points
2025-10-28T17:20:44.5966667+00:00

I’m running an Azure Web App that uses an AI agent via the Python SDK. However, the agent is currently hardcoded so that its responses should trigger either a blob append or a blob search. Sometimes, nothing happens not even an error.

What is the best way to capture and persist all incoming and outgoing JSON bodies or event traces possibly using Blob Storage or Application Insights for later inspection of message flow anomalies?

Foundry Tools
Foundry Tools

Formerly known as Azure AI Services or Azure Cognitive Services is a unified collection of prebuilt AI capabilities within the Microsoft Foundry platform


1 answer

Sort by: Most helpful
  1. Anshika Varshney 12,110 Reputation points Microsoft External Staff Moderator
    2025-10-30T15:06:04.3966667+00:00

    Hello Chris,
    You’re right the standard Azure AI Foundry Agent Playground interface doesn't provide a built-in button to directly download the full incoming & outgoing JSON bodies of each run. But yes, there are workarounds and ways to capture them. Here’s how you can do it:

    Workaround A: Use Tracing / Observability

    You can hook into the agent's tracing/monitoring features so you can see the JSON request/response details (or at least a rich enough log) and then export them manually:

    1.In the Azure Portal, go to your Foundry project → Observability or Tracing settings.

    2.Connect an Application Insights resource (or Log Analytics workspace) to your agent so that your agent logs are sent to it.

    3.Use the SDK or your code to ensure content-recording is enabled for the agent. For example, in Python you may set environment variables or use the SDK to enable recording of messages.

    4.In Application Insights / Log Analytics, you can query for request/response spans that include the JSON payloads, then export the logs (CSV/JSON) for offline review.

    While this gives you access, it’s not a “one-click download of request/response JSON” from the UI.

    Workaround B: Use the SDK/CLI for direct calls

    If you call the agent via SDK or REST (instead of only using the Playground), you can capture both the outgoing request (what you send) and the incoming response (what the agent returns) locally. For example:

    import json
    # build message payload
    payload = { "messages": [ {"role":"user","content":"…"} ], /* other params */ }
    with open("request.json", "w") as f: f.write(json.dumps(payload, indent=2))
    
    response = client.agents.runs.create_and_process(thread_id=…, agent_id=…)
    with open("response.json","w") as f: f.write(json.dumps(response, indent=2))
    
    

    This way you get both JSON files and can store/analyze them.

    Things to note:

    The Playground hides many internals for simplicity, so full raw JSON bodies may not always be exposed in UI form.

    Logging message content may have privacy/security implications — be careful if your payloads contain sensitive data.

    If you only have the UI (no code access) then option A is the only realistic path.

    There may be slight delays or sampling in logs, depending on how busy the system is.

    So in short: No, there’s no native “Download full JSON” button in the agent Playground. But yes, you can get access to the JSON bodies by:

    • Enabling tracing/observability and exporting from Application Insights or Log Analytics
    • Or by using the SDK/REST yourself so you control request & response and write them to files.

    I hope this has been helpful! Please let me know if you have another query.

    Was this answer helpful?


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.