feat: add unified setup-api-client action and remediation plan#1183
feat: add unified setup-api-client action and remediation plan#1183
Conversation
This commit adds: 1. New unified setup-api-client action (.github/actions/setup-api-client/action.yml) - Combines npm install + token export into one reusable action - Pins @octokit/* versions for consistency (20.0.2, 6.0.1, 9.1.5, 6.0.3) - Supports both JSON secrets and individual inputs - Reports token count for debugging 2. Comprehensive remediation plan (docs/fixes/RATE_LIMIT_REMEDIATION_PLAN.md) - Detailed PR history from #1008 to #1182 - Root cause analysis - Implementation phases - Testing strategy - Handoff protocol Next steps: Apply the action to high-frequency workflows
Automated Status SummaryHead SHA: 7901fcd
Coverage Overview
Coverage Trend
Top Coverage Hotspots (lowest coverage)
Updated automatically; will refresh on subsequent CI/Docker completions. Keepalive checklistScopeNo scope information available Tasks
Acceptance criteria
|
🤖 Keepalive Loop StatusPR #1183 | Agent: Codex | Iteration 0/5 Current State
🔍 Failure Classification| Error type | infrastructure | |
There was a problem hiding this comment.
Pull request overview
This pull request introduces infrastructure to address persistent API rate limiting issues by creating a unified action for dependency installation and token management, accompanied by a comprehensive remediation plan documenting 40+ prior attempts to fix these issues.
Changes:
- Added new
setup-api-clientcomposite action that combines npm dependency installation with token export functionality - Created detailed remediation plan documenting the complete history of rate limit fixes from PR #1008 through #1182, root cause analysis, and phased implementation strategy
- Established pinned versions for @octokit packages (rest@20.0.2, plugin-retry@6.0.1, plugin-paginate-rest@9.1.5, auth-app@6.0.3)
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 9 comments.
| File | Description |
|---|---|
.github/actions/setup-api-client/action.yml |
New unified composite action that installs @octokit dependencies and exports all available tokens to environment variables, supporting both JSON secrets input and individual token inputs |
docs/fixes/RATE_LIMIT_REMEDIATION_PLAN.md |
Comprehensive 623-line remediation plan documenting PR history, root cause analysis, implementation phases, success criteria, testing strategy, and handoff protocol |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This commit updates agents-keepalive-loop.yml to use the new unified setup-api-client action instead of separate npm install + export steps. Changes: - Replace 4 instances of 'npm install' + 'export-load-balancer-tokens' with single 'setup-api-client' action - Remove duplicate export block in evaluate job - Add setup-api-client to summary job Benefits: - Single point of dependency management (pinned versions) - Consistent token export across all jobs - Reduced workflow file from 965 to 887 lines - Easier maintenance - one action to update, not multiple blocks Jobs updated: - evaluate: lines 78-82 - mark-running: lines 332-336 - run-codex: lines 427-431 - summary: lines 639-643
This ensures the new unified setup action will be synced to consumer repos. Also marks export-load-balancer-tokens as deprecated.
When rate limits are exhausted, the summary comment now shows: ### 🛑 Agent Stopped: API capacity depleted This replaces the misleading '🔄 Agent Running' status that previously appeared when the agent was actually blocked by rate limits. The new status clearly indicates: - All token pools are exhausted - This is NOT a code/prompt problem - Automatic recovery when limits reset (~1 hour) Detection logic: - reason === 'rate-limit-exhausted' - action === 'defer' with rate-related reason
✅ Codex Completion CheckpointCommit: No new completions recorded this round. About this commentThis comment is automatically generated to track task completions. |
The check_api_wrapper_guard.py script now accepts either: - export-load-balancer-tokens (old pattern) - setup-api-client (new unified action) This allows workflows to use the new setup-api-client action without triggering lint errors.
|
Status | ✅ no new diagnostics |
|
Autofix updated these files:
|
Documents the relationship between: - setup-api-client action (exports tokens to GITHUB_ENV) - github-api-with-retry.js (reads env vars, creates token-aware wrapper) - token_load_balancer.js (token registry and selection) This ensures future changes to rate limiting understand the full component chain.
Fails CI when templates in templates/consumer-repo/ drift more than 50 lines from their main workflow counterparts in .github/workflows/. This prevents the situation where consumers receive outdated versions because templates weren't updated when main workflows changed. Triggered on: - Push/PR touching agents-*.yml workflows - Push/PR touching consumer templates
Explicitly instructs Copilot to read CLAUDE.md before any work. Also documents the template sync requirement.
- Renamed ci-template-drift.yml → health-74-template-drift.yml - Added to EXPECTED_NAMES in test_workflow_naming.py - Changed to warn-only mode (pre-existing drift shouldn't block PRs)
Required for test_inventory_docs_list_all_workflows test
Systematic audit found 8 jobs with github-script that make API calls but were missing setup-api-client for rate limit mitigation. Fixed jobs: - agents-autofix-loop.yml / metrics - agents-bot-comment-handler.yml / cleanup - reusable-10-ci-python.yml / logs_summary - reusable-16-agents.yml / preflight - reusable-20-pr-meta.yml / keepalive_orchestrator - reusable-20-pr-meta.yml / keepalive_from_gate - reusable-20-pr-meta.yml / pr_body_update - reusable-bot-comment-handler.yml / dispatch Identified false positive (no fix needed): - reusable-16-agents.yml / verify_issue_summary (uses core.summary only) Audit tracked in docs/fixes/setup-api-client-coverage-audit.csv Refs: #1183
* docs: add setup-api-client coverage audit spreadsheet Tracks which workflow jobs have github-script but lack setup-api-client. Identifies 10 gaps requiring fixes for complete rate limit remediation. Columns track fix status, PR number, and date for audit trail. * fix: add setup-api-client to all jobs making GitHub API calls Systematic audit found 8 jobs with github-script that make API calls but were missing setup-api-client for rate limit mitigation. Fixed jobs: - agents-autofix-loop.yml / metrics - agents-bot-comment-handler.yml / cleanup - reusable-10-ci-python.yml / logs_summary - reusable-16-agents.yml / preflight - reusable-20-pr-meta.yml / keepalive_orchestrator - reusable-20-pr-meta.yml / keepalive_from_gate - reusable-20-pr-meta.yml / pr_body_update - reusable-bot-comment-handler.yml / dispatch Identified false positive (no fix needed): - reusable-16-agents.yml / verify_issue_summary (uses core.summary only) Audit tracked in docs/fixes/setup-api-client-coverage-audit.csv Refs: #1183 * docs: update audit spreadsheet with PR#1189 * fix: address review comment - use correct checkout path per job Review pointed out that in reusable-20-pr-meta.yml, jobs that checkout workflows-lib should use ./workflows-lib/.github/actions/setup-api-client, while jobs that checkout consumer first should use ./consumer/.github/... Corrected: - keepalive_orchestrator, keepalive_from_gate, pr_body_update: use workflows-lib (Workflows repo is checked out to workflows-lib/ with setup-api-client) - keepalive_dispatch: kept using consumer checkout (consumer repo is checked out first, workflows-lib comes later) Updated audit spreadsheet to reflect the two different patterns.
Rate Limit Comprehensive Remediation
This PR comprehensively addresses the API rate limit issues across ALL workflows by:
Changes
New
setup-api-clientAction (.github/actions/setup-api-client/)toJSON(secrets)for automatic discoveryWorkflow Migration (60+ workflows)
export-load-balancer-tokensreferences withsetup-api-clientsecretsandgithub_tokenConsumer Template Updates (10+ templates)
templates/consumer-repo/.github/actions/setup-api-client/agents-auto-pilot.ymltemplateExpected CI Behavior
reusable-18-autofix.yml) check out frommainbranchsetup-api-clientaction doesn't exist onmainyetTesting
./.github/actions/setup-api-client✅Files Changed