Set Pi gateway context window for Copilot Claude Sonnet 5 - #63494
Conversation
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
|
@copilot add front matter field to configure context window on the engine element. |
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
|
@copilot investigate if other agentic engines support this flag. Add boolean to agentic engine to notify if it is supported by the agentic engine. Raise warning if not supported. |
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Implemented in 202c3f8 (with additional coverage in 474c1bc). |
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Inline and imported configurations can silently mishandle the new setting, and generated editor metadata is stale.
Get a fresh assessment by requesting another Copilot review.
Review effort: Balanced
Findings: 3
Open (4)
What changed in this PR
Adds explicit Pi gateway context-window metadata, including the 1M-token limit for GitHub Copilot’s Claude Sonnet 5.
Changes:
- Adds
engine.context-windowparsing, capability validation, schema, and documentation. - Emits context-window metadata in Pi’s generated
models.json. - Adds Go and JavaScript coverage for defaults, overrides, and unsupported engines.
| File | Description |
|---|---|
actions/setup/js/pi_models_json.cjs |
Resolves and emits Pi context windows. |
actions/setup/js/pi_models_json.test.cjs |
Tests model metadata generation. |
pkg/workflow/pi_engine.go |
Passes configured context windows to setup. |
pkg/workflow/pi_engine_test.go |
Tests Pi environment generation. |
pkg/workflow/engine.go |
Parses the new engine setting. |
pkg/workflow/engine_definition.go |
Adds declarative capability metadata and minor URL parsing cleanup. |
pkg/workflow/engine_config_test.go |
Tests engine capability support. |
pkg/workflow/engine_args_test.go |
Tests configuration extraction. |
pkg/workflow/compiler_orchestrator_tools.go |
Invokes capability validation. |
pkg/workflow/agentic_engine.go |
Adds the runtime capability and slice-access cleanup. |
pkg/workflow/agent_validation.go |
Warns for unsupported engines. |
pkg/workflow/agent_validation_model_test.go |
Tests capability warnings. |
pkg/parser/schemas/main_workflow_schema.json |
Defines context-window in frontmatter. |
docs/src/content/docs/reference/frontmatter-full.md |
Documents the new setting. |
| _, engineConfig, _ := c.ExtractEngineConfig(frontmatter) | ||
| if engineConfig == nil || engineConfig.ContextWindow == 0 || engine.GetCapabilities().ContextWindow { |
| func applyReferencedEngineFields(config *EngineConfig, engineObj map[string]any, topLevel engineTopLevelConfig) { | ||
| applyEngineProviderFields(config, engineObj) | ||
| applyEnginePermissionMode(config, engineObj) | ||
| applyEngineContextWindowField(config, engineObj) |
| type EngineCapabilitiesDefinition struct { | ||
| ToolsAllowlist bool `yaml:"tools-allowlist,omitempty"` | ||
| MaxTurns bool `yaml:"max-turns,omitempty"` | ||
| ContextWindow bool `yaml:"context-window,omitempty"` |
| "context-window": { | ||
| "type": "integer", | ||
| "minimum": 1, | ||
| "description": "Optional model context window metadata for engines that need to register explicit model catalog entries. Supported by the Pi engine when generating its AWF gateway models.json; other engines ignore it and emit a warning." |
|
@copilot Please review the current head, address any remaining maintainer feedback, refresh the branch if needed, and continue with the
|
Co-authored-by: gh-aw-bot <259018956+gh-aw-bot@users.noreply.github.com>
Addressed the remaining review feedback in 620113b:
|
|
🎉 This pull request is included in a new release. Release: |


Pi treats
aw-gatewayas a custom provider, so its model entries do not inherit context limits from Pi’s built-in Copilot catalog. WithoutcontextWindow,claude-sonnet-5falls back to 128k and can compact conversation history well before its 1M-token capacity.contextWindow: 1000000for GitHub Copilot’sclaude-sonnet-5. Leave other models unchanged rather than assign unverified limits.models.jsonand for unknown or differently routed models.