Skip to content

Commit 29c7394

Browse files
perf(durable-demo): skip artificial delay on first stage for responsiveness
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent eb6b6a0 commit 29c7394

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

  • sdk/agentserver/azure-ai-agentserver-invocations/samples/durable-agent-demo/src/durable-research-agent

sdk/agentserver/azure-ai-agentserver-invocations/samples/durable-agent-demo/src/durable-research-agent/agent.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ async def deep_research(ctx: TaskContext[dict]) -> dict[str, Any]:
156156
}))
157157

158158
# Do the work — streaming LLM tokens
159-
result = await _run_stage_streaming(ctx, topic, stage, prior_results=results[-3:])
159+
result = await _run_stage_streaming(ctx, topic, stage, prior_results=results[-3:], stage_idx=stage_idx)
160160
results.append({"stage": stage, "result": result})
161161

162162
# ── CHECKPOINT ── crash-recovery boundary ─────
@@ -184,10 +184,12 @@ async def deep_research(ctx: TaskContext[dict]) -> dict[str, Any]:
184184
# ── LLM helpers ───────────────────────────────────────────────────────────────
185185

186186
async def _run_stage_streaming(
187-
ctx: TaskContext, topic: str, stage: str, *, prior_results: list
187+
ctx: TaskContext, topic: str, stage: str, *, prior_results: list, stage_idx: int = 0
188188
) -> str:
189189
"""Call the LLM for one research stage, streaming tokens to the consumer."""
190-
await asyncio.sleep(STAGE_DURATION)
190+
# Skip artificial delay for first stage so demo feels responsive
191+
if stage_idx > 0:
192+
await asyncio.sleep(STAGE_DURATION)
191193

192194
if prior_results:
193195
findings = "\n".join(f"- {r['stage']}: {r['result'][:80]}" for r in prior_results[-3:])

0 commit comments

Comments
 (0)