Plan or API?
On a plan, the agent is covered by the fixed price within usage limits; on the API you pay every token. People who code with an agent all day usually save with a Max plan; CI automation fits the API better.
Where the cost comes from
Every step resends instructions, history and the files read so far. Without caching the bill would be several times higher, which is why short, focused sessions cost less.