Skip to content

Add max-continuations field to agentic engine configuration#18368

Merged
pelikhan merged 7 commits intomainfrom
copilot/add-max-continues-field
Feb 25, 2026
Merged

Add max-continuations field to agentic engine configuration#18368
pelikhan merged 7 commits intomainfrom
copilot/add-max-continues-field

Conversation

Copy link
Contributor

Copilot AI commented Feb 25, 2026

Adds a max-continuations field to the agentic engine configuration, enabling autopilot mode with a configurable continuation limit for supported engines (currently Copilot only).

Changes Made

  • engine.go: Added MaxContinuations int field to EngineConfig struct with parsing for the max-continuations frontmatter field
  • agentic_engine.go: Added SupportsMaxContinuations() bool to the CapabilityProvider interface and BaseEngine
  • copilot_engine.go: Enabled supportsMaxContinuations: true
  • copilot_engine_execution.go: Applies --autopilot --max-autopilot-continues <n> flags when MaxContinuations > 1; flags are skipped for detection jobs (SafeOutputs == nil) since autopilot mode is only meaningful for the agent execution
  • agent_validation.go: Added validateMaxContinuationsSupport validation that errors if the engine doesn't support max-continuations
  • compiler_orchestrator_tools.go: Calls the new validation
  • main_workflow_schema.json: Added max-continuations field to the engine_config schema
  • smoke-copilot.md: Set max-continuations: 2 as a real-world usage example

💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.


Add max-continuations field to agentic engine configuration

Adds a max-continuations field to the agentic engine configuration, enabling autopilot mode with a configurable continuation limit for supported engines (currently Copilot only).

Changes Made

  • engine.go: Added MaxContinuations int field to EngineConfig struct with parsing for the max-continuations frontmatter field
  • agentic_engine.go: Added SupportsMaxContinuations() bool to the CapabilityProvider interface and BaseEngine
  • copilot_engine.go: Enabled supportsMaxContinuations: true
  • copilot_engine_execution.go: Applies --autopilot --max-autopilot-continues (n) flags when MaxContinuations > 1; flags are skipped for detection jobs (SafeOutputs == nil) since autopilot mode is only meaningful for the agent execution
  • agent_validation.go: Added validateMaxContinuationsSupport validation that errors if the engine doesn't support max-continuations
  • compiler_orchestrator_tools.go: Calls the new validation
  • main_workflow_schema.json: Added max-continuations field to the engine_config schema
  • smoke-copilot.md: Set max-continuations: 2 as a real-world usage example

💬 We'd love your input! Share your thoughts on Copilot coding agent in our [2 minute survey]((gh.io/redacted)

Changeset

  • Type: patch
  • Description: Allow workflows to configure a max-continuations limit when using Copilot so autopilot stops after a predictable number of iterations.

Generated by Changeset Generator for issue #18368

Warning

⚠️ Firewall blocked 1 domain

The following domain was blocked by the firewall during workflow execution:

  • github.com


✨ PR Review Safe Output Test - Run 22406871179

💥 [THE END] — Illustrated by Smoke Claude

@pelikhan
Copy link
Contributor

@copilot this flag does not apply to the detection copilot execution. The detection agentic execution should never use max-continues.

… support

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Feb 25, 2026

@copilot this flag does not apply to the detection copilot execution. The detection agentic execution should never use max-continues.

Fixed in 407ca26. The --autopilot --max-autopilot-continues flags are now skipped when isDetectionJob is true (i.e. SafeOutputs == nil). I also hoisted the isDetectionJob variable earlier in the function to remove the redundant inner-scope re-declarations.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • https://api.github.com/repos/actions/checkout/git/ref/tags/v4
    • Triggering command: /usr/bin/gh gh api /repos/actions/checkout/git/ref/tags/v4 --jq .object.sha u/13/liblto_plug-errorsas _64-linux-gnu/13-ifaceassert KiZkQl.res (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/checkout/git/ref/tags/v4 --jq .object.sha (http block)
  • https://api.github.com/repos/actions/github-script/git/ref/tags/v8
    • Triggering command: /usr/bin/gh gh api /repos/actions/github-script/git/ref/tags/v8 --jq .object.sha continues-field^{commit} (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/github-script/git/ref/tags/v8 --jq .object.sha (http block)
  • https://api.github.com/repos/actions/setup-go/git/ref/tags/v4
    • Triggering command: /usr/bin/gh gh api /repos/actions/setup-go/git/ref/tags/v4 --jq .object.sha g_.a (http block)
  • https://api.github.com/repos/actions/setup-node/git/ref/tags/v4
    • Triggering command: /usr/bin/gh gh api /repos/actions/setup-node/git/ref/tags/v4 --jq .object.sha continues-field^{commit} (http block)

If you need me to access, download, or install something from one of these locations, you can either:

Copy link
Contributor

@pelikhan pelikhan left a comment

Choose a reason for hiding this comment

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

@copilot set Max-continues to 2 on smoke-copilot

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Feb 25, 2026

@copilot set Max-continues to 2 on smoke-copilot

Done in 856778c. Changed smoke-copilot to use an engine config block with max-continuations: 2. The compiled lock file confirms --autopilot --max-autopilot-continues 2 is applied only to the agent execution step.

Copilot AI changed the title [WIP] Add max-continuations field to agentic engine configuration Add max-continuations field to agentic engine configuration Feb 25, 2026
@pelikhan pelikhan added the smoke label Feb 25, 2026
@github-actions
Copy link
Contributor

github-actions bot commented Feb 25, 2026

✨ The prophecy is fulfilled... Smoke Codex has completed its mystical journey. The stars align. 🌟

@github-actions
Copy link
Contributor

github-actions bot commented Feb 25, 2026

🎬 THE ENDSmoke Claude MISSION: ACCOMPLISHED! The hero saves the day! ✨

@github-actions
Copy link
Contributor

📰 BREAKING: Smoke Copilot is now investigating this pull request. Sources say the story is developing...

@github-actions
Copy link
Contributor

Agent Container Tool Check

Tool Status Version
bash 5.2.21
sh available
git 2.52.0
jq 1.7
yq 4.52.2
curl 8.5.0
gh 2.86.0
node 20.20.0
python3 3.12.3
go 1.24.12
java 10.0.102
dotnet 10.0.102

Result: 12/12 tools available ✅

Overall Status: PASS

🔧 Tool validation by Agent Container Smoke Test

@github-actions
Copy link
Contributor

Commit pushed: f11654b

Generated by Changeset Generator

@github-actions
Copy link
Contributor

🤖 Smoke test §22406871214 results for @Copilot:

Test
GitHub MCP
Safe Inputs GH CLI
Serena MCP ❌ (unavailable)
Playwright
Web Fetch
File Writing + Bash
Discussion Interaction
Build gh-aw
Discussion Creation
Workflow Dispatch
PR Review

Overall: PASS (11/12)

📰 BREAKING: Report filed by Smoke Copilot

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

This PR cleanly adds max-continuations support for the Copilot engine's autopilot mode. The implementation follows existing patterns (validateMaxTurnsSupport), schema changes are well-documented, and the smoke test usage provides live validation. LGTM!

📰 BREAKING: Report filed by Smoke Copilot


// validateWebSearchSupport validates that web-search tool is only used with engines that support this feature
func (c *Compiler) validateWebSearchSupport(tools map[string]any, engine CodingAgentEngine) {
// Check if web-search tool is requested
Copy link
Contributor

Choose a reason for hiding this comment

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

The validation pattern here mirrors validateMaxTurnsSupport nicely — good consistency. Worth noting the guard engineConfig.MaxContinuations == 0 correctly treats 0 as "not set" since minimum valid value is 1 per schema.

@github-actions
Copy link
Contributor

📰 VERDICT: Smoke Copilot has concluded. All systems operational. This is a developing story. 🎤

@github-actions
Copy link
Contributor

Smoke test results:

  • PR titles: Improve test coverage and structure for pkg/parser/import_cache_test.go; fix(scout): normalize report headers to h3 and bold summary tags
  • GitHub MCP: ✅
  • Serena MCP (activate + find_symbol >=3): ✅
  • Playwright title contains GitHub: ✅
  • Web fetch contains GitHub: ✅
  • File write + bash cat: ✅
  • Build (make build): ✅
    Overall: PASS

🔮 The oracle has spoken through Smoke Codex

@github-actions
Copy link
Contributor

Commit pushed: dc3868f

💥 [THE END] — Illustrated by Smoke Claude

@github-actions
Copy link
Contributor

Smoke Test Results - Run 22406871179

Core Tests PR Review Tests
#1 GitHub MCP ✅ #11 Update PR ✅
#2 safeinputs-gh ✅ #12 Review comments ✅
#3 Serena MCP ✅ #13 Submit review ✅
#4 Make build ✅ #14 Resolve thread ✅
#5 Playwright ✅ #15 Add reviewer ✅
#6 Tavily search ✅ #16 Push to branch ✅
#7 File creation ✅ #17 Close PR ⚠️ skipped
#8 Bash verify ✅
#9 Discussion query ✅
#10 Agentic Workflows ✅

Overall Status: PARTIAL (all non-skipped tests passed, #17 skipped by design)

💥 [THE END] — Illustrated by Smoke Claude

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

💥 Automated smoke test review - all systems nominal!

💥 [THE END] — Illustrated by Smoke Claude

@github-actions
Copy link
Contributor

Hey @Copilot 👋 — great work adding the max-continuations capability to the Copilot engine! The feature design is clean — adding the field to EngineConfig, wiring it through the CapabilityProvider interface, validating it in agent_validation.go, and updating the schema all follow the established patterns nicely. A few things to tighten up before this is ready for review:


⚠️ Missing Tests

The PR introduces new logic but no test coverage. The codebase has a strong testing convention for exactly these cases:

  • pkg/workflow/engine_config_test.go — needs a case for max-continuations: 2 parsing into EngineConfig.MaxContinuations
  • pkg/workflow/agentic_engine_interfaces_test.goSupportsMaxContinuations() should be called and verified for each engine (Copilot → true, Claude/Codex/Gemini → false), matching the existing SupportsMaxTurns() pattern
  • pkg/workflow/max_continuations_validation_test.go (new file, integration build tag) — mirrors max_turns_validation_test.go: test that using max-continuations with a non-supporting engine (e.g., claude) returns the right error, and that using it with copilot succeeds
  • pkg/workflow/copilot_engine_execution.go — the autopilot flag injection logic (--autopilot --max-autopilot-continues N) has no unit test verifying the flags appear in the generated execution steps

🧹 Unrelated Changes to Clean Up

Two files in the diff are unrelated to the feature:

  1. smoke-test-22406871179.txt — This looks like an accidentally committed smoke-test artifact. It should be removed from the branch.
  2. .devcontainer/devcontainer.json — Only reorders github-cli and git-lfs entries with no functional change. Consider reverting this to keep the diff focused.

If you'd like a hand addressing these, assign this prompt to your coding agent:

In the PR branch `copilot/add-max-continues-field` in the `github/gh-aw` repo, address the following:

1. **Remove the accidental smoke-test artifact**:
   - Delete `smoke-test-22406871179.txt` from the repository root.

2. **Revert the unrelated devcontainer change**:
   - In `.devcontainer/devcontainer.json`, restore the original order of `github-cli:1` and `git-lfs:1` entries (swap them back so `github-cli:1` comes before `git-lfs:1`).

3. **Add `engine_config_test.go` coverage** in `pkg/workflow/engine_config_test.go`:
   - Add a test case for `engine: { id: copilot, max-continuations: 2 }` that verifies `EngineConfig.MaxContinuations == 2`.

4. **Update `agentic_engine_interfaces_test.go`** in `pkg/workflow/agentic_engine_interfaces_test.go`:
   - Add `_ = engine.SupportsMaxContinuations()` to the capability methods loop.
   - Add assertions: `assert.True(t, copilot.SupportsMaxContinuations())` and `assert.False(t, claude.SupportsMaxContinuations())` and `assert.False(t, codex.SupportsMaxContinuations())`, mirroring the existing `SupportsMaxTurns()` assertions.

5. **Create `pkg/workflow/max_continuations_validation_test.go`** (integration build tag `//go:build integration`):
   - Model it on `max_turns_validation_test.go`.
   - Test case 1: `engine: { id: claude, max-continuations: 2 }` → expect error "max-continuations not supported: engine 'claude' does not support the max-continuations feature".
   - Test case 2: `engine: { id: copilot, max-continuations: 2 }` → expect no error.
   - Test case 3: `engine: copilot` (no max-continuations) → expect no error.

Run `make agent-finish` after making changes to validate everything passes.

Generated by Contribution Check

@pelikhan pelikhan marked this pull request as ready for review February 25, 2026 18:32
Copilot AI review requested due to automatic review settings February 25, 2026 18:32
@pelikhan pelikhan merged commit 315511d into main Feb 25, 2026
50 checks passed
@pelikhan pelikhan deleted the copilot/add-max-continues-field branch February 25, 2026 18:33
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds a max-continuations engine configuration field to enable Copilot CLI autopilot mode with a configurable continuation limit, plus validation and schema/docs updates.

Changes:

  • Extend EngineConfig parsing and workflow schema to accept engine.max-continuations.
  • Add an engine capability flag (SupportsMaxContinuations) and validation that rejects unsupported engines.
  • Apply Copilot CLI execution flags --autopilot --max-autopilot-continues <n> for agent runs when max-continuations > 1.

Reviewed changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
smoke-test-22406871179.txt Adds a smoke-test marker file for the run.
pkg/workflow/engine.go Adds MaxContinuations to EngineConfig and parses max-continuations from engine frontmatter.
pkg/workflow/agentic_engine.go Adds SupportsMaxContinuations() capability and backing field on BaseEngine.
pkg/workflow/copilot_engine.go Marks Copilot engine as supporting max-continuations.
pkg/workflow/copilot_engine_execution.go Adds Copilot CLI autopilot flags for non-detection runs when MaxContinuations > 1.
pkg/workflow/agent_validation.go Adds validation to error if max-continuations is used with an engine that doesn’t support it.
pkg/workflow/compiler_orchestrator_tools.go Wires the new max-continuations validation into compilation.
pkg/parser/schemas/main_workflow_schema.json Adds max-continuations to the engine_config schema and examples.
.github/workflows/smoke-copilot.md Updates smoke workflow to use object-form engine config with max-continuations: 2.
.github/workflows/smoke-copilot.lock.yml Updates generated lock output reflecting the new Copilot CLI flags.
.devcontainer/devcontainer.json Reorders feature entries (no functional change).
.changeset/patch-max-continuations.md Adds changeset entry documenting the new configuration option.
Comments suppressed due to low confidence (1)

pkg/workflow/engine.go:126

  • Casting uint64 to int for max-continuations can overflow on 32-bit platforms (or with unexpectedly large values), potentially producing a negative continuation limit. Prefer an overflow-safe conversion (like the existing parseIntValue/ParseIntFromConfig which guard overflow) or add an explicit bounds check before converting.
				} else if maxContUint64, ok := maxCont.(uint64); ok {
					config.MaxContinuations = int(maxContUint64)
				} else if maxContStr, ok := maxCont.(string); ok {

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +126 to +134
// validateMaxContinuationsSupport validates that max-continuations is only used with engines that support this feature
func (c *Compiler) validateMaxContinuationsSupport(frontmatter map[string]any, engine CodingAgentEngine) error {
// Check if max-continuations is specified in the engine config
_, engineConfig := c.ExtractEngineConfig(frontmatter)

if engineConfig == nil || engineConfig.MaxContinuations == 0 {
// No max-continuations specified, no validation needed
return nil
}
Copy link

Copilot AI Feb 25, 2026

Choose a reason for hiding this comment

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

There are existing integration tests for max-turns engine support validation (pkg/workflow/max_turns_validation_test.go), but no corresponding tests for the new max-continuations validation. Add coverage that asserts: (1) max-continuations errors on engines that don’t support it (e.g., claude/codex), and (2) it succeeds for copilot.

Copilot uses AI. Check for mistakes.
Comment on lines +89 to +93
// Add --autopilot and --max-autopilot-continues when max-continuations > 1
// Never apply autopilot flags to detection jobs; they are only meaningful for the agent run.
isDetectionJob := workflowData.SafeOutputs == nil
if !isDetectionJob && workflowData.EngineConfig != nil && workflowData.EngineConfig.MaxContinuations > 1 {
maxCont := workflowData.EngineConfig.MaxContinuations
Copy link

Copilot AI Feb 25, 2026

Choose a reason for hiding this comment

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

Add unit/integration coverage for the new autopilot argument behavior: when EngineConfig.MaxContinuations > 1 and this is an agent run (SafeOutputs != nil), the generated Copilot CLI command should include --autopilot --max-autopilot-continues <n>, and those flags should be absent for detection jobs (SafeOutputs == nil). There are already similar assertions in pkg/workflow/copilot_engine_test.go for other flags.

Copilot uses AI. Check for mistakes.
Comment on lines +121 to +125
if maxCont, hasMaxCont := engineObj["max-continuations"]; hasMaxCont {
if maxContInt, ok := maxCont.(int); ok {
config.MaxContinuations = maxContInt
} else if maxContUint64, ok := maxCont.(uint64); ok {
config.MaxContinuations = int(maxContUint64)
Copy link

Copilot AI Feb 25, 2026

Choose a reason for hiding this comment

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

max-continuations parsing only handles int, uint64, and numeric strings. When engine config comes from JSON (e.g., included engine config via extractEngineConfigFromJSON), numbers are decoded as float64, so max-continuations will be silently ignored and autopilot won’t be enabled. Consider using the existing int-conversion helpers (e.g., ConvertToInt / parseIntValue / ParseIntFromConfig) and/or handling float64/int64/json.Number explicitly; also emit a warning/error when the key is present but unparseable.

This issue also appears on line 124 of the same file.

See below for a potential fix:

				switch v := maxTurns.(type) {
				case int:
					config.MaxTurns = strconv.Itoa(v)
				case int64:
					config.MaxTurns = strconv.FormatInt(v, 10)
				case uint64:
					config.MaxTurns = strconv.FormatUint(v, 10)
				case float64:
					// JSON numbers are decoded as float64; coerce to int64 for formatting.
					config.MaxTurns = strconv.FormatInt(int64(v), 10)
				case json.Number:
					// Preserve the textual representation; assumed to be numeric.
					config.MaxTurns = v.String()
				case string:
					config.MaxTurns = v
				default:
					engineLog.Printf("Unsupported type for 'max-turns': %T (value: %v); ignoring", v, v)
				}
			}

			// Extract optional 'max-continuations' field
			if maxCont, hasMaxCont := engineObj["max-continuations"]; hasMaxCont {
				switch v := maxCont.(type) {
				case int:
					config.MaxContinuations = v
				case int64:
					config.MaxContinuations = int(v)
				case uint64:
					config.MaxContinuations = int(v)
				case float64:
					// JSON numbers are decoded as float64; coerce to int.
					config.MaxContinuations = int(v)
				case json.Number:
					if parsed, err := strconv.Atoi(v.String()); err == nil {
						config.MaxContinuations = parsed
					} else {
						engineLog.Printf("Invalid numeric value for 'max-continuations': %v; ignoring", v)
					}
				case string:
					if parsed, err := strconv.Atoi(v); err == nil {
						config.MaxContinuations = parsed
					} else {
						engineLog.Printf("Invalid string value for 'max-continuations': %q; ignoring", v)
					}
				default:
					engineLog.Printf("Unsupported type for 'max-continuations': %T (value: %v); ignoring", v, v)

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants