Repository navigation
fix(ndc): record what a refused compression cost - #188
Merged
Merged
Conversation
fdaviddpt
pushed a commit
that referenced
this pull request
Jul 26, 2026
Review of #188 pointed out the entry read as though every NDC call is now accounted for. It is not: a call that times out or exits non-zero raises inside call_haiku before any token counts exist, so there is nothing to log on that path. Narrowed to what the change actually does, with the remaining gap tracked in #190 rather than implied away. Co-Authored-By: Max <noreply>
Contributor
Author
|
Review point taken — the entry did read as though every NDC call is now accounted for, and it is not. A call that times out or exits non-zero raises inside CHANGELOG narrowed to the outcomes this actually covers, and the remaining gap is tracked in #190 rather than implied away. |
`log_tokens` sat inside the success branch of the NDC block, so a call the model answered with a refusal or a clarification — which since #178 has its own branch — was never accounted for. The call had already gone out and already cost money; what came back does not change that. The failure mode is the one #178 was about. A model that starts refusing compression gives a run where memory stops growing AND reported cost drops to zero, which reads as "nothing happened" rather than "this failed repeatedly and was paid for". Moved above the branch, so every outcome is recorded. The summarize path in Step 6 already logs before it branches — checked while in there, it needs nothing. The reject-gate stub gains configurable token counts (STUB_NDC_TOKENS, default unchanged) so the new test can assert the logged numbers are the ones the call actually spent, not just that some line exists. Co-Authored-By: Max <noreply>
Review of #188 pointed out the entry read as though every NDC call is now accounted for. It is not: a call that times out or exits non-zero raises inside call_haiku before any token counts exist, so there is nothing to log on that path. Narrowed to what the change actually does, with the remaining gap tracked in #190. Co-Authored-By: Max <noreply>
fdaviddpt
force-pushed
the
max/ndc-token-accounting-180
branch
from
July 26, 2026 21:53
5b9811a to
723b7a8
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #180.
log_tokenssat inside the success branch of the NDC block. Since #178 that block has a third outcome — the model answering with a refusal or a clarification — and those calls went out, spent input and output tokens, and cost money that was never recorded.The failure mode is the one #178 was about: a model that starts refusing compression gives a run where memory stops growing and reported cost drops to zero. That reads as "nothing happened" rather than "this failed repeatedly and was paid for".
The call is now accounted for before its verdict is read, because spending it is what already happened.
The issue suggested checking the summarize path in Step 6 for the same shape — it already logs before it branches, so it needs nothing.
Test
tests/test_ndc_reject_gate.pygains a case that drives a rejected NDC call with real token counts and asserts the numbers reaching the log are the ones the call spent, not merely that some line exists. The reject-gate stub gainsSTUB_NDC_TOKENSfor that; unset, it emits zeros exactly as before, so no existing test changes behaviour.Red against pre-fix code, green after. Full suite: 735 passed, 41 skipped.