Skip to content

fix: budget tracker drops test costs due to tuple index bug#518

Merged
gltanaka merged 2 commits intopromptdriven:mainfrom
Serhan-Asad:fix/issue-508-v3
Feb 16, 2026
Merged

fix: budget tracker drops test costs due to tuple index bug#518
gltanaka merged 2 commits intopromptdriven:mainfrom
Serhan-Asad:fix/issue-508-v3

Conversation

@Serhan-Asad
Copy link
Contributor

@Serhan-Asad Serhan-Asad commented Feb 13, 2026

Summary

  • 5 failing unit tests reproducing the tuple index bug at sync_orchestration.py:1752
  • 2 failing E2E tests verifying budget tracking at integration level
  • result[-2] on a 4-tuple returns model name string instead of cost float, silently dropping test/test_extend costs

Root Cause

result[-2] on (content, cost, model, agentic_success) returns result[2] (model), not result[1] (cost). The isinstance(..., (int, float)) check fails silently, defaulting to $0.00.

Fixes #508

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>
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@Serhan-Asad Serhan-Asad marked this pull request as draft February 13, 2026 20:55
- 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>
@Serhan-Asad Serhan-Asad marked this pull request as ready for review February 13, 2026 21:04
@gltanaka gltanaka marked this pull request as draft February 13, 2026 23:36
@gltanaka gltanaka marked this pull request as ready for review February 13, 2026 23:36
@gltanaka
Copy link
Contributor

please fix the CI failures

@gltanaka gltanaka marked this pull request as draft February 13, 2026 23:43
@Serhan-Asad Serhan-Asad marked this pull request as ready for review February 15, 2026 21:22
@Serhan-Asad Serhan-Asad marked this pull request as draft February 15, 2026 21:23
@Serhan-Asad Serhan-Asad marked this pull request as ready for review February 15, 2026 22:39
@gltanaka gltanaka merged commit 3f7d5e3 into promptdriven:main Feb 16, 2026
4 of 5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Budget tracker drops test/test_extend costs due to wrong tuple index

2 participants