fix: budget tracker drops test costs due to tuple index bug#518
Merged
gltanaka merged 2 commits intopromptdriven:mainfrom Feb 16, 2026
Merged
fix: budget tracker drops test costs due to tuple index bug#518gltanaka merged 2 commits intopromptdriven:mainfrom
gltanaka merged 2 commits intopromptdriven:mainfrom
Conversation
result[-2] on a 4-tuple returns model name string instead of cost float, silently dropping test/test_extend costs. Fixes promptdriven#508 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes a critical budget tracking bug where test and test_extend operations had their costs silently dropped to $0.00 due to incorrect tuple indexing. The root cause is that cmd_test_main returns a 4-tuple (content, cost, model, agentic_success) with cost at index 1, but the generic cost extraction logic used result[-2] which accesses index 2 (the model name string) instead of index 1 (the cost float).
Changes:
- Fixed cost extraction logic in sync_orchestration.py to use explicit index 1 for test/test_extend operations
- Updated both cost tracking (line 1752) and logging (line 1780) sections to handle test/test_extend correctly
- Added comprehensive unit and E2E tests to verify the fix and prevent regression
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| pdd/sync_orchestration.py | Fixed cost extraction at lines 1752-1755 and 1780-1782 to handle test/test_extend 4-tuples correctly by using result[1] instead of result[-2] |
| tests/test_e2e_issue_508_budget_test_cost.py | Added 5 unit tests verifying cost extraction logic for test, test_extend, and generate operations, plus budget enforcement |
| tests/test_e2e_issue_508_sync_budget_tracking.py | Added 2 E2E tests that exercise the real sync_orchestration function with mocked operations to verify budget tracking |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Fix generate test to use correct 4-tuple (content, was_incremental, cost, model) - Update E2E mock for code_generator_main to return 4-tuple - Improve comment accuracy for tuple format documentation Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Contributor
|
please fix the CI failures |
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.
Summary
sync_orchestration.py:1752result[-2]on a 4-tuple returns model name string instead of cost float, silently dropping test/test_extend costsRoot Cause
result[-2]on(content, cost, model, agentic_success)returnsresult[2](model), notresult[1](cost). Theisinstance(..., (int, float))check fails silently, defaulting to$0.00.Fixes #508