Skip to content

feat: add per-agent timeout_seconds for hard wall-clock timeouts (#82) - #150

Merged
Jason Robert (jrob5756) merged 3 commits into
microsoft:mainfrom
brrusino:feature/agent-level-timeouts
May 6, 2026
Merged

feat: add per-agent timeout_seconds for hard wall-clock timeouts (#82)#150
Jason Robert (jrob5756) merged 3 commits into
microsoft:mainfrom
brrusino:feature/agent-level-timeouts

Conversation

@brrusino

@brrusinoBrent Rusinow (brrusino) commented May 5, 2026

Copy link
Copy Markdown
Contributor

Add timeout_seconds field to AgentDef that wraps agent execution in asyncio.wait_for() at the engine level. This provides hard cancellation for slow agents without blocking entire workflows.

Key behaviors:

  • Effective timeout = min(agent.timeout_seconds, remaining_workflow_timeout)
  • When workflow timeout is stricter, it owns the error (no mislabeling)
  • Emits agent_timeout event with agent name, elapsed time, and limit
  • Raises AgentTimeoutError (subclass of TimeoutError) for existing error handling semantics (fail_fast, continue_on_error)
  • Scoped to provider-backed agents only (script uses 'timeout', human_gate/workflow types rejected)
  • Applied at all execution sites: main loop, parallel groups, for-each groups

Schema:

  • New field: timeout_seconds: float | None (ge=1.0)
  • Rejected for script, human_gate, and workflow agent types

Exception:

  • New AgentTimeoutError class with agent_name attribute

Console:

  • New verbose_log_agent_timeout handler for agent_timeout events

Closes#82 .

@codecov-commenter

Codecov Comments Bot (codecov-commenter) commented May 5, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (main@179c8e6). Learn more about missing BASE report.

Additional details and impacted files
@@ Coverage Diff @@## main #150 +/- ##
=======================================
Coverage ? 86.21% =======================================
Files ? 60 Lines ? 8870 Branches ? 0 =======================================
Hits ? 7647 Misses ? 1223 Partials ? 0 

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@jrob5756Jason Robert (jrob5756) left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, focused PR. CI is green and the helper-based design is clean. A few suggestions inline. Most are minor; the missing for-each integration test and the brittle output-type assertion are the two I'd address before merging. Also looks like there is a merge conflict :)

Comment threadsrc/conductor/engine/workflow.py
Comment threadsrc/conductor/config/schema.py
Comment threadsrc/conductor/exceptions.py
Comment threadtests/test_engine/test_agent_timeout.py Outdated
Comment threadtests/test_engine/test_agent_timeout.py
…rosoft#82)
Add timeout_seconds field to AgentDef that wraps agent execution in
asyncio.wait_for() at the engine level. This provides hard cancellation
for slow agents without blocking entire workflows.
Key behaviors:
- Effective timeout = min(agent.timeout_seconds, remaining_workflow_timeout)
- When workflow timeout is stricter, it owns the error (no mislabeling)
- Emits agent_timeout event with agent name, elapsed time, and limit
- Raises AgentTimeoutError (subclass of TimeoutError) for existing error
handling semantics (fail_fast, continue_on_error)
- Scoped to provider-backed agents only (script uses 'timeout',
human_gate/workflow types rejected)
- Applied at all execution sites: main loop, parallel groups, for-each groups
Schema:
- New field: timeout_seconds: float | None (ge=1.0)
- Rejected for script, human_gate, and workflow agent types
Exception:
- New AgentTimeoutError class with agent_name attribute
Console:
- New verbose_log_agent_timeout handler for agent_timeout events
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…criber
Add tests for the agent_timeout console logging path to address
CodeCov coverage gaps:
- verbose_log_agent_timeout with verbose mode enabled
- verbose_log_agent_timeout with verbose mode disabled (no-op path)
- verbose_log_agent_timeout file logging dual-write
- ConsoleEventSubscriber.on_event agent_timeout dispatch
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Use 'from e' instead of 'from None' to preserve asyncio.TimeoutError
chain for debugging (workflow.py)
- Document hard cancellation implications in timeout_seconds docstring:
in-flight sessions, MCP tools, HTTP connections may be left
inconsistent (schema.py)
- Document why both agent_name and current_agent exist on
AgentTimeoutError for downstream consumer clarity (exceptions.py)
- Pin brittle 'or' assertion to deterministic value (test)
- Add TestAgentTimeoutForEach class with fail_fast and
continue_on_error integration tests (test)
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@brrusino
Brent Rusinow (brrusino)force-pushed the feature/agent-level-timeouts branch from d867696 to 30058b9CompareMay 6, 2026 17:10
@jrob5756
Jason Robert (jrob5756) merged commit 3c3b17e into microsoft:mainMay 6, 2026
7 checks passed
Jason Robert (jrob5756) added a commit that referenced this pull request May 13, 2026
Release notes for 0.1.15 added to CHANGELOG.md.
Added:
- Per-agent timeout_seconds for hard wall-clock timeouts (#150)
- Auto-discovery of .github/instructions/**/*.instructions.md with applyTo
filtering, plus polymorphic conventions refactor (#169)
Fixed:
- system_prompt is now rendered and forwarded to providers (#179)
- conductor update on Windows: install scripts become the single upgrade
path; install.sh reaches parity (#171)
- install.ps1 UTF-8 BOM breaking the irm | iex one-liner (#178)
- conductor stop crash on Windows from os.kill(pid, 0) liveness probe (#176)
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature: Agent-Level Timeouts

3 participants

@brrusino@codecov-commenter@jrob5756