Simplify AgentEngine cancellation around caller contexts#290
Merged
spboyer merged 6 commits intoMay 25, 2026
Conversation
Copilot
AI
changed the title
[WIP] Refactor AgentEngine to use Context for cancellation
Simplify AgentEngine cancellation around caller contexts
May 23, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
This PR refactors AgentEngine.Execute(ctx, req) cancellation semantics so that context deadlines/cancellation are the single source of truth, removing the separate ExecutionRequest.Timeout knob and updating orchestration + CLI call sites to wrap contexts before invoking Execute.
Changes:
- Removed
ExecutionRequest.Timeoutand updatedAgentEngine.Executedocs to clarify that callers control cancellation/deadlines viactx. - Converted eval/task
timeout_secondsintocontext.WithTimeout(...)wrappers at orchestration/CLI/trigger/judge/suggest/prompt-grader call sites. - Updated engines/tests to honor pre-canceled/expired contexts and to verify deadline propagation and “no implicit engine timeout” behavior.
Show a summary per file
| File | Description |
|---|---|
| internal/trigger/runner.go | Wraps trigger executions in a timeout context instead of using request timeout. |
| internal/trigger/runner_test.go | Updates trigger runner test to assert timeout via context deadline. |
| internal/suggest/suggest.go | Applies per-pass WithTimeout contexts for selection/implementation calls. |
| internal/quality/judge.go | Wraps judge execution in a timeout context derived from TimeoutSec. |
| internal/orchestration/runner.go | Applies eval/task timeouts as context deadlines and centralizes timeout derivation. |
| internal/orchestration/runner_test.go | Updates tests to validate context deadlines rather than request timeouts. |
| internal/graders/prompt_grader.go | Enforces prompt grader timeout via context deadline (not request field). |
| internal/execution/mock.go | Makes mock engine return immediately on already-canceled contexts. |
| internal/execution/engine.go | Removes ExecutionRequest.Timeout field and clarifies Execute context semantics. |
| internal/execution/copilot.go | Removes implicit timeout creation/validation and returns immediately on expired contexts. |
| internal/execution/copilot_test.go | Removes uses/tests of request timeout and updates call sites accordingly. |
| internal/execution/copilot_engine_test.go | Adds/updates tests for caller-deadline propagation and no default timeout. |
| cmd/waza/tokens/suggest.go | Wraps Copilot suggestion execution in a 60s timeout context. |
| cmd/waza/dev/copilot.go | Wraps dev Copilot suggestions execution in a 120s timeout context. |
| cmd/waza/cmd_run_suggest.go | Wraps eval-analysis suggestion generation in a 120s timeout context. |
| cmd/waza/cmd_new_task.go | Wraps “execute prompt” step in the CLI-provided timeout context. |
Copilot's findings
- Files reviewed: 16/16 changed files
- Comments generated: 3
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…sider-agentengine-cancellation-api
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Merged
spboyer
pushed a commit
that referenced
this pull request
Jun 6, 2026
- Clarify BYOK + --model fix description (validates against Copilot catalog before BYOK config applies) - Add #290 PR reference to AgentEngine cancellation entry Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
github-actions Bot
pushed a commit
that referenced
this pull request
Jun 6, 2026
* chore: Prepare release v0.35.0 - Bump version.txt and extension.yaml to 0.35.0 - Add [0.35.0] entry to CHANGELOG.md - Update site releases page with new download links and changelog Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * docs: Address review feedback on v0.35.0 release notes - Clarify BYOK + --model fix description (validates against Copilot catalog before BYOK config applies) - Add #290 PR reference to AgentEngine cancellation entry Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
AgentEngine.Execute(ctx, req)exposed two cancellation inputs: the caller context andExecutionRequest.Timeout. This refactors execution cancellation so context is the single source of truth, while eval timeout settings are converted before calling the engine.Execution API
ExecutionRequest.Timeout.Executeas context-controlled for cancellation and deadlines.CopilotEnginefrom creating implicit request timeouts.Timeout conversion
timeout_secondsnow becomes anExecutecontext deadline in orchestration.Execute.CopilotEnginereturns immediately for already-expired contexts.MockEnginenow honors pre-canceled contexts.