Skip to content

Cost tracking & budget limits for recursive task trees β€” how are you handling this?Β #6

@agentcostin

Description

@agentcostin

Hey Jian and the Fractals community πŸ‘‹

I've been digging into Fractals and think there's a real gap worth discussing: cost visibility and budget control for recursive task decomposition.

The problem is structurally unique to systems like Fractals. A single high-level task with maxDepth=4 can spawn dozens to hundreds of leaf tasks β€” each making its own OpenAI planning calls and Claude CLI / Codex CLI execution calls. Users have no idea what a task tree will cost until the API bill arrives. That's not a minor inconvenience; it's a blocker for teams that want to use Fractals on anything beyond personal experimentation.

A few specific scenarios where this bites:

  • Runaway decompositions β€” the LLM judges a task to need 40 subtasks instead of 5. No one catches it until post-execution.
  • No cost signal at the Review step β€” users inspect the plan tree before committing to execution, but currently there's no "this will cost approximately $X" estimate to inform that decision.
  • No per-branch attribution β€” if a maxDepth=3 tree costs $18, which branch consumed 80% of that? Was it planning or execution?

This is actually where a recent paper β€” AgentOS: From Application Silos to a Natural Language-Driven Data Ecosystem β€” is relevant. It argues that the "Agent Kernel" needs to treat token budget allocation as a first-class OS-level concern across concurrent agent threads. Fractals is one of the clearest real-world expressions of exactly that problem.

I've been building AgentCost β€” an open-source cost governance platform β€” that I think maps cleanly onto this. A few integration approaches, from lightest to deepest:

Level 1 β€” Gateway proxy (zero Fractals code changes):
Point Fractals' OPENAI_API_KEY at the AgentCost gateway instead of OpenAI directly. Every planning-phase call gets captured, attributed, and tracked automatically with no changes to the codebase.

Level 2 β€” Webhook after leaf execution:
A small addition to executor.ts β€” POST task metadata (task ID, depth, lineage, executor type) to an AgentCost endpoint after each leaf completes. AgentCost correlates this with LLM usage to produce a per-tree, per-branch cost breakdown.

Level 3 β€” Cost estimate at Review:
Before the user clicks Execute, call AgentCost's pre-call estimation API with the leaf count and task types. The Review UI shows "Estimated cost: $4.20 – $7.80" alongside the plan tree. Users can set a budget ceiling before committing.

I'd love to hear how people are currently handling this β€” or whether this is even a pain point for early Fractals users. Happy to build a Level 1 proof-of-concept and share a screenshot of the per-tree cost breakdown in AgentCost's dashboard if that would be useful.
β€” Vicky
AgentCost | agentcost.in | Demo

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions