| name | taskforge-cost |
| description | Displays a per-model cost summary. Use when the user says "/taskforge-cost", "cost", "how much did I spend", "token usage", "how much has this cost", or similar. v2 aggregates from telemetry.jsonl. |
Cost โ Cost Summary (v2)
Summarize costs by model and phase for the project execution, and project remaining costs.
Prerequisites
- A project with execution state must exist under
_workspace/projects/{projectId}/
- Project selection: Same as
/taskforge-execute โ auto-select if only one, ask if multiple
- All file paths below are relative to
_workspace/projects/{projectId}/
Data Sources (v2)
Primary: telemetry.jsonl โ one JSON object per line. Relevant events:
| Event | Fields used |
|---|
task_end | model, costUSD, tokens, wallMin, outcome, taskId |
sprint_complete | sprintId, totalCostUSD, guardrailEvents |
guardrail_triggered | taskId, type, value, limit |
plan_approved | milestoneId, estimatedCostUSD |
quick_task | costUSD, tokens, wallMin |
Fallback (if telemetry.jsonl is missing or empty): execution-state.json per-task cost fields.
PM calls (plan) and validation (validate) costs are tracked as separate telemetry events and bucketed into "Other" in the summary.
Estimating Remaining Cost
Project remaining task costs using per-model average rates from completed tasks:
Estimated remaining = ฮฃ (average costUSD per model ร remaining tasks per model)
Per-model average:
- Average costUSD of completed haiku tasks ร remaining haiku tasks
- Average costUSD of completed sonnet tasks ร remaining sonnet tasks
For models with no completed tasks yet, use default estimates:
- haiku: $0.002/task
- sonnet: $0.04/task
Note: code-writing (execution) tasks only use haiku or sonnet. Opus is reserved for judgment work โ planning, plan-edit, discover, retro, milestone QA, and harness orchestrators โ and is tracked separately under "Other".
Output Format
Template โ fill from telemetry/state. Do not copy literal labels.
๋น์ฉ ์์ฝ โ {projectName}
๋ชจ๋ธ๋ณ (์คํ):
haiku: {n} runs, ${cost} ({pct}%) | avg ${avg}/task
sonnet: {n} runs, ${cost} ({pct}%) | avg ${avg}/task
โโโโโโโโโโโโโโโโโโโโโโโโโ
Subtotal: {n} runs, ${cost}
๋จ๊ณ๋ณ:
{milestoneId} ({title}): ${cost} ({done}/{total} tasks) {statusLabel}
{milestoneId} ({title}): ${cost} ({done}/{total} tasks) {statusLabel}
{milestoneId} ({title}): ๋ฏธ์์
{milestoneId} ({title}): ๋ฏธ์์
๊ธฐํ (PM/๊ฒ์ฆ, opus):
๊ณํ (plan): ${cost}
๋ง์ผ์คํค QA: ${cost}
์คํ๋ฆฐํธ ๊ฒ์ฆ: ${cost} (์๋, sonnet)
โโโโโโโโโโโโโโโโโโโโโโโโโ
Subtotal: ${cost}
์ด ๋น์ฉ: ${cost}
๊ฐ๋๋ ์ผ ๋ฐ๋: {n}ํ (์ด๋ฒ ๋ง์ผ์คํค)
- {taskId}: {limitName} ์ด๊ณผ ({actualValue})
์์ ๋จ์ ๋น์ฉ:
haiku ร {n} = ~${cost}
sonnet ร {n} = ~${cost}
PM/๊ฒ์ฆ = ~${cost}
โโโโโโโโโโโโโโโโโโโโโโโโโ
๋จ์ ์์: ~${cost}
์ด ์์: ~$0.84
Aggregation Rules
- By model (execution): group all
task_end events by model, sum costUSD, count runs.
- By milestone: group
task_end events by the milestoneId derived from the task's taskId prefix (e.g. M1-S1-T3 โ M1). Cross-check with project-plan.json for total task counts.
- Other: aggregate non-execution events โ plan runs, validate runs, milestone QA. These can use opus.
- Guardrail summary: count
guardrail_triggered events for the current milestone. Show the top 3 offenders (taskId + trigger type).
When Data Is Unavailable
If neither telemetry.jsonl nor execution-state.json has cost data yet:
- "์์ง ์คํ ๋ด์ญ์ด ์์ด์ ๋น์ฉ ๋ฐ์ดํฐ๊ฐ ์์ด์. ํ์คํฌ๊ฐ ์คํ๋๋ฉด ์๋์ผ๋ก ๊ธฐ๋ก๋ฉ๋๋ค."
- Show the plan's
estimatedCostUSD (from plan_approved event) if available, as a rough upfront estimate.
Notes
telemetry.jsonl is the source of truth. Only fall back to execution-state.json when telemetry is missing.
- Opus usage in "Other" is expected and normal โ it's the PM model. An opus entry under "๋ชจ๋ธ๋ณ (์คํ)" would be a bug.
- Guardrail events do not directly add cost, but a high count usually correlates with higher-than-estimated cost for that milestone.