Add caching budget scenario to loop-context by Tusm11 · Pull Request #347 · cobusgreyling/loop-engineering · GitHub
Skip to content

Add caching budget scenario to loop-context - #347

Merged
cobusgreyling merged 1 commit into
cobusgreyling:mainfrom
Tusm11:loop-context-caching-budget
Jul 22, 2026
Merged

cobusgreyling merged 1 commit into
cobusgreyling:mainfrom
Tusm11:loop-context-caching-budget

Conversation

@Tusm11

@Tusm11 Tusm11 commented Jul 22, 2026 •

Copy link
Copy Markdown
Contributor

Problem

loop-cost's --with-caching flag reports a discounted caching
scenario, but loop-context --budget-from-pattern (which resolves a
token budget by shelling out to loop-cost) had no way to request it —
--budget-scenario only accepted realistic, action, or report.
Anyone using prompt caching had no way to set a circuit-breaker budget
that reflects their actual discounted spend.

Fix

  • Add 'caching' as a valid --budget-scenario value.
  • Pass --with-caching through to loop-cost automatically when that
    scenario is selected.
  • Give a specific error message (pointing at stable_fraction in
    registry.yaml) when a pattern doesn't support the caching scenario
    yet, instead of a generic "missing tokensPerRun" error.
  • Update --help text accordingly.

No changes to the ledger/circuit-breaker logic itself — this is scoped
to budget resolution only.

Depends on: #346 (adds stable_fraction and --with-caching to
loop-cost) — should be merged first, or reviewed together.

Checklist

  • Links work from README or relevant index
  • No secrets, tokens, or internal URLs

loop-cost's --with-caching flag (added in a prior PR) reports a
discounted 'caching' scenario alongside noop/report/action/realistic,
but loop-context's --budget-from-pattern had no way to resolve a
budget from it. This adds 'caching' as a valid --budget-scenario,
passes --with-caching through to loop-cost when it's selected, and
gives a clearer error pointing at registry.yaml's stable_fraction
when a pattern doesn't support it yet.

Depends on the stable_fraction/--with-caching work in loop-cost.
@Tusm11
Tusm11 requested a review from cobusgreyling as a code owner July 22, 2026 05:20
@cobusgreyling
cobusgreyling merged commit 16647a2 into cobusgreyling:main Jul 22, 2026
2 checks passed
cobusgreyling pushed a commit that referenced this pull request Jul 22, 2026
Record merges, escalate loop-cost/loop-context version+publish gap, rebased draft.
cobusgreyling added a commit that referenced this pull request Jul 22, 2026
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.

2 participants