Skip to content

Distribute the parent's maxTotalChargeUsd across child runs #1139

Description

@B4nan

A pay-per-event orchestrator started with maxTotalChargeUsd has no help keeping its children inside that budget. Each child accepts its own max_total_charge_usd, but splitting the parent's remaining budget across children, adjusting as earlier children finish under their cap, is left to the caller. The orchestrator skill (apify/agent-skills#90) lists this as a must-have, which means agents are currently writing it themselves.

Depends on #1127: the remaining budget is the parent's limit minus what tracked children have charged so far, and only the registry knows the children after a restart.

Proposal

When the parent run has maxTotalChargeUsd and a named child is started without an explicit max_total_charge_usd, the SDK sets it to the parent's remaining budget (parent limit minus the sum of usage_total_usd / charged amounts of tracked children, minus the parent's own charge so far). An explicit max_total_charge_usd on the child is capped at the remaining budget rather than passed through.

A budget_per_child option could let the caller reserve headroom for later children, but the default above already guarantees the subtree never exceeds the parent's limit.

Longer term this is better enforced on the platform for a parent's whole subtree, but the SDK version works today.

✍️ Drafted by Claude Code

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request.t-toolingIssues with this label are in the ownership of the tooling team.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions