What a request costs: the tokens of each kind multiplied by that kind's price per million. Input, cache writes, cache reads and output are all priced separately, and output is the most expensive, five times input on current Claude models.
An agent's bill grows with the length of the session, not only the size of the task, since every turn carries everything before it. Starting a fresh session is a cost decision as well as a quality one.
Say it to your agent
“Run this with claude -p --output-format json and read total_cost_usd. Do that for three real tasks, then tell me the cost per task and which step used the most tokens.”