Implement the estimation foundations for pre-flight command cost previews.
Concrete files to investigate and update:
pdd/server/token_counter.py
pdd/prompts/server/token_counter_python.prompt
pdd/track_cost.py
pdd/prompts/track_cost_python.prompt
.pdd/llm_model.csv
- existing token/cost tests under
tests/
Scope:
- Extend model pricing loading so
.pdd/llm_model.csv reads both input and output pricing.
- Add an output-inclusive cost estimate API such as
estimate_completion_cost(input_tokens, predicted_output_tokens, model, pricing_csv).
- Extend
CostEstimate to expose input, output, and total cost while preserving existing callers.
- Preserve unknown-pricing behavior: token counts/context can still be reported, but cost must be explicitly unknown.
- Extend cost logging in
pdd/track_cost.py so actual input_tokens and output_tokens can be recorded while preserving legacy CSV/header handling.
PDD Command Hint: change+sync
Acceptance criteria:
pdd/server/token_counter.py can compute deterministic input+output pricing from a fixture pricing CSV.
- Unknown models return token metrics without silently inventing a price.
pdd/track_cost.py remains backward-compatible with legacy cost CSVs and supports new token-count columns.
Split Contract
Command sequence: change → sync
Allowed write set:
pdd/server/token_counter.py
pdd/prompts/server/token_counter_python.prompt
pdd/track_cost.py
pdd/prompts/track_cost_python.prompt
tests/test_token_counter.py
tests/test_track_cost.py
Acceptance criteria:
- Token-counter tests cover input and output rates from a fixture
.pdd/llm_model.csv.
- Unknown model pricing reports unknown cost rather than a guessed dollar value.
- Cost logging accepts and preserves
input_tokens and output_tokens columns without breaking legacy CSV handling.
Independently mergeable: True
Scope rule: Do not expand beyond this contract or implement sibling sub-issue work. If the contract is insufficient, report the gap instead.
PDD Command Hint: This is a new feature. Use change → sync (modify prompts, then generate and validate code).
Parent: #1347
Parent issue: #1347
Implement the estimation foundations for pre-flight command cost previews.
Concrete files to investigate and update:
pdd/server/token_counter.pypdd/prompts/server/token_counter_python.promptpdd/track_cost.pypdd/prompts/track_cost_python.prompt.pdd/llm_model.csvtests/Scope:
.pdd/llm_model.csvreads both input and output pricing.estimate_completion_cost(input_tokens, predicted_output_tokens, model, pricing_csv).CostEstimateto expose input, output, and total cost while preserving existing callers.pdd/track_cost.pyso actualinput_tokensandoutput_tokenscan be recorded while preserving legacy CSV/header handling.PDD Command Hint: change+sync
Acceptance criteria:
pdd/server/token_counter.pycan compute deterministic input+output pricing from a fixture pricing CSV.pdd/track_cost.pyremains backward-compatible with legacy cost CSVs and supports new token-count columns.Split Contract
Command sequence: change → sync
Allowed write set:
pdd/server/token_counter.pypdd/prompts/server/token_counter_python.promptpdd/track_cost.pypdd/prompts/track_cost_python.prompttests/test_token_counter.pytests/test_track_cost.pyAcceptance criteria:
.pdd/llm_model.csv.input_tokensandoutput_tokenscolumns without breaking legacy CSV handling.Independently mergeable: True
Scope rule: Do not expand beyond this contract or implement sibling sub-issue work. If the contract is insufficient, report the gap instead.
PDD Command Hint: This is a new feature. Use
change → sync(modify prompts, then generate and validate code).Parent: #1347
Parent issue: #1347