Skip to main content

agent-tco: Pareto-optimal configuration of agentic workflows.

Project description

agent-tco

agent-tco is a Python library for Pareto-optimal configuration of agentic workflows.


Features

  • Workflow simulator with six-class scenario taxonomy (i1–i6): happy path, retry-resolved, HITL success, HITL partial, compound recovery, aborted.
  • Grid search — evaluates all candidate configurations with Beta credible intervals on scenario probabilities.
  • Pareto frontier — identifies non-dominated configurations on the ACR vs. E[TCO] plane.
  • Critical step sensitivity analysis — Proposition 1: ∂ACR/∂q_k prioritizes which step to upgrade first.
  • Tier pricing utilities — built-in TIER_A, TIER_B, TIER_C constants covering frontier, mid-range, and lightweight models. Pass your own TierCost(tier_id, cost_per_1k_tokens) to use current pricing.
  • StepExecutor protocol — plug in real LLM calls or a Mock for testing, no SDK dependency.

Installation

pip install agent-tco

Built for Python 3.12 or above.


Quick Start

1. Define configurations and run the grid search

from agent_tco import (
    CostParams, GridSearch,
    step_config_from_tier, WorkflowConfig,
    TIER_A, TIER_B, TIER_C,
)

cost_params = CostParams(
    labor_rate=60.0,
    review_time_hours=0.25,
    manual_process_cost=50.0,
)

# j3: all Tier C
j3 = WorkflowConfig("j3", [
    step_config_from_tier(k, TIER_C, acr=0.78 if k == 2 else 0.92, hitl_prob=0.20 if k == 4 else 0.05)
    for k in range(1, 6)
])

# j9: Tier B at step 2 (the bottleneck), Tier C elsewhere
j9 = WorkflowConfig("j9", [
    step_config_from_tier(k, TIER_B if k == 2 else TIER_C,
                          acr=0.88 if k == 2 else 0.92,
                          hitl_prob=0.08 if k == 2 else (0.20 if k == 4 else 0.05))
    for k in range(1, 6)
])

gs = GridSearch(cost_params=cost_params, n_runs=300, seed=42)
results = gs.evaluate_all([j3, j9])
for r in results:
    print(f"{r.config.config_id}: ACR={r.acr:.2f}  E[TCO]=${r.expected_tco:.2f}  M=${r.executive_metric:.2f}")

2. Compute the Pareto frontier and identify the recommended configuration

from agent_tco import pareto_frontier, rank_by_executive_metric

frontier = pareto_frontier(results)
ranked = rank_by_executive_metric(frontier)
best = ranked[0]
print(f"Recommended: {best.config.config_id} — ${best.executive_metric:.2f} per autonomous outcome")

Interpreting the Executive Metric

The executive metric M = E[TCO] / ACR is the expected cost per autonomously delivered outcome. When M < C_manual (the cost of the manual process), the agent is economically viable at this configuration. If M > C_manual for every configuration on the Pareto frontier, no configuration is cost-effective and the business case does not hold.


Using a real LLM executor

The StepExecutor protocol accepts any callable (step, context) -> (completed, hitl_triggered):

from agent_tco import WorkflowSimulator, CostParams

def my_llm_executor(step, context):
    # call your LLM here
    completed = run_llm_step(step, context)
    hitl = should_escalate(step, context)
    return completed, hitl

sim = WorkflowSimulator(cost_params=cost_params, executor=my_llm_executor)
run = sim.simulate_run(j9)
print(run.scenario, run.total_cost)

In tests, replace my_llm_executor with Mock(return_value=(True, False)).


API Reference

See API.md.


License

MIT License. See LICENSE.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

agent_tco-0.0.1.tar.gz (7.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

agent_tco-0.0.1-py3-none-any.whl (10.8 kB view details)

Uploaded Python 3

File details

Details for the file agent_tco-0.0.1.tar.gz.

File metadata

  • Download URL: agent_tco-0.0.1.tar.gz
  • Upload date:
  • Size: 7.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.11

File hashes

Hashes for agent_tco-0.0.1.tar.gz
Algorithm Hash digest
SHA256 a2e7cfe589823d09ab569ba340b72230e5d15c1aa6d3a8293a8c95eb5aaee10f
MD5 4fddc873c3235bea5615e8c6f053ae38
BLAKE2b-256 8dbee344c4525dd2924568e7a3475599dcfac552d4a869938de64e0afcf4e949

See more details on using hashes here.

File details

Details for the file agent_tco-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: agent_tco-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 10.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.11

File hashes

Hashes for agent_tco-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 3b34a60883af8b0e901d224a483d690f0ffb1b58a70e8b336db9eceeb936d587
MD5 98cca215b92523fd64c16dd4ce9a7003
BLAKE2b-256 8cb7f28ca7d6bc004dcea74f200a8b78aaa8396cc038b4057d98f4c8bd6aa9d5

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page