Skip to content

Spec 16: Cost & Budget

DWS Spec 16: Cost & Budget Model

Digital Worker Standard — DWS Specification

Version: 1.0 Tier: 4 — Governance Status: Release Candidate Dependencies: Spec 0 (Project Structure), Spec 6 (Workflow & Phases), Spec 11 (Events & Telemetry)


1. Overview

This specification defines how costs are tracked, budgets are enforced, and spending is governed across DWS workers. Cost management is a first-class governance concern: a worker that overspends is as much a governance failure as a worker that produces bad output.

DWS treats cost like any other constraint: it is declared at definition time, tracked at runtime, and enforced through the same event and escalation infrastructure as authority and verification.


2. Budget Declaration

2.1 Worker-Level Budget

The jobspec.json manifest includes a budget block (Spec 0, Section 2.1):

{
"budget": {
"cost_ceiling_per_run": { "amount": 10.00, "currency": "USD" },
"cost_ceiling_per_day": { "amount": 100.00, "currency": "USD" },
"cost_ceiling_per_month": { "amount": 2000.00, "currency": "USD" },
"alerts": [
{ "threshold_percent": 50, "action": "notify" },
{ "threshold_percent": 80, "action": "escalate" },
{ "threshold_percent": 100, "action": "pause" }
]
}
}

2.2 Workflow-Level Budget

Workflow global constraints (Spec 6, Section 2.3) include cost_ceiling and cost_tracking:

{
"global_constraints": {
"cost_ceiling": { "amount": 25.00, "currency": "USD" },
"cost_tracking": {
"enabled": true,
"worker_budgets": [
{ "role": "implementor", "budget": { "amount": 15.00, "currency": "USD" }, "alert_threshold": 0.8 },
{ "role": "verifier", "budget": { "amount": 5.00, "currency": "USD" }, "alert_threshold": 0.9 }
],
"attribution": "per_phase"
}
}
}

2.3 Budget Hierarchy

Budgets are enforced at multiple levels. The most restrictive ceiling applies:

  1. Run-level — The cost_ceiling on the workflow or cost_ceiling_per_run on the manifest.
  2. Worker-level — Per-worker budget allocations within a workflow.
  3. Daily aggregatecost_ceiling_per_day on the manifest.
  4. Monthly aggregatecost_ceiling_per_month on the manifest.

When any ceiling is reached, the configured alert action is taken.


3. Cost Attribution

3.1 Cost Components

ComponentDescriptionTracked By
Model inferenceToken input/output costs per model invocation.span.model_request_end events with model_usage.
Tool callsCosts associated with MCP tool invocations (API calls, compute).skill.tool_called / skill.tool_returned events.
VerificationCost of verification worker invocations.Separate from execution cost.
InfrastructureSession-hour fees, container costs (e.g., Managed Agents $0.08/hour).Runtime-specific tracking.
RetriesCost of re-execution after verification failure or guardrail rejection.Accumulated into phase cost.

3.2 Attribution Modes

The attribution field on workflow cost tracking determines how costs are bucketed:

ModeDescription
per_workerCosts attributed to the worker that incurred them.
per_phaseCosts attributed to the workflow phase.
per_intentCosts attributed to the intent being executed.
allAll attribution dimensions tracked simultaneously.

4. Cost Events

Event TypeWhen EmittedPayload
workflow.cost_threshold_reachedAlert threshold crossed.{ threshold, action, current_cost, ceiling, breakdown }
workflow.cost_ceiling_exceededHard ceiling breached.{ ceiling, actual_cost, overage }
span.model_request_endModel invocation completed.{ model_usage: { input_tokens, output_tokens, cost } }

4.1 Cost Breakdown

Cost events SHOULD include a breakdown by component:

{
"cost_breakdown": {
"model_inference": 3.50,
"tool_calls": 0.80,
"verification": 1.20,
"infrastructure": 0.40,
"retries": 0.60,
"total": 6.50,
"currency": "USD"
}
}

5. Budget Enforcement

5.1 Alert Actions

When a budget alert threshold is reached:

ActionBehaviour
notifyEmit a workflow.cost_threshold_reached event. Execution continues.
escalateTrigger the escalation protocol (Spec 7). A human decides whether to continue.
pauseHalt the workflow. Create an execution checkpoint (Spec 10). Resume requires human approval.

5.2 Hard Ceiling Enforcement

When the hard ceiling (cost_ceiling) is exceeded:

  1. The runtime MUST halt the current phase.
  2. The runtime MUST emit workflow.cost_ceiling_exceeded.
  3. The runtime MUST escalate to the worker’s escalation_target.
  4. The workflow enters a paused state until a human either increases the ceiling or aborts.

The runtime MUST NOT silently continue execution beyond a hard ceiling.

5.3 Verification Cost Separation

Verification costs are tracked separately from execution costs but count toward the global ceiling. This prevents verification retry loops from consuming the entire budget without visibility. The cost breakdown distinguishes verification as a separate line item.


6. SLA Cost Implications

When an intent has an SLA (Spec 4, Section 2.1), cost and time constraints may conflict. For example, a resolution_time SLA may require faster (more expensive) model invocations.

Runtimes SHOULD:

  • Prioritise SLA compliance over cost optimisation when both are configured.
  • Emit events when SLA compliance increases costs beyond projections.
  • Allow organisations to configure SLA-cost trade-off preferences.

7. Cost Reporting

7.1 Per-Run Report

At workflow completion, the runtime SHOULD produce a cost summary:

{
"cost_report": {
"workflow_id": "design-implement-verify",
"execution_id": "exec-001",
"total_cost": 6.50,
"currency": "USD",
"breakdown": {
"by_phase": {
"design": 1.20,
"implement": 3.80,
"verify": 1.50
},
"by_component": {
"model_inference": 3.50,
"tool_calls": 0.80,
"verification": 1.20,
"infrastructure": 0.40,
"retries": 0.60
},
"by_worker": {
"coordinator": 1.20,
"implementor": 3.80,
"verifier": 1.50
}
},
"budget_utilisation": 0.26,
"ceiling": 25.00
}
}

7.2 Aggregate Reporting

Runtimes SHOULD support aggregate cost queries across time periods, workers, workflows, and intents for fleet-level cost management.


8. References

  • Spec 0: Project Structure — Budget block in jobspec.json manifest.
  • Spec 4: Intent Artifacts — SLA fields on intents.
  • Spec 6: Workflow & Phases — Cost ceiling and cost tracking in global constraints.
  • Spec 7: Coordination Protocol — Escalation protocol for cost ceiling breaches.
  • Spec 8: Verification Framework — Verification cost tracked separately.
  • Spec 11: Events & Telemetry — Cost events in the event stream.