Trace token burn back to the loop script
When a session miner reports a task_type or prompt_type consuming tokens, the symptom (what the agent was doing) is not necessarily the cause (what kept re-spawning the agent).
Why: session JSONL contains cwd, workflow_id, and the first user prompt,
but the scheduler name is missing. An unbounded outer loop — a worker
intervalMs, a while true shell driver, a cron plan, or a plan task with no
iteration limit — can make a cheap plan become an expensive burn.
Pattern:
- Rank spend by task_type / prompt_type, then open one representative session file.
- Read its
cwdand first user prompt to map it to a plan or workflow. - Open that plan or worker file.
- Look for an unbounded loop:
intervalMswithout a max-tick or max-age boundwhile true,sleep, or a cron expression- a plan task that calls
submitPlanon every tick with no cooldown - a shell loop driver that re-enters the plan on failure
- Before adding a worker-level cooldown or a smarter prompt, confirm the scheduler is not already responsible for re-running the same plan.
- If the scheduler is unbounded, the root cause is the loop script / plan entry point, not the plan content.
Avoid stopping at the worker that submitted the plan. The worker may be correct on each tick; the bug is the loop that keeps ticking.