# RLM Cost Report: {{tree_id}}

**Generated**: {{timestamp}}
**Status**: {{status_emoji}} {{status_text}}

---

## Summary

| Metric | Value |
|--------|-------|
| **Total Tokens** | {{total_tokens}} ({{input_tokens}} in + {{output_tokens}} out) |
| **Total Cost** | ${{total_cost_usd}} |
| **Sub-Calls** | {{total_sub_calls}} |
| **Max Depth** | {{max_depth}} |
| **Duration** | {{duration}} |
| **Budget Usage** | {{budget_usage_percent}}% |

---

## Budget Status

```
{{budget_bar}}
```

{{#budget_warnings}}
⚠️ **Warnings**:
{{#warnings}}
- {{.}}
{{/warnings}}
{{/budget_warnings}}

{{#budget_projection}}
📊 **Projection**: Based on current trajectory, final cost estimated at **${{projected_cost}}** ({{projected_percent}}% of budget)
{{/budget_projection}}

---

## Cost Breakdown by Depth

| Depth | Nodes | Tokens | Cost (USD) | % of Total |
|-------|-------|--------|------------|------------|
{{#depth_breakdown}}
| {{depth}} | {{node_count}} | {{tokens}} | ${{cost}} | {{percent}}% |
{{/depth_breakdown}}
| **Total** | **{{total_nodes}}** | **{{total_tokens}}** | **${{total_cost}}** | **100%** |

---

## Cost Breakdown by Model

| Model | Calls | Tokens | Cost (USD) | Avg Cost/Call |
|-------|-------|--------|------------|---------------|
{{#model_breakdown}}
| {{model}} | {{call_count}} | {{tokens}} | ${{cost}} | ${{avg_cost}} |
{{/model_breakdown}}
| **Total** | **{{total_calls}}** | **{{total_tokens}}** | **${{total_cost}}** | **${{avg_cost_per_call}}** |

---

## Percentile Analysis

Based on REF-089 (Zhang et al., 2026) recursive decomposition cost patterns:

| Metric | p25 | p50 | p75 | p95 |
|--------|-----|-----|-----|-----|
| **Cost per Sub-Call** | ${{p25_cost}} | ${{p50_cost}} | ${{p75_cost}} | ${{p95_cost}} |
| **Tokens per Sub-Call** | {{p25_tokens}} | {{p50_tokens}} | {{p75_tokens}} | {{p95_tokens}} |

### Comparison to Alternative Approaches

| Approach | Estimated Cost | Comparison |
|----------|----------------|------------|
| **Current (RLM)** | ${{total_cost_usd}} | — |
| **Base Model (no decomposition)** | ${{base_model_cost}} | {{base_model_comparison}} |
| **Summarization Approach** | ${{summarization_cost}} | {{summarization_comparison}} |

{{#cost_efficiency_note}}
💡 **Note**: {{cost_efficiency_note}}
{{/cost_efficiency_note}}

---

## Top 5 Most Expensive Nodes

| Node ID | Model | Tokens | Cost (USD) | Prompt Preview |
|---------|-------|--------|------------|----------------|
{{#top_expensive_nodes}}
| `{{node_id}}` | {{model}} | {{tokens}} | ${{cost}} | {{prompt_preview}} |
{{/top_expensive_nodes}}

---

## Recommendations

{{#recommendations}}
### {{category}}

{{#items}}
- **{{title}}**: {{description}}
  {{#metrics}}
  - _Expected Impact_: {{metric}}
  {{/metrics}}
{{/items}}

{{/recommendations}}

---

## Cost Breakdown Details

### Depth Distribution

{{#depth_chart}}
```
Depth {{depth}}: {{bar}} {{node_count}} nodes (${{cost}})
```
{{/depth_chart}}

### Model Usage Over Time

{{#model_timeline}}
- **{{timestamp}}**: {{model}} ({{tokens}} tokens, ${{cost}})
{{/model_timeline}}

---

## Configuration

| Parameter | Value |
|-----------|-------|
| Max Depth | {{config_max_depth}} |
| Max Sub-Calls | {{config_max_sub_calls}} |
| Default Sub-Model | {{config_default_sub_model}} |
| Budget Tokens | {{config_budget_tokens}} |
| Parallel Sub-Calls | {{config_parallel}} |

---

## References

- **Schema**: `@agentic/code/addons/rlm/schemas/rlm-cost.yaml`
- **Research**: REF-089 (Zhang et al., 2026) - Recursive Language Models
- **Documentation**: `@agentic/code/addons/rlm/docs/cost-analysis.md`

---

**Report ID**: `{{report_id}}`
**Tree ID**: `{{tree_id}}`
**Generated by**: AIWG RLM Addon v{{addon_version}}
