Browse the docs

Troubleshoot a Foundry hybrid agent

Symptoms you are likely to hit, what causes each, the fix, and where to find the container logs.

Before you startA deployed agent and read access to the project's Application Insights workspace.View as Markdown

Symptoms and fixes

SymptomCauseFix
Runs die at about 15 minutes: stream cut, background stuck in_progress, no envelopeNo session idle timeout on the version (default 900 s)Set SESSION_IDLE_TIMEOUT_SECONDS=3600 and redeploy
internal server error on every request; container looks healthyProtocol declared as responses 1.0.0Declare 2.0.0
Version rejected: reserved for platform useAn AGENT_* or FOUNDRY_* name in environment_variablesMove it to the Dockerfile ENV
image_pull_failed, UnauthorizedAcrPull, InvalidAcrPullCredentialsAccount and project managed identities lack classic AcrPullGrant AcrPull on the registry to both
401 Principal does not have access to API/OperationThe model grant went to the blueprint, or to the projectGrant Foundry User to the instance identity at account scope
Long run dies with EACCES then Prompt is too longThe CLI's config dir is under the unwritable /home/sessionKeep HOME and CLAUDE_CONFIG_DIR under /work in build_options
JSON message exceeded maximum buffer sizeSDK default 1 MiB bufferKeep the template's 64 MiB max_buffer_size
Every request refused: MAX_TURNS and MAX_USD_PER_RUN must be setCeilings missing from the versionSet both and redeploy
Every request refused: request field collides with Starting step fieldsA request field named title, delivered, model or agent_versionRename it and rebuild
Run fails mid-way on a model that "doesn't exist"An unpinned tier fell back to a missing deploymentPin all three ANTHROPIC_DEFAULT_*_MODEL
ZoneInfoNotFoundError in the containerNo tzdata in the imageInstall tzdata in the Dockerfile
Failed publish but AMC shows a green runTurn ended normally, so the stream ended response.completedRaise RunFailed after the markers in _run_stream
Run costs several times normal, over a hundred Bash calls, skills_bypassed setThe prompt led with a command and the skill never loadedRestore the "FIRST, invoke the skill" opening
Run dies with no envelope after fanning outTask enabled for a skill that doesn't delegatePut Task back in disallowed_tools
MCP calls start failing 401 near the end of a long runThe per-turn token expired (about 60 to 90 minutes)Lower RUN_TIMEOUT_SECONDS or put a refresh proxy in front of the server
HITL agent ends green having asked nobodyThe brain didn't write hitl_request.jsonEnforce a mandatory pause in _postprocess
Steps fragment into many (2), (3) repeatsPhase idle close changedKeep PHASE_IDLE_MESSAGES = 2
Cost in AMC far too lowinput_tokens reported without cached tokensReport cache-inclusive input_tokens with cached_input_tokens as the subset
Cost in AMC doubledRun totals or cost_usd on the trailing markers while steps carry tokensTrailing markers carry the residual only
A probe fails with a bare socket error at startCold container still startingConnect with a generous timeout (the probe uses 180 s)

Where the logs are

Container stdout lands in the Log Analytics workspace behind the project's Application Insights.

  • `AppTraces`, filtered on AppRoleName == '<agent-name>', one AppRoleInstance per container. Every step is also logged as step: <title>.
  • `AppExceptions`: Details holds the stack, Properties the response id, agent version and caller.
  • Lines logged at startup, before the hosting server configures the exporter, reach stdout only. That's why a readiness refusal is logged again per request.
  • A ConnectionError to 169.254.169.254 /metadata/instance is the App Insights resource detector probing a sandbox that has no metadata service. It's noise.
bash
az monitor log-analytics query -w <workspace-customer-id> \
  --analytics-query "AppTraces | where AppRoleName == 'invoice-summarizer-agent' | order by TimeGenerated desc | take 200"

Query the workspace rather than the App Insights traces blade, which has gone empty mid-investigation. KQL reserves first and latest as column names.

Process-loss recovery

A hosted run dies with the process serving it (a deploy, a replica recycle) and sticks at in_progress. Foundry's resilient_background fix is workflow-only and a hybrid agent is a single agent, so it doesn't apply. If you genuinely need process-loss recovery, model the unit as a one-node workflow; see Microsoft Agent Framework (Python).

Last updated 2026-10-21