Repository navigation
A hard dollar cap per PR-Agent run in GitHub Actions (OPENAI.API_BASE + LITELLM.EXTRA_HEADERS) #3942
domondi1
started this conversation in
Show and tell
Replies: 1 comment
|
Update: inferrail 0.4.16 prices OpenAI's |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
PR-Agent already reports what a run cost (
config.output_run_cost), but nothing stops a run. One big PR,/improveon a large diff, or a burst ofsynchronizeevents can make many model calls, and you see the bill after. This is a setup that puts a hard dollar ceiling on each review run, with no PR-Agent changes. It uses two settings PR-Agent already has:OPENAI.API_BASEandLITELLM.EXTRA_HEADERS.The pieces: a local gateway (Inferrail, open source; I maintain it) runs next to PR-Agent in the job. Every model call from that run carries the same work id and dollar budget, and the gateway refuses a call with HTTP 402 before it reaches OpenAI if it would push the run past the budget.
reviewanddescribeshare the one $0.50 budget because they send the same work id. The last line prints what the run cost: number of calls, tokens, dollars.What I checked (PR-Agent 0.47.0, inferrail 0.4.15, the same env vars as above, against a stand-in OpenAI endpoint with fixed token counts, publishing turned off):
review,describeandimproveon one PR: all 3 calls landed under the one work id, $0.000135 total; theX-Inferrail-*headers are stripped before the upstream call.budget 'work_id:pr-tight:per_work' ... would be exceeded, then it loggedFailed to review PRand exited. 0 calls reached the upstream, about 18 s total. No tight retry loop.Caveats:
OPENAI__API_BASEat it.inferrail modelslists them). PR-Agent's defaultgpt-5.6family is priced per context length and isn't in the released catalog yet, so with 0.4.15 setCONFIG__MODELto a priced model as above. Otherwise the gateway refuses with a clearINFERRAIL_E012instead of guessing.Happy to adjust this if PR-Agent maintainers would rather it live somewhere else.
All reactions