Skip to content

Simplify AgentEngine cancellation around caller contexts#290

Merged
spboyer merged 6 commits into
mainfrom
copilot/spboyer-reconsider-agentengine-cancellation-api
May 25, 2026
Merged

Simplify AgentEngine cancellation around caller contexts#290
spboyer merged 6 commits into
mainfrom
copilot/spboyer-reconsider-agentengine-cancellation-api

Conversation

Copilot AI commented May 23, 2026

Copy link
Copy Markdown
Contributor

AgentEngine.Execute(ctx, req) exposed two cancellation inputs: the caller context and ExecutionRequest.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

    • Removed ExecutionRequest.Timeout.
    • Documented Execute as context-controlled for cancellation and deadlines.
    • Stopped CopilotEngine from creating implicit request timeouts.
  • Timeout conversion

    • Eval/task timeout_seconds now becomes an Execute context deadline in orchestration.
    • Trigger, suggest, quality judge, prompt grader, and related CLI call sites now wrap contexts before invoking Execute.
execCtx, cancel := context.WithTimeout(ctx, r.executionTimeout(tc))
resp, err := r.engine.Execute(execCtx, req)
cancel()
  • Cancellation behavior
    • CopilotEngine returns immediately for already-expired contexts.
    • MockEngine now honors pre-canceled contexts.
    • Added focused coverage for caller deadlines, expired contexts, no implicit engine timeout, and eval timeout propagation.

Copilot AI requested review from Copilot and removed request for Copilot May 23, 2026 15:18
Copilot AI linked an issue May 23, 2026 that may be closed by this pull request
Copilot AI requested review from Copilot and removed request for Copilot May 23, 2026 15:27
Copilot AI changed the title [WIP] Refactor AgentEngine to use Context for cancellation Simplify AgentEngine cancellation around caller contexts May 23, 2026
Copilot AI requested a review from spboyer May 23, 2026 15:30
@spboyer spboyer marked this pull request as ready for review May 23, 2026 19:42
Copilot AI review requested due to automatic review settings May 23, 2026 19:42

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.Timeout and updated AgentEngine.Execute docs to clarify that callers control cancellation/deadlines via ctx.
  • Converted eval/task timeout_seconds into context.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

Comment thread internal/trigger/runner_test.go
Comment thread internal/orchestration/runner_test.go
Comment thread internal/orchestration/runner.go Outdated
Copilot AI added 3 commits May 25, 2026 10:32
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings May 25, 2026 14:37

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot's findings

  • Files reviewed: 18/18 changed files
  • Comments generated: 2

Comment thread internal/models/testcase.go Outdated
Comment thread internal/execution/mock.go
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@spboyer spboyer merged commit 84a5736 into main May 25, 2026
7 checks passed
@spboyer spboyer deleted the copilot/spboyer-reconsider-agentengine-cancellation-api branch May 25, 2026 14:58
Copilot AI mentioned this pull request Jun 6, 2026
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>
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.

Reconsider AgentEngine cancellation API

4 participants