सीधे आँकड़ों पर जाएँ

← सभी लेख

Coding Agents in CI: A $0.50 Pipeline Budget

01 / Give the agent a dollar limit before repository access

A coding agent in CI needs a purchasing limit, not just an instruction to be economical. For this example, set a $0.50 API ceiling per pipeline run, with a $0.40 admission threshold and $0.10 of untouched headroom. Track runner charges separately. These are proposed operating limits, not vendor defaults or a guarantee supplied by an agent.

The implementation belongs outside the model: a request broker that owns the API credential, checks the remaining allowance, and approves or rejects every call. An agent that can bypass that broker can bypass the budget.

02 / A sample receipt totals $0.167 for model usage

The following rates and token counts are invented solely to demonstrate accounting. They are not CheapRelay prices, measured performance, or a quote for any model. Replace them with the actual billing categories and rates for your chosen route before enabling CI.

  • ■ Uncached input: 60,000 tokens at $1.00 per million = $0.060.
  • ■ Cache reads: 120,000 tokens at $0.10 per million = $0.012.
  • ■ Cache writes: 20,000 tokens at $1.25 per million = $0.025.
  • ■ Output: 14,000 tokens at $5.00 per million = $0.070.
  • ■ API subtotal: $0.167, leaving $0.233 below the $0.40 admission threshold.
  • ■ Runner: six minutes at an assumed $0.01 per minute = $0.060.
  • ■ Combined illustrative run cost: $0.227.

In this example, the three input categories are mutually exclusive. When implementing the receipt, normalize your provider's usage fields before multiplying: do not charge cached tokens again as ordinary input. Chat Completions exposes prompt, completion, and total token counts, providing a starting point for reconciliation. ([help.openai.com](https://help.openai.com/en/articles/4936856-understanding-and-counting-tokens?utm_source=openai))

03 / Reserve $0.045 before authorizing the next request

Suppose the next call contains at most 25,000 input tokens and allows 4,000 output tokens. At the illustrative uncached rates, reserve $0.025 + $0.020 = $0.045. Treat cache eligibility as a possible saving, not guaranteed budget capacity. Include any separately chargeable features in the reservation or disable them.

With $0.167 settled and no calls outstanding, the projected total becomes $0.212: approve. With $0.380 settled, it becomes $0.425: reject because it exceeds the $0.40 admission threshold. Release unused reservation only after settlement. Keep unresolved requests reserved.

Use a compatible tokenizer or supported counting endpoint for the complete serialized request, including tools and conversation history. Token-counting facilities can estimate input before dispatch; the estimate is not the final bill. ([developers.openai.com](https://developers.openai.com/api/docs/guides/token-counting?utm_source=openai))

Set the endpoint's supported output limit explicitly. For OpenAI endpoints, max_output_tokens or max_completion_tokens also bounds non-visible generated tokens, not merely the answer text. Verify equivalent behavior on your selected relay route. ([developers.openai.com](https://developers.openai.com/api/docs/guides/token-counting?utm_source=openai))

04 / Make retries and parallel jobs share the same wallet

Use one atomic ledger keyed by pipeline run ID. Otherwise, twenty matrix jobs each receiving $0.50 create $10.00 of authorized exposure. Every request, retry, fallback, and child agent must acquire a reservation from that same ledger.

For this policy, allow one retry, but require a fresh reservation. If a connection fails after dispatch, retain the original reservation until its billing status is resolved. A missing response is not evidence of zero spend. If reconciliation is unavailable, stop rather than assume the money remains.

Add a ten-minute job timeout as a separate operational guardrail. GitHub Actions supports timeout-minutes, but elapsed time is not a dollar meter. ([docs.github.com](https://docs.github.com/en/actions/reference/workflows-and-actions/workflow-syntax?ref=ty1er.com&utm_source=openai)) Group runs by pull request and enable cancel-in-progress to cancel superseded work. ([docs.github.com](https://docs.github.com/en/actions/reference/workflows-and-actions/workflow-syntax?ref=cloud-tech-simplified&utm_source=openai))

05 / Publish the receipt even when the agent stops early

Always retain an artifact containing run ID, request IDs, rate snapshot, token categories, settled cost, outstanding reservations, runner estimate, and stop reason. Mark budget exhaustion explicitly; do not report an unfinished repair as successful.

CheapRelay's pay-as-you-go token billing, including cache reads and writes, fits this receipt-based approach without a monthly subscription. Keep enforcement in your broker rather than assuming an OpenAI-compatible route provides a native per-run cap. Sign up for CheapRelay, then test the ledger on a small pipeline before expanding access.

साइन अप दाम खुद आज़माएँ, साइन-अप क्रेडिट साथ है।

आगे पढ़ने को

तारीखखंडभाषाशीर्षक
2026-10-25कोडिंग एजेंट, सस्ते मेंENCoding Assistant Habits That Double Your Bill
A receipt-style breakdown shows how oversized prompts and verbose answers turn a $0.60 coding session into $1.20, before retries.
2026-10-25कोडिंग एजेंट, सस्ते मेंENThree AI CLIs, One Desktop, a $30 Budget
A receipt-style plan for running Claude Code, Codex and Gemini CLI together, with a $30 usage budget and no invented token prices.
2026-10-25कोडिंग एजेंट, सस्ते मेंENClaude Code on Windows: A PowerShell Cost Receipt
Configure Claude Code with PowerShell environment variables, then audit a four-line token receipt without confusing example rates with real prices.
2026-10-25कोडिंग एजेंट, सस्ते मेंENGemini CLI vs Claude Code: The Shell Chore Receipt
A concrete token-cost comparison for shell chores, with itemized receipts, retry math, cache caveats, and practical spending controls.
2026-10-25कोडिंग एजेंट, सस्ते मेंENCheap First, Escalate Later: A Coding Cost Receipt
A worked token receipt shows how cheaper-first pair programming can cut API spending, with clear rules for escalating without wasting developer time.
2026-10-25कोडिंग एजेंट, सस्ते मेंENCoding Agent Memory Files: Show Me the Receipt
A concrete cost breakdown of coding agent memory files: repeated input, cache reads, maintenance, and the point where useful instructions pay off.