The fan-out path used to report usage as if a single Codex call had run: `prompt_tokens = max(1, len(prompt)//4)` and `completion_tokens = len(synthesis)//4`. In reality it had spawned N parallel worker turns (each carrying the same prompt) plus a synthesis turn that re-sent the prompt and every tab's output. For `parallel_calls=20` that meant the cost / context widget under- reported the request by roughly 20x. Now sums: - `prompt_tokens ≈ (N * prompt + synthesis_prompt) / 4` where `synthesis_prompt = sum(tab_outputs) + prompt`. - `completion_tokens ≈ (sum(tab_output_chars) + synthesis_chars) / 4`. Tests: new regression `test_parallel_usage_accounts_for_all_calls` runs a 4-way fan-out against a fake SDK with deterministic chunk lengths and asserts the reported usage scales with N, not the single-call shape. |
||
|---|---|---|
| .. | ||
| assets | ||
| auth | ||
| core | ||
| loggers | ||
| models | ||
| plugins | ||
| requirements | ||
| routes | ||
| state | ||
| storage | ||
| tests | ||
| utils | ||
| __init__.py | ||
| _platform_compat.py | ||
| colab.py | ||
| main.py | ||
| run.py | ||
| startup_banner.py | ||