Examples
Examples
Two notebooks and two complete agents in the SDK repository. All of them measure on real traffic rather than asserting a number, and the agents also run a $0 test suite in CI.
Notebooks
git clone https://github.com/fluxcompute/fluxcompute-sdk.git cd fluxcompute-sdk pip install -e ".[dev]" pip install jupyter # not in the dev extra export ANTHROPIC_API_KEY=sk-ant-... jupyter notebook examples/quickstart.ipynb
Worked agents
Two complete programs, not snippets. Each keeps its own state in SQLite, records every call
and step in an execution graph, and ends with a scorecard of gates. They share one rule:
a model does one bounded job, and code decides everything with a consequence.
Only a provider key is needed. A FLUXCOMPUTE_KEY is optional and adds one line,
the dashboard link. The company in the fixtures is fictional.
git clone https://github.com/fluxcompute/fluxcompute-sdk.git cd fluxcompute-sdk pip install -e ".[examples]" export ANTHROPIC_API_KEY=sk-ant-... python examples/agents/company_brain/run.py python examples/agents/crm_inbox/run.py
Company brain
One versioned document assembled from a repository snapshot, an inbox and a brand file, with a
verbatim quote behind every fact and facts removed when their source stops asserting them. The
model turns a paragraph into typed facts; code decides what changed, which source wins, what to
remove and what to publish. The injected failure is a retired model id, and
resume() fixes it in the same graph.
| Run | LLM calls | Tiers | Cost | Outcome |
|---|---|---|---|---|
run.py | 17 | easy 17 | $0.0226 | 32 facts, 21 of 21 golden answers, 42 nodes recorded |
--version 2 | 10 | easy 10 | $0.0123 | 1 added, 3 updated, 3 removed, 1 rename carried |
--version 2 again | 0 | none | $0.0000 | 4 facts retired after their grace period |
--fail-at 2 | 1 + 1 retry | easy, then medium | $0.0048 retry | one failed call resumed in-process, 15 never reached, exit 1 |
--resume <task> | 15 | easy 15 | $0.0187 | 32 facts, 21 of 21, nothing extracted twice |
Recorded 2026-09-10 against SDK 0.3.1 on Python 3.10, with no
FLUXCOMPUTE_KEY. Reproduce with your own key:
python examples/agents/company_brain/run.py.
The third row is the point, and this is all it takes. Work is keyed on the content hash, so an unchanged run makes no model calls, and the marker of done work is a row rather than a cursor, so a run that failed halfway cannot report "0 changed" forever afterwards.
# diff: done work is an extraction row keyed on the content hash, not a cursor if (item.item_id, item.hash) in extracted: reused += 1 # third sync: 0 LLM calls, $0.0000 else: changed.append(item) with client.step("extract") as s: s.set_attribute("item", short_hash(item.item_id)) # a hash, never the text result = await call(client, rubric=rubric, user=clean) # On the injected failure: retry that call, in the same graph. A reply that was never # JSON leaves no failed llm_call node, and then there is nothing to resume. failed = [n for n in graph.failed_nodes() if n.node_type == "llm_call"] if failed: resp = await client.resume(task_id, node_id=failed[-1].node_id, instruction=instruction) # resumed: 3 facts, routed to claude-sonnet-4-6 (medium), $0.0048
What resume() cannot do is run your loop. Fifteen items were never reached, and
the process exits with the command that finishes the job from a new process. That run cost
$0.0187 for fifteen extractions and repeated neither the one that succeeded nor the
one that was resumed.
CRM inbox
Every inbound message becomes one classified, deduplicated CRM row per conversation, with a suggested next action. Headers and four deterministic rules decide what never reaches a model; priority is a pure function of the class and the account; the agent has no send path, so the worst a bad classification can do is put a row in the wrong column of a file a person reads.
| Run | LLM calls | Tiers | Cost | Outcome |
|---|---|---|---|---|
run.py, 17 messages | 14 | easy 12, medium 2 | $0.0207 | 16 rows, macro precision 1.00, phishing recall 1.00, 33 nodes |
--run 1 again | 0 | none | $0.0000 | 14 cached, 0 rows changed |
--run 2, 3 messages | 2 | easy 2 | $0.0023 | 2 inserted, 1 updated, 1 quarantined |
--forget <address> | 0 | none | $0.0000 | 1 message, 1 classification, 1 row erased; no client built |
Recorded 2026-09-10 against SDK 0.3.1 on Python 3.10, with no
FLUXCOMPUTE_KEY. Reproduce with your own key:
python examples/agents/crm_inbox/run.py.
Three messages never reached a model: an out-of-office and a newsletter were decided by their headers, and a phishing attempt by rules that never read its argument. The second row is checked on every run, not only when somebody remembers to re-run: the upsert is applied twice to the same inputs and the second pass has to change nothing, so idempotency is a gate rather than a hope.
rows = [build_row(db, key, by_domain) for key in touched] apply_rows(db, rows, task_id) # INSERT ... ON CONFLICT(thread_key) DO UPDATE after = snapshot(db) apply_rows(db, rows, task_id) # the same write again, on purpose repeat = snapshot(db) churn = [k for k in after if after[k] != repeat.get(k)] card.gate("re-run is a zero-row diff", not churn) # run 1 again: 0 inserted, 0 updated, 16 unchanged (second pass changed 0), 0 LLM calls
Development
If you're working on the SDK itself:
pip install -e ".[dev]"
ruff check fluxcompute/ examples/
pytest tests/ -v
We don't take external code contributions, but bug reports are genuinely useful. See CONTRIBUTING.md. Security issues go to security@fluxcompute.dev.
License
Apache-2.0. See LICENSE. Versions 0.1.0–0.2.1 were released under MIT and remain so.