Skip to content

Set Pi gateway context window for Copilot Claude Sonnet 5 - #63494

Merged
pelikhan merged 11 commits into
mainfrom
copilot/fix-aw-gateway-model-context-window
Sep 26, 2026
Merged

pelikhan merged 11 commits into
mainfrom
copilot/fix-aw-gateway-model-context-window

Conversation

Copilot AI commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

Pi treats aw-gateway as a custom provider, so its model entries do not inherit context limits from Pi’s built-in Copilot catalog. Without contextWindow, claude-sonnet-5 falls back to 128k and can compact conversation history well before its 1M-token capacity.

  • Gateway model metadata: Set contextWindow: 1000000 for GitHub Copilot’s claude-sonnet-5. Leave other models unchanged rather than assign unverified limits.
  • Coverage: Add tests for the generated models.json and for unknown or differently routed models.

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix aw-gateway model registration to include context window Set Pi gateway context window for Copilot Claude Sonnet 5 Sep 25, 2026
Copilot AI requested a review from pelikhan September 25, 2026 19:31
@pelikhan

Copy link
Copy Markdown
Collaborator

@copilot add front matter field to configure context window on the engine element.

Copilot AI and others added 6 commits September 25, 2026 19:57
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 AI commented Sep 25, 2026

Copy link
Copy Markdown
Contributor Author

@copilot add front matter field to configure context window on the engine element.

Implemented in 0faf820. engine.context-window is now parsed, documented in the schema, and passed into Pi gateway models.json generation with focused Go/JS coverage.

@pelikhan

Copy link
Copy Markdown
Collaborator

@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.

Copilot AI and others added 2 commits September 25, 2026 20:41
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>

Copilot AI commented Sep 25, 2026

Copy link
Copy Markdown
Contributor Author

@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.

Implemented in 202c3f8 (with additional coverage in 474c1bc). EngineCapabilities.ContextWindow now identifies support; Pi is enabled, and unsupported engines emit a warning when engine.context-window is set.

@pelikhan
pelikhan marked this pull request as ready for review September 25, 2026 20:51
Copilot AI balanced review requested due to automatic review settings September 25, 2026 20:51

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 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 Medium severity · 1 Low severity

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-window parsing, 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.

Comment thread pkg/workflow/agent_validation.go Outdated
Comment on lines +145 to +146
_, engineConfig, _ := c.ExtractEngineConfig(frontmatter)
if engineConfig == nil || engineConfig.ContextWindow == 0 || engine.GetCapabilities().ContextWindow {
Comment thread pkg/workflow/engine.go
func applyReferencedEngineFields(config *EngineConfig, engineObj map[string]any, topLevel engineTopLevelConfig) {
applyEngineProviderFields(config, engineObj)
applyEnginePermissionMode(config, engineObj)
applyEngineContextWindowField(config, engineObj)
Comment thread pkg/workflow/engine_definition.go Outdated
type EngineCapabilitiesDefinition struct {
ToolsAllowlist bool `yaml:"tools-allowlist,omitempty"`
MaxTurns bool `yaml:"max-turns,omitempty"`
ContextWindow bool `yaml:"context-window,omitempty"`
Comment on lines +14325 to +14328
"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."
@gh-aw-bot

Copy link
Copy Markdown
Collaborator

@copilot Please review the current head, address any remaining maintainer feedback, refresh the branch if needed, and continue with the pr-finisher skill.

Generated by 👨🍳 PR Sous Chef

Generated by 👨‍🍳 PR Sous Chef · pi · gpt54 · 25.1 AIC · ⌖ 8.84 AIC · ⊞ 9.3K · ◷
Comment /souschef to run again

Co-authored-by: gh-aw-bot <259018956+gh-aw-bot@users.noreply.github.com>

Copilot AI commented Sep 25, 2026

Copy link
Copy Markdown
Contributor Author

@copilot Please review the current head, address any remaining maintainer feedback, refresh the branch if needed, and continue with the pr-finisher skill.

Generated by [👨🍳 PR Sous Chef](htt...

Addressed the remaining review feedback in 620113b:

  • The unsupported-engine context-window warning now uses the resolved EngineConfig, so imported engine settings also trigger it. Added a compile test with an imported engine: {id: codex, context-window: …}.
  • context-window is now parsed on inline engine definitions (engine.runtime.id), with a test for that path.
  • Removed context-window from behaviors.capabilities. The schema never allowed it there, and behavior-defined engines have no code that uses it.
  • Regenerated docs/public/editor/autocomplete-data.json. The regenerated file also picks up some older schema changes that hadn't been copied over yet.

make agent-report-progress passes locally. My push won't start CI, so a maintainer needs to re-run it.

Copilot AI requested a review from gh-aw-bot September 25, 2026 21:19
@pelikhan
pelikhan merged commit 5ecd40a into main Sep 26, 2026
45 checks passed
@pelikhan
pelikhan deleted the copilot/fix-aw-gateway-model-context-window branch September 26, 2026 05:22
@github-actions

Copy link
Copy Markdown
Contributor

🎉 This pull request is included in a new release.

Release: v0.89.22

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.

pi_models_json.cjs registers aw-gateway models with no contextWindow, so pi falls back to a 128k default well below the real model's capacity

4 participants