Home Tip: Make Microsoft Foundry Agents Recoverable
Post
Cancel

Tip: Make Microsoft Foundry Agents Recoverable

Tip

Building an agent that runs in the background? In Microsoft Foundry, you can opt in to recovery for long-running background responses, so the framework can reinvoke work after interruptions such as a crash or redeployment.

For the Responses protocol, enable resilient background handling when you create the agent host:

1
2
3
4
5
6
7
8
from azure.ai.agentserver.responses import (
    ResponsesAgentServerHost,
    ResponsesServerOptions,
)

app = ResponsesAgentServerHost(
    options=ResponsesServerOptions(resilient_background=True),
)

This configuration snippet belongs in an existing hosted agent application; it is not a complete agent by itself.

The recovery option applies to responses stored and run in the background (store=true and background=true). When a run is recovered, your handler can detect that state and continue from a checkpoint instead of starting from the beginning.


Important: Recovery Is Opt-In

Crash recovery is off by default. Foreground responses aren’t recovered after a crash, and enabling recovery doesn’t automatically make every handler safe to rerun.

If your agent performs an action that can’t safely happen twice, such as sending an email or submitting an order, explicitly track progress and make the action idempotent where possible. Recovery alone does not guarantee exactly-once execution.

Long-running agent capabilities are in preview, and APIs or package versions may change. Check the current documentation before using them in production.


Bonus: Wait for Human Approval

Long-running agents also support workflows that pause for a human decision and resume later. In a multi-turn task chain, a turn can return an approval request and suspend; the next input on the same task_id resumes the handler.

That means an approval can arrive minutes, hours, or days later without holding a request open. The durable chain also survives container restarts.

This is a separate workflow pattern, not something the resilient_background setting adds automatically. Follow the human-in-the-loop guide below to implement the approval and resume steps.


References

This post is licensed under CC BY 4.0 by the author.

Tip of the day – Mark Trusted SharePoint Sites as Authoritative for Copilot Search

-