Skip to content

Commit 52016f4

Browse files
fix(responses-demo): make crash route recovery-aware (crash once, then recover)
The demo crash trigger (input='crash' -> os._exit(137)) did not check context.is_recovery, so after a crash the durably re-delivered 'crash' input re-fired the exit on every recovered lifetime — an infinite crash-loop for a demo whose whole point is to crash ONCE and recover. Guard with 'not context.is_recovery' so the recovered run skips the crash and resumes to completion. Also refreshes the azd env agent version pointer. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 2c8d3d8 commit 52016f4

2 files changed

Lines changed: 8 additions & 4 deletions

File tree

  • sdk/agentserver/azure-ai-agentserver-responses/samples/durable-responses-agent-demo
    • .azure/durable-responses-agent-demo
    • src/durable-responses-agent-demo

sdk/agentserver/azure-ai-agentserver-responses/samples/durable-responses-agent-demo/.azure/durable-responses-agent-demo/.env

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
AGENT_DURABLE_RESPONSES_AGENT_DEMO_ENDPOINT="https://rapida-0687-resource.services.ai.azure.com/api/projects/rapida-0687/agents/durable-responses-agent-demo/versions/30"
1+
AGENT_DURABLE_RESPONSES_AGENT_DEMO_ENDPOINT="https://rapida-0687-resource.services.ai.azure.com/api/projects/rapida-0687/agents/durable-responses-agent-demo/versions/31"
22
AGENT_DURABLE_RESPONSES_AGENT_DEMO_NAME="durable-responses-agent-demo"
33
AGENT_DURABLE_RESPONSES_AGENT_DEMO_RESPONSES_ENDPOINT="https://rapida-0687-resource.services.ai.azure.com/api/projects/rapida-0687/agents/durable-responses-agent-demo/endpoint/protocols/openai/responses?api-version=2025-11-15-preview"
4-
AGENT_DURABLE_RESPONSES_AGENT_DEMO_VERSION=30
4+
AGENT_DURABLE_RESPONSES_AGENT_DEMO_VERSION=31
55
AI_PROJECT_DEPLOYMENTS="[{\\\"name\\\":\\\"gpt-4o\\\",\\\"model\\\":{\\\"name\\\":\\\"gpt-4o\\\",\\\"format\\\":\\\"OpenAI\\\",\\\"version\\\":\\\"2024-11-20\\\"},\\\"sku\\\":{\\\"name\\\":\\\"GlobalStandard\\\",\\\"capacity\\\":50}}]"
66
AZURE_AI_ACCOUNT_ID="/subscriptions/47f1c914-e299-4953-a99d-3e34644cfe1c/resourceGroups/agents-westus2/providers/Microsoft.CognitiveServices/accounts/rapida-0687-resource"
77
AZURE_AI_ACCOUNT_NAME="rapida-0687-resource"

sdk/agentserver/azure-ai-agentserver-responses/samples/durable-responses-agent-demo/src/durable-responses-agent-demo/main.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -231,8 +231,12 @@ async def handler(
231231
"""
232232
topic = (await context.get_input_text()) or ""
233233

234-
# Demo-only crash trigger.
235-
if DEMO_MODE and topic.strip().lower() in ("crash", "kill", "💥"):
234+
# Demo-only crash trigger. Guarded by ``not context.is_recovery`` so the
235+
# crash fires exactly once: on the recovered re-invocation the same
236+
# (durably re-delivered) "crash" input is ignored and the handler resumes
237+
# to completion — i.e. a crash-recovery demo that crashes once and then
238+
# recovers, instead of crash-looping forever.
239+
if DEMO_MODE and not context.is_recovery and topic.strip().lower() in ("crash", "kill", "💥"):
236240
logger.critical("CRASH triggered via input=%r — exiting in 300ms", topic)
237241

238242
async def _crash() -> None:

0 commit comments

Comments
 (0)