Add explicit top-level ET budget control and ET-limit failure attribution#31094
Merged
Conversation
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot
AI
changed the title
Add ET budget control and ET-limit failure attribution
Add explicit ET budget control and ET-limit failure attribution
May 8, 2026
Copilot created this pull request from a session on behalf of
pelikhan
May 8, 2026 21:28
View session
Contributor
There was a problem hiding this comment.
Pull request overview
Adds explicit Effective Token (ET) budget configuration (engine.max-effective-tokens, defaulting via a new constant) and propagates ET-budget / ET-related rate-limit signals into workflow outputs and conclusion failure attribution.
Changes:
- Parse and expose
engine.max-effective-tokens, including a default fallback (DefaultMaxEffectiveTokens). - Inject
apiProxy.maxEffectiveTokensinto generated AWF config and propagate ET usage + ET rate-limit detection signals to downstream jobs. - Detect ET budget/rate-limit failures from MCP gateway logs and surface them in failure issue/comment templates.
Show a summary per file
| File | Description |
|---|---|
| pkg/workflow/engine.go | Adds MaxEffectiveTokens to EngineConfig, parsing of max-effective-tokens, and a defaulting getter. |
| pkg/constants/constants.go | Introduces DefaultMaxEffectiveTokens default budget constant. |
| pkg/parser/schemas/main_workflow_schema.json | Adds schema support for engine.max-effective-tokens (int or numeric string). |
| pkg/workflow/awf_config.go | Adds apiProxy.maxEffectiveTokens to generated AWF config JSON using engine-config defaulting. |
| pkg/workflow/schemas/awf-config.schema.json | Extends AWF config schema to allow apiProxy.maxEffectiveTokens. |
| pkg/workflow/awf_config_test.go | Adds assertions/tests for default and overridden maxEffectiveTokens in AWF config JSON. |
| pkg/workflow/compiler_main_job.go | Exposes effective_tokens_rate_limit_error as an agent job output. |
| pkg/workflow/notify_comment.go | Passes ET usage / ET rate-limit flag and max ET budget into conclusion job env for attribution. |
| pkg/workflow/threat_detection.go | Ensures detection engine runs inherit MaxEffectiveTokens. |
| actions/setup/js/parse_mcp_gateway_log.cjs | Adds ET budget / rate-limit log detection and exports effective_tokens_rate_limit_error output. |
| actions/setup/js/parse_mcp_gateway_log.test.cjs | Adds unit tests for the new ET/rate-limit detection helper. |
| actions/setup/js/handle_agent_failure.cjs | Adds ET-focused failure context rendering and uses ET signals in failure attribution logic. |
| actions/setup/md/agent_failure_issue.md | Adds {effective_tokens_rate_limit_error_context} placeholder to failure issue template. |
| actions/setup/md/agent_failure_comment.md | Adds {effective_tokens_rate_limit_error_context} placeholder to failure comment template. |
| pkg/workflow/testdata/TestWasmGolden_CompileFixtures/basic-copilot.golden | Updates golden workflow output + AWF config JSON to include ET budget and rate-limit output. |
| pkg/workflow/testdata/TestWasmGolden_CompileFixtures/playwright-cli-mode.golden | Updates golden workflow output + AWF config JSON to include ET budget and rate-limit output. |
| pkg/workflow/testdata/TestWasmGolden_CompileFixtures/smoke-copilot.golden | Updates golden workflow output + AWF config JSON to include ET budget and rate-limit output. |
| pkg/workflow/testdata/TestWasmGolden_CompileFixtures/with-imports.golden | Updates golden workflow output + AWF config JSON to include ET budget and rate-limit output. |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 19/19 changed files
- Comments generated: 2
Comment on lines
+132
to
+136
| name: "object format - with max-effective-tokens", | ||
| frontmatter: map[string]any{ | ||
| "engine": map[string]any{ | ||
| "id": "claude", | ||
| "max-effective-tokens": 10000000, |
| const budgetLine = maxEffectiveTokens ? `\n- Configured ET budget: \`${maxEffectiveTokens}\`` : ""; | ||
| const runLine = runUrl ? `\n- Run: ${runUrl}` : ""; | ||
|
|
||
| return `\n**⛔ Effective Token Budget Exhausted**: The run failed due to effective-token budget/rate-limit enforcement in the API proxy.${usageLine}${budgetLine}${runLine}\n\nPrefer ET budget controls for diagnosis instead of run-count heuristics. You can tune this limit with \`engine.max-effective-tokens\` in workflow frontmatter.\n`; |
Collaborator
|
@copilot move max-effective-tokens to top level property, not under engine. |
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Contributor
Author
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
changed the title
Add explicit ET budget control and ET-limit failure attribution
Add explicit top-level ET budget control and ET-limit failure attribution
May 8, 2026
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.
New Feature
What does this feature do?
This adds a first-class effective-token (ET) budget control to workflows via top-level
max-effective-tokens(default10_000_000) and routes ET budget/rate-limit failures through conclusion reporting. Failures are now attributed to ET budget/rate-limit enforcement instead of run-count heuristics.Why is this feature needed?
Run counts are an unreliable cost proxy; ET is the actual budget/control plane used by the firewall and the most accurate signal for post-run diagnosis.
Implementation details
Frontmatter + compiler model
max-effective-tokensparsing to workflow config handling.10000000) and getter fallback behavior.AWF enforcement path
apiProxy.maxEffectiveTokens.ET-limit/rate-limit detection
effective_tokens_rate_limit_erroras step output and agent job output.Conclusion failure attribution
GH_AW_EFFECTIVE_TOKENS,GH_AW_MAX_EFFECTIVE_TOKENS,GH_AW_EFFECTIVE_TOKENS_RATE_LIMIT_ERROR).Generated AWF config now includes:
{ "apiProxy": { "enabled": true, "maxEffectiveTokens": 10000000 } }