Skip to content

fix: retain paid usage from reasoning-ceiling retries - #1625

Closed
santoshkumarradha wants to merge 2 commits into
devfrom
codex/fix-retry-usage
Closed

santoshkumarradha wants to merge 2 commits into
devfrom
codex/fix-retry-usage

Conversation

@santoshkumarradha

@santoshkumarradha santoshkumarradha commented Sep 27, 2026 •

Copy link
Copy Markdown
Member

Actual completed supplier task

Actual terminal capture 1 · Capture 2

These short recordings show the actual completed terminal state, not the full task execution. Exact revisions, accounting receipts and limits are below.

Problem and behavior

Fixes #1624. A successful reasoning-only response at the output ceiling teaches the adapter to retry with more room. The first response is paid, but the session previously saw only the final answer. A real OpenRouter DeepSeek V4.1 Flash run recorded $0.058953156 across 53 transport responses versus $0.058353756 across 52 ledger rows: the missing $0.0005994 exactly matched the discarded 718-input/320-output response.

The adapter now notifies accounting owners before retrying. The session records the discarded response, including cache usage, with its model/role and original inline-versus-detached turn ownership. Existing full per-transport billing owners retain sole ledger ownership. Composed budget observers update the applicable day, task, seat and helper totals without releasing the in-flight reservation twice. The final response content, error behavior, context size and one-retry limit stay unchanged.

This is a separate dev-based accounting fix. It contains no task-admission or broad restart-audit changes.

Verification

  • Original production-source overlay fails the new regression: successful retry loses the first $0.0005994; failed retry loses all of that paid first attempt.
  • Six real-HTTP session cases repeated three times pass: success/error; inline/detached turn attribution; full billing ownership; independent ledger cost/call counts; cache-read/cache-write counts; day/task/seat/helper budgets and reservation release.
  • Provider contract cases cover successful retry, HTTP failure, cancellation, observer composition, unchanged final response and full per-transport billing. Focused race cases repeated five times pass.
  • Full provider package passes in 91.256 seconds. Live verification and final exact-head gates are reported separately below when complete.

Limits

The existing adapter may spend one retry within an already admitted logical call; this change records that spend and makes subsequent budget decisions accurate. It does not add a new admission policy for internal retries. Current direct consolidation/sentinel roads send no output ceiling and cannot enter this specific ceiling-learning retry. Auxiliary call ownership is explicit at the existing seven detached request sites, rather than inferred from role names.

Final revision and real terminal acceptance

Exact PR head: 6105c01e8dddbf988eced24008ee83d5fbc84fa5 (changelog identity only after independently reviewed production 1f4f3c51fed3d9c5f8be109138eebca2c61b83c7). Clean build and changelog checks pass; build SHA256 0085c71b3fd48b541ffd92e8c0440347d75fe7774dca80621ec5331f717e9858.

Two bounded live workflows ran using only deepseek/deepseek-v4.1-flash. Live source was the explicitly combined 961c98c0d50860ab517f33a4e148628abd290965: focused #1619 head25893534b plus this reviewed production fix, without broad #1604. This is not isolated-head live evidence.

Both runs naturally triggered a paid reasoning-ceiling response, which now appears immediately in the ledger. Their retries hit a provider-stream deadline; existing later reconciliation added the retry cost. No transport-cost parity or successful final live retry is claimed:

Settled trial First paid response retained Known transport cost Later reconciled cost Final ledger
1 (14 calls / 14 rows) $0.0005985 $0.009988692 $0.0014391 $0.011427792
2 (14 calls / 14 rows) $0.000446472 $0.009559980 $0.0013488 $0.010908780

Both generated supplier CSVs contain Bolts:12 available/3 needed and Nuts:7 available/8 needed; all24 inventory tests pass in each. A separate reviewer checked the settled raw receipts, model IDs and artifacts. Successful-retry semantics are covered by the HTTP regression cases above.

All required exact-head checks pass in run36337200573, including the full affected-package gate (4m42s) and light gate (3m51s). Independent review and live receipt audit are complete. Ready for review; no production deployment or merge.

Review media below are direct PR attachments. Repository-hosted evidence links have been removed. Exact revisions, validation results and limitations remain in this description; original source recordings and generated examples are retained locally.

trial2

@santoshkumarradha santoshkumarradha added bug Something the code does that it should not area:provider Routing, lanes, refusals, hedging, what a call costs labels Sep 27, 2026
@santoshkumarradha santoshkumarradha added this to the Reliable agent milestone Sep 27, 2026
@santoshkumarradha santoshkumarradha added area:session The engine — turns, tasks, the toolbelt, checkpoints sev:critical Data loss, money spent wrongly, a false done, or the merge queue blocked labels Sep 27, 2026
@santoshkumarradha
santoshkumarradha marked this pull request as ready for review September 27, 2026 17:37
@santoshkumarradha

Copy link
Copy Markdown
Member Author

Superseded by aggregate PR #1627: #1627 . The exact reviewed green head is verified as an ancestor of published Santosh/dev; its issue details, validation, direct GitHub media attachments and limitations are preserved in the aggregate. Closing this source PR under the approved batch-1 workflow. Source branch retained; no merge into dev/main is implied.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:provider Routing, lanes, refusals, hedging, what a call costs area:session The engine — turns, tasks, the toolbelt, checkpoints bug Something the code does that it should not sev:critical Data loss, money spent wrongly, a false done, or the merge queue blocked

Projects

None yet

Development

Successfully merging this pull request may close these issues.

provider: reasoning-ceiling retry drops the first paid attempt from usage

1 participant