"""add_lever.py: your turn, add a fifth cost lever: the Batch API discount.

Anthropic's Message Batches API processes non-urgent requests asynchronously for about HALF the
price. It is perfect for work that does not need an instant answer (overnight evals, bulk
classification, backfills). Add it to the estimator and see what it saves on the easy, batchable steps.

Steps:
  1. Implement batch_estimate below: like optimize.estimate, but multiply the cost of any step you
     mark batchable by BATCH_MULT (0.5). Hint: copy the loop from ../solution/optimize.py.
  2. Mark the three easy steps batchable and compare to the "both" config.
  3. Run:  python add_lever.py

Worked levers (route, cache, trim) are in ../solution/optimize.py.
"""

import sys, os
sys.path.insert(0, os.path.join(os.path.dirname(__file__), "..", "solution"))
import optimize, pricing

BATCH_MULT = 0.5      # Batch API is about 50% of the synchronous price


def batch_estimate(steps=optimize.STEPS, batchable=("easy",)):
    """TODO: total cost where steps whose difficulty is in `batchable` get the BATCH_MULT discount.
    Reuse routing + caching from optimize.estimate's logic, then apply the discount per step."""
    raise NotImplementedError("apply BATCH_MULT to batchable steps and sum the cost")


if __name__ == "__main__":
    both = optimize.estimate(routing=True, caching=True)["cost"]
    print(f"both (route + cache):        ${both:.5f}/run")
    # print(f"+ batch the easy steps:      ${batch_estimate():.5f}/run")
    print("Goal: batching the easy steps should shave a bit more off the cheap end of the pipeline.")
    print("Remember: batching trades latency for cost, so only batch work that can wait.")
