Skip to content

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

Open
brrusino wants to merge 2 commits intomicrosoft:mainfrom
brrusino:feature/agent-level-timeouts
Open

feat: add per-agent timeout_seconds for hard wall-clock timeouts (#82)#150
brrusino wants to merge 2 commits intomicrosoft:mainfrom
brrusino:feature/agent-level-timeouts

Conversation

@brrusino
Copy link
Copy Markdown
Contributor

@brrusino brrusino commented May 5, 2026

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 .

…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>
@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented May 5, 2026

Codecov Report

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

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #150   +/-   ##
=======================================
  Coverage        ?   86.20%           
=======================================
  Files           ?       57           
  Lines           ?     8331           
  Branches        ?        0           
=======================================
  Hits            ?     7182           
  Misses          ?     1149           
  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.

…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>
Sign up for free to 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

2 participants