Skip to content

fix: prevent token exhaustion causing zero-output agentic workflow runs#2850

Merged
pethers merged 2 commits into
mainfrom
copilot/aw-news-month-ahead-failed
May 31, 2026
Merged

fix: prevent token exhaustion causing zero-output agentic workflow runs#2850
pethers merged 2 commits into
mainfrom
copilot/aw-news-month-ahead-failed

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 31, 2026

News: Month Ahead workflow consumed 23M/25M tokens on MCP data gathering, then session terminated before any safe output call — producing zero value from a 20-minute run.

Root cause

Token budget (~25M) is the binding constraint for opus models doing heavy MCP work, not the 60-minute time limit. The agent can exhaust tokens in ~20 minutes without ever reaching the PR creation phase. Existing prompts only enforced time-based deadlines.

Changes

Shared prompt modules (apply to all news workflows):

  • 00-base-contract.md — Added Rule Bump actions/checkout from 4.3.1 to 6.0.2 #9 (MANDATORY safe output call before exit), Timer C (token budget as binding constraint), critical mid-run checkpoint at minute 20
  • 01-bash-and-shell-safety.md — Added mandatory mid-run checkpoint with diagnostic script and escalation policy: compress scope → minimal PR → safeoutputs___noop fallback
  • 07-commit-and-pr.md — Rewrote deadline enforcement with Timer C awareness, token-budget tips (batch MCP calls, avoid re-reads of large files), mandatory safeoutputs___noop if PR creation fails

Workflow-level reinforcement (Tier-C aggregation workflows most at risk):

  • news-month-ahead.md, news-quarter-ahead.md, news-year-ahead.md, news-election-cycle.md — Added 🔴 token-budget awareness warning: check agent_minute before every phase transition, compress scope if ≥20 min with no artifacts on disk

Key enforcement mechanism

## Rule 9 – MANDATORY safe output
Before your session ends you **MUST** call exactly one of:
- `safeoutputs___create_pull_request` (preferred), OR
- `safeoutputs___noop` with a reason string

A run that exits without either call is a **total failure** — it wastes
compute budget and produces zero value.

Copilot AI linked an issue May 31, 2026 that may be closed by this pull request
@github-actions github-actions Bot added the size-xs Extra small change (< 10 lines) label May 31, 2026
@github-actions
Copy link
Copy Markdown
Contributor

🏷️ Automatic Labeling Summary

This PR has been automatically labeled based on the files changed and PR metadata.

Applied Labels: size-xs

Label Categories

  • 🗳️ Content: news, dashboard, visualization, intelligence
  • 💻 Technology: html-css, javascript, workflow, security
  • 📊 Data: cia-data, riksdag-data, data-pipeline, schema
  • 🌍 I18n: i18n, translation, rtl
  • 🔒 ISMS: isms, iso-27001, nist-csf, cis-controls
  • 🏗️ Infrastructure: ci-cd, deployment, performance, monitoring
  • 🔄 Quality: testing, accessibility, documentation, refactor
  • 🤖 AI: agent, skill, agentic-workflow

For more information, see .github/labeler.yml.

@github-actions
Copy link
Copy Markdown
Contributor

🔍 Lighthouse Performance Audit

Category Score Status
Performance 85/100 🟡
Accessibility 95/100 🟢
Best Practices 90/100 🟢
SEO 95/100 🟢

📥 Download full Lighthouse report

Budget Compliance: Performance budgets enforced via budget.json

…without safe output

Root cause: Agent exhausted ~23M/25M token budget on data gathering/analysis
and session terminated before reaching PR creation phase (no safe output call).

Changes:
- 00-base-contract.md: Add Rule #9 (mandatory safe output), Timer C (token
  budget), mid-run checkpoint warning, strengthen output contract
- 01-bash-and-shell-safety.md: Add mandatory mid-run checkpoint at minute 20
  with escalation policy for token-budget awareness
- 07-commit-and-pr.md: Rewrite deadline enforcement with Timer C, token-budget
  awareness tips, and noop fallback if PR call fails
- news-month-ahead.md: Add token-budget awareness warning to time budget section
- news-quarter-ahead.md, news-year-ahead.md, news-election-cycle.md: Add same
  token-budget awareness warning (all Tier-C aggregation workflows)

Closes #2849

Co-authored-by: pethers <1726836+pethers@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix workflow failure in News: Month Ahead fix: prevent token exhaustion causing zero-output agentic workflow runs May 31, 2026
Copilot AI requested a review from pethers May 31, 2026 12:50
@github-actions github-actions Bot added documentation Documentation updates workflow GitHub Actions workflows ci-cd CI/CD pipeline changes news News articles and content generation agentic-workflow Agentic workflow changes size-m Medium change (50-250 lines) labels May 31, 2026
@github-actions
Copy link
Copy Markdown
Contributor

🔍 Lighthouse Performance Audit

Category Score Status
Performance 85/100 🟡
Accessibility 95/100 🟢
Best Practices 90/100 🟢
SEO 95/100 🟢

📥 Download full Lighthouse report

Budget Compliance: Performance budgets enforced via budget.json

@pethers pethers marked this pull request as ready for review May 31, 2026 13:01
Copilot AI review requested due to automatic review settings May 31, 2026 13:01
@pethers pethers merged commit 6aed982 into main May 31, 2026
14 checks passed
@pethers pethers deleted the copilot/aw-news-month-ahead-failed branch May 31, 2026 13:01
Copy link
Copy Markdown
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.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agentic-workflow Agentic workflow changes ci-cd CI/CD pipeline changes documentation Documentation updates news News articles and content generation size-m Medium change (50-250 lines) size-xs Extra small change (< 10 lines) workflow GitHub Actions workflows

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[aw] News: Month Ahead failed

3 participants