Use AWF audit JSONL as source for effective token failure parsing#31104
Conversation
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Fixes max-effective-tokens reporting in failure handling by using AWF firewall audit JSONL records as the canonical source of the max effective token budget (with env var fallback), and updates compiled workflows to propagate effective-token rate-limit context.
Changes:
- Added audit-log parsing in
handle_agent_failure.cjsto extract max effective tokens (supportsmax_effective_tokensandmaxEffectiveTokens, including nested shapes) and prefersandbox/firewall/audit/log.jsonloveraudit.jsonl. - Wired failure-path budget resolution to prefer the parsed audit value, and reused the same audit-log path resolver for firewall auth error parsing.
- Updated workflow lock files to surface
effective_tokens_rate_limit_erroroutputs and configure/export max effective tokens consistently; added unit tests for audit parsing and path preference.
Show a summary per file
| File | Description |
|---|---|
| actions/setup/js/handle_agent_failure.cjs | Adds audit-log path resolution + max-effective-tokens parsing and uses it in failure reporting. |
| actions/setup/js/handle_agent_failure.test.cjs | Adds unit coverage for audit parsing (missing file, nested/camelCase extraction, log.jsonl preference). |
| .github/workflows/video-analyzer.lock.yml | Propagates effective token rate-limit output and configures maxEffectiveTokens / GH_AW_MAX_EFFECTIVE_TOKENS. |
| .github/workflows/test-workflow.lock.yml | Propagates effective token rate-limit output and configures maxEffectiveTokens / GH_AW_MAX_EFFECTIVE_TOKENS. |
| .github/workflows/test-project-url-default.lock.yml | Propagates effective token rate-limit output and configures maxEffectiveTokens / GH_AW_MAX_EFFECTIVE_TOKENS. |
| .github/workflows/test-dispatcher.lock.yml | Propagates effective token rate-limit output and configures maxEffectiveTokens / GH_AW_MAX_EFFECTIVE_TOKENS. |
| .github/workflows/smoke-opencode.lock.yml | Propagates effective token rate-limit output and configures maxEffectiveTokens / GH_AW_MAX_EFFECTIVE_TOKENS. |
| .github/workflows/smoke-gemini.lock.yml | Propagates effective token rate-limit output and configures maxEffectiveTokens / GH_AW_MAX_EFFECTIVE_TOKENS. |
| .github/workflows/smoke-crush.lock.yml | Propagates effective token rate-limit output and configures maxEffectiveTokens / GH_AW_MAX_EFFECTIVE_TOKENS. |
| .github/workflows/smoke-ci.lock.yml | Propagates effective token rate-limit output and configures maxEffectiveTokens / GH_AW_MAX_EFFECTIVE_TOKENS. |
| .github/workflows/release.lock.yml | Propagates effective token rate-limit output and configures maxEffectiveTokens / GH_AW_MAX_EFFECTIVE_TOKENS. |
| .github/workflows/poem-bot.lock.yml | Propagates effective token rate-limit output and configures maxEffectiveTokens / GH_AW_MAX_EFFECTIVE_TOKENS. |
| .github/workflows/jsweep.lock.yml | Propagates effective token rate-limit output and configures maxEffectiveTokens / GH_AW_MAX_EFFECTIVE_TOKENS. |
| .github/workflows/issue-triage-agent.lock.yml | Propagates effective token rate-limit output and configures maxEffectiveTokens / GH_AW_MAX_EFFECTIVE_TOKENS. |
| .github/workflows/hippo-embed.lock.yml | Propagates effective token rate-limit output and configures maxEffectiveTokens / GH_AW_MAX_EFFECTIVE_TOKENS. |
| .github/workflows/gpclean.lock.yml | Propagates effective token rate-limit output and configures maxEffectiveTokens / GH_AW_MAX_EFFECTIVE_TOKENS. |
| .github/workflows/firewall.lock.yml | Propagates effective token rate-limit output and configures maxEffectiveTokens / GH_AW_MAX_EFFECTIVE_TOKENS. |
| .github/workflows/example-permissions-warning.lock.yml | Propagates effective token rate-limit output and configures maxEffectiveTokens / GH_AW_MAX_EFFECTIVE_TOKENS. |
| .github/workflows/dev.lock.yml | Propagates effective token rate-limit output and configures maxEffectiveTokens / GH_AW_MAX_EFFECTIVE_TOKENS. |
| .github/workflows/daily-malicious-code-scan.lock.yml | Propagates effective token rate-limit output and configures maxEffectiveTokens / GH_AW_MAX_EFFECTIVE_TOKENS. |
| .github/workflows/copilot-token-optimizer.lock.yml | Propagates effective token rate-limit output and configures maxEffectiveTokens / GH_AW_MAX_EFFECTIVE_TOKENS. |
| .github/workflows/codex-github-remote-mcp-test.lock.yml | Propagates effective token rate-limit output and configures maxEffectiveTokens / GH_AW_MAX_EFFECTIVE_TOKENS. |
| .github/workflows/code-simplifier.lock.yml | Propagates effective token rate-limit output and configures maxEffectiveTokens / GH_AW_MAX_EFFECTIVE_TOKENS. |
| .github/workflows/changeset.lock.yml | Propagates effective token rate-limit output and configures maxEffectiveTokens / GH_AW_MAX_EFFECTIVE_TOKENS. |
| .github/workflows/brave.lock.yml | Propagates effective token rate-limit output and configures maxEffectiveTokens / GH_AW_MAX_EFFECTIVE_TOKENS. |
| .github/workflows/bot-detection.lock.yml | Propagates effective token rate-limit output and configures maxEffectiveTokens / GH_AW_MAX_EFFECTIVE_TOKENS. |
| .github/workflows/ai-moderator.lock.yml | Propagates effective token rate-limit output and configures maxEffectiveTokens / GH_AW_MAX_EFFECTIVE_TOKENS. |
| .github/workflows/ace-editor.lock.yml | Propagates effective token rate-limit output and configures maxEffectiveTokens / GH_AW_MAX_EFFECTIVE_TOKENS. |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 70/219 changed files
- Comments generated: 1
| function parseFirewallAuthErrors(auditJsonlPath) { | ||
| try { | ||
| if (!fs.existsSync(auditJsonlPath)) { | ||
| const resolvedPath = resolveFirewallAuditLogPath(auditJsonlPath); | ||
| if (!fs.existsSync(resolvedPath)) { | ||
| return []; |
| with: | ||
| script: | | ||
| try { | ||
| const { setupGlobals } = require('${{ runner.temp }}/gh-aw/actions/setup_globals.cjs'); |
There was a problem hiding this comment.
@copilot move to .cjs file in actions/setup/js + parse the effective token error info from JSONL as well
There was a problem hiding this comment.
Implemented in 515fd17. Effective-token error info is now parsed directly in actions/setup/js/handle_agent_failure.cjs from AWF firewall audit JSONL (including nested snake_case/camelCase fields and text-based ET rate-limit signals), with existing env vars kept as fallback. Added targeted tests in handle_agent_failure.test.cjs.
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 move effective token computation in own JavaScript file |
|
@copilot merge main and recompile |
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Done in |
|
@copilot merge main and recompile |
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Done in |
Bug Fix
What was the bug?
Failure handling relied on raw/env outputs for effective-token failure context. While
max-effective-tokenswas being moved to AWF firewall audit records,effective_tokensand ET rate-limit error signaling could still drift from the canonical runtime values in audit JSONL.How did you fix it?
Audit log as source of truth
max_effective_tokensandmaxEffectiveTokens(including nested objects).effective_tokens/effectiveTokenseffective_tokens_rate_limit_error/effectiveTokensRateLimitErrorEffective-token logic extracted to dedicated module
actions/setup/js/effective_tokens_context.cjs.handle_agent_failure.cjsto consume the new module while preserving behavior and existing fallbacks.Audit file resolution and compatibility
sandbox/firewall/audit/log.jsonl.sandbox/firewall/audit/audit.jsonl.Failure context wiring
GH_AW_MAX_EFFECTIVE_TOKENSwhen audit data is unavailable.effective_tokensand ET rate-limit signals, with existing env vars as fallback.Coverage updates
log.jsonlpreference overaudit.jsonl, and effective-token error info parsing from JSONL.Branch maintenance from feedback
maininto this PR branch and recompiled workflows to refresh generated lock artifacts while keeping the original fix unchanged.Testing
handle_agent_failure.test.cjs)../pkg/cli/...,./pkg/workflow/...,./pkg/parser/...).Example