Python: Add timeout for wait-for-first-completion - #7908
Conversation
There was a problem hiding this comment.
Pull request overview
Adds a configurable bounded wait for Python background agents, preventing indefinite blocking.
Changes:
- Adds a five-minute default and configurable wait timeout.
- Returns normally on timeout without stopping background tasks.
- Adds validation and timeout-focused tests.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
_background_agents.py |
Implements timeout behavior and validation. |
_agent.py |
Exposes timeout through harness creation. |
_agent.pyi |
Updates the public typing signature. |
test_harness_background_agents.py |
Tests defaults, validation, and timeout behavior. |
test_harness_agent.py |
Tests harness timeout forwarding. |
_workflows/_agent.py |
Formatting-only change. |
_harness/_loop.py |
Formatting-only changes. |
💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.
Python Test Coverage Report •
Python Unit Test Overview
|
||||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
MAF Automated Review — Iteration 1
Result: Findings reported
Scope: full PR (1 commit(s)): 279186443070
Model: gpt-5.6-sol
Overview
The PR adds a provider-controlled, validated timeout and preserves timed-out tasks so their results can be observed later. The new tests cover validation, propagation, timeout return, and retained task state. However, returning control while timed-out tasks continue running creates an unbounded allocation loop with no automatic production cleanup, exposing shared process resources to persistent exhaustion.
Reviewed the supplied pull-request change set across correctness, security/reliability, architecture, and failure behavior.
1 verified finding remained after source verification (1 high) across 1 file. Details are attached to the affected lines below.
Affected areas: python/packages/core/agent_framework/_harness/_background_agents.py
Motivation & Context
Without a timeout, waiting for background agents can continue indefinitely.
Description & Review Guide
Allow developers to specify a timeout.
Related Issue
Fixes #7454
Contribution Checklist
breaking changelabel (or add "[BREAKING]" to the title prefix, before or after any language prefix) — a workflow keeps the label and title prefix in sync automatically.