This example places AutoHelix around a separate LLM workflow. The inner workflow reads an order-support request, selects policy context, asks a model for a structured decision, validates it, and executes it in a deterministic simulator.
The support task is deliberately small. It illustrates a broader pattern:
- run an LLM system on a frozen workload;
- capture quality metrics and per-case execution traces;
- let AutoHelix edit the workflow's tunable surfaces; and
- evaluate each revision on the same workload.
The optimization surface is intentionally compact:
workflow.py- context selection, prompt assembly, validation, and retries;prompt.md- the task prompt; andSKILL.md- reusable instructions supplied to the inner model.
Here, prompt.md and SKILL.md belong to the inner workflow. The outer
optimization agent still receives AutoHelix's built-in prompt.
benchmark.py freezes the workload, policies, simulator, provider adapter, and
evaluator. The baseline router deliberately omits a broadly applicable policy,
leaving a general improvement for AutoHelix to discover from failed-case
traces. workflow.py remains editable because real workflow optimization often
needs more than prompt changes.
python examples/setup_example.py workflow-optimization --dir ./workflow-run
cd ./workflow-run
python benchmark.py --mock
autohelix run -n 2The mock command is a free smoke test. A real evaluation contains six inner
model calls. The two-iteration run above evaluates the baseline and two
candidates, for at least 18 calls total. The benchmark records each call's cost
in $AUTOHELIX_USAGE_FILE, so the run's cost totals and --cost include them
(see Cost Tracking).
By default, the inner workflow invokes the user's configured Claude CLI model as a one-shot completion with tools and session persistence disabled. The CLI is only the model transport; it cannot use tools to inspect or modify the project. The outer AutoHelix agent is configured independently.
To request a specific model from Claude CLI:
export WORKFLOW_MODEL_NAME=sonnetManaged CLI settings may resolve an alias to a different model. The detailed report records the actual model reported by Claude when that information is available.
AutoHelix tracks task_success_rate and average model tokens per case. Tokens
are a more reproducible efficiency signal than provider-reported dollars,
which can change with prompt-cache state. results/report.json also retains
validity, unsafe actions, model calls, provider-reported cost, actual model
names, latency, and the complete execution trace for every case.
The included cases are an inspectable teaching workload, not a secure holdout. For a real system, optimize on a development workload and evaluate the selected workflow once on cases the outer agent could not inspect.
Set WORKFLOW_MODEL_COMMAND to any command that reads a prompt from stdin and
writes only the completion text to stdout:
export WORKFLOW_MODEL_COMMAND="/path/to/my-model-wrapper"That wrapper can call Bedrock, a hosted API, or a local model. Keeping this
adapter command-based avoids requiring one cloud account or SDK for the
example. Custom commands do not report model identity, token counts, or cost
unless the adapter in benchmark.py is extended, so the run's cost totals
leave their calls out.