Skip to content

feat: make budget notices state what is left and what to do - #11485

Merged
lpcox merged 3 commits into
mainfrom
copilot/make-budget-notices-more-informative
Nov 12, 2026
Merged

lpcox merged 3 commits into
mainfrom
copilot/make-budget-notices-more-informative

Conversation

Copilot AI commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

Credit and time notices gave only a percentage and an instruction that varied by threshold. That didn't tell an agent how much it could still do, and "submit now" is wrong for sub-agents now that #11479 delivers each notice to every conversation. Now every notice states the facts first, then one fixed line that each agent applies according to its own role. A new "little left" notice also fires when about five requests or five minutes remain.

[AWF AI CREDIT WARNING] 247 of 300 AI credits are used; at the current rate about 12 more model requests fit. If you are responsible for this workflow's final output, stop the remaining work and submit it now with what you have. Otherwise, finish your current step and return what you have to the agent that started you.

[AWF TIME WARNING] 16 of 20 minutes have passed; about 4 minutes remain. If you are responsible for …

This builds on #11479's per-conversation delivery (conversation keys, claim/acknowledge on a 2xx response, steering_delivery records). There is no second delivery path and no configuration change under src/.

Notice text

  • Credits: "X of Y AI credits are used; at the current rate about N more model requests fit."
    • N is the remaining credits divided by the average cost of the run's last 10 priced requests, rounded down. Routing-classifier requests are left out of the average.
    • If no recent request cost anything, the "about N more" clause is omitted rather than guessed.
    • Credit amounts are rounded down, so a notice never overstates what is left.
  • Time: "X of T minutes have passed; about N minutes remain." Under one minute it reads "less than a minute remains".
  • Directive: the line from the issue, word for word, in STEERING_DIRECTIVE (guards/steering-thresholds.js). The per-threshold message tables are removed.

"Little left" trigger

  • It fires when about 5 requests' worth of credits or about 5 minutes remain, only after at least 50% of the budget or deadline is used, and at most once per run for each kind.
  • Ranking: delivery state is now keyed by rank instead of threshold.
    • A threshold notice ranks as its percentage.
    • The little-left notice ranks as the highest threshold already crossed plus 0.5 (for example 90.5, or 0.5 if no threshold has been crossed).
    • So it is that kind's current notice when it fires, and the next 90, 95 or 99% threshold supersedes it. The existing "never deliver a less urgent notice after a more urgent one" rule applies unchanged.
  • Big requests: when one request costs at least half the budget, the little-left notice fires alongside the threshold it crossed.

Records and schema

  • steering_delivery gains a required trigger field: "threshold" or "little_left". For little_left, threshold is null; the schema enforces this with if/then/else.
  • The legacy steering {type, threshold} field is written only for threshold notices, so gh-aw's smoke test still sees only 80, 90, 95 and 99.
  • The reflect state gains little_left_triggered. thresholds_crossed and thresholds_pending list only integer thresholds.

Docs

  • "Runtime and AI-credit steering" in docs/api-proxy-sidecar.md and §10.1 of docs/awf-config-spec.md cover the message formats, the estimate rules, the trigger, the ranking and the record fields.

Notes for review

  • A ceiling change mid-run already resets threshold state. It now also resets the little-left trigger, so the trigger can fire again.
  • The issue's open question, whether Codex or Claude Code sub-agents can call safe-output tools, is not addressed here.

@rabeckett
rabeckett added this pull request to stack #11480 November 11, 2026 23:34
Copilot AI linked an issue Nov 11, 2026 that may be closed by this pull request
Copilot AI changed the title [WIP] Update budget notices to include remaining budget and actions feat: make budget notices state what is left and what to do Nov 11, 2026
Copilot AI requested a review from rabeckett November 11, 2026 23:55
@rabeckett
rabeckett requested a max review from Copilot November 11, 2026 23:55

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.

🟡 Changes recommended

Credit notices misrepresent small budgets and fractional usage, and the new warning trigger can break the routed-steering smoke test even when the agent follows the notice.

3 open issues
What changed in this PR

This PR makes AWF’s API-proxy budget notices actionable while preserving the existing per-conversation delivery path.

Changes:

  • Replaces percentage-only warnings with credit/request and time estimates plus one shared, role-aware directive.
  • Adds “little left” triggers and rank-based notice ordering.
  • Updates delivery records, reflection state, schema, documentation, and tests.
File Description
schemas/​token-usage.schema.json Validates notice triggers and nullable little-left thresholds.
docs/​awf-config-spec.md Documents notice formats, estimates, triggers, and ranking.
docs/​api-proxy-sidecar.md Explains steering behavior and delivery records.
containers/​api-proxy/​token-tracker.schema.test.js Covers threshold and little-left record formats.
containers/​api-proxy/​token-persistence.js Records triggers while preserving legacy threshold-only records.
containers/​api-proxy/​token-budget-log.js Passes request purpose into credit accounting.
containers/​api-proxy/​server.token-steering.test.js Updates end-to-end notice delivery and recording checks.
containers/​api-proxy/​server.network.test.js Adds the little-left reflection flag expectation.
containers/​api-proxy/​guards/​timeout-steering.test.js Tests time-notice wording, triggers, and ranking.
containers/​api-proxy/​guards/​timeout-steering.js Builds factual time notices and adds the five-minute trigger.
containers/​api-proxy/​guards/​steering-thresholds.test.js Tests notice ranks and supersession.
containers/​api-proxy/​guards/​steering-thresholds.js Defines the shared directive and rank helpers.
containers/​api-proxy/​guards/​ai-credits-guard.test.js Tests credit estimates, triggers, and classifier exclusion.
containers/​api-proxy/​guards/​ai-credits-guard.js Tracks recent costs and builds factual credit notices.
containers/​api-proxy/​body-handler.test.js Updates injection and delivery expectations.
containers/​api-proxy/​body-handler.js Selects and claims notices by rank and includes trigger metadata.

Review effort: Max

Base automatically changed from copilot/send-budget-notice-once-per-conversation to main November 12, 2026 01:11
Copilot AI and others added 3 commits November 11, 2026 17:11
…11479)

* fix: put budget notices at the end of the conversation on Messages, Chat Completions and Gemini (#11449)

* Initial plan

* fix(api-proxy): add budget notices at the end of the conversation on every API

Co-authored-by: rabeckett <[email protected]>

* docs(api-proxy): note extended-thinking cache limitation for Messages notices

Co-authored-by: rabeckett <[email protected]>

* docs(api-proxy): scope pending-warning skip rule to Messages, Chat Completions and Gemini

Co-authored-by: rabeckett <[email protected]>

---------

Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: rabeckett <[email protected]>

* feat: send each budget notice once to every conversation in the run

Co-authored-by: rabeckett <[email protected]>

* fix: steer Claude on Vertex, default Responses roles, skip token counting

Co-authored-by: rabeckett <[email protected]>

* fix: steer Claude on Bedrock and give stored-response requests their own notice entry

Co-authored-by: rabeckett <[email protected]>

* perf: skip steering conversation inspection until a budget threshold is crossed

Co-authored-by: rabeckett <[email protected]>

* fix: never steer Responses compaction requests

Co-authored-by: rabeckett <[email protected]>

* Potential fix for pull request finding

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>

* fix: key steering conversations with a per-process HMAC secret

Co-authored-by: rabeckett <[email protected]>

* Potential fix for pull request finding

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>

* test: assert steering conversation key properties instead of exact derivation

Co-authored-by: rabeckett <[email protected]>

* fix: persist and log the opaque steering conversation prefix directly

Co-authored-by: rabeckett <[email protected]>

* docs: describe both cases where steering_delivery.conversation is null

Co-authored-by: rabeckett <[email protected]>

---------

Co-authored-by: Copilot <[email protected]>
Co-authored-by: rabeckett <[email protected]>
Co-authored-by: Landon Cox <[email protected]>
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
@lpcox
lpcox force-pushed the copilot/make-budget-notices-more-informative branch from 2ff4e44 to 03e7d49 Compare November 12, 2026 01:11
@github-actions

Copy link
Copy Markdown
Contributor

✅ Copilot review passed with no inline comments.

@copilot Add the ready-for-aw label to this PR to trigger agentic CI smoke tests.

@github-actions

Copy link
Copy Markdown
Contributor

Documentation Preview

Documentation has been built for this PR.

Download preview artifact

To view locally:

  1. Download the docs-preview-pr-11485 artifact from the workflow run
  2. Unzip and open index.html in your browser

Built from commit b792f77

@lpcox
lpcox marked this pull request as ready for review November 12, 2026 01:16
@lpcox

lpcox commented Nov 12, 2026

Copy link
Copy Markdown
Collaborator

@copilot address review feedback

Copilot AI commented Nov 12, 2026

Copy link
Copy Markdown
Contributor Author

@copilot address review feedback

All three review concerns are addressed in 03e7d49: little-left deliveries preserve the superseded legacy threshold, and the credit display now retains precision for small budgets and rounds usage conservatively. The targeted API-proxy tests pass (144 tests).

Copilot AI requested a review from lpcox November 12, 2026 01:46
@lpcox
lpcox merged commit 2d966af into main Nov 12, 2026
47 of 48 checks passed
@lpcox
lpcox deleted the copilot/make-budget-notices-more-informative branch November 12, 2026 01:47
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.

Make budget notices say how much is left and what to do

4 participants