You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Runnable, single-file demos of what this library does: build agents, run several of them under one
budget, score them against a real check, and let them improve from their own runs. Every example
imports from the published package (@tangle-network/agent-runtime) exactly as your code would, and
most run offline with no API key so you can see the machinery before spending anything.
New here? Run these three, in order (the first two cost $0):
pnpm tsx examples/driver-loop/driver-loop.ts # 1. one agent steering another — offline
pnpm tsx examples/improve/improve.ts # 2. an agent that rewrites its own prompt, safely — offline
TANGLE_API_KEY=... pnpm tsx examples/supervise/supervise.ts # 3. one function call = a supervisor over real workers
driver-loop is the core move everything else builds on; improve is the self-improvement primitive;
supervise is the one-call product entry point.
A few words that appear everywhere
worker — an agent that produces an answer.
driver (or supervisor) — an agent that launches workers, reads their output, and decides
what to do next.
the fold — the key trick: a driver reads the last worker's output and writes the next
instruction from it, so the loop actually reacts instead of retrying blind.
shot — one worker attempt. sample = make N attempts and keep the best (breadth). refine
= attempt, let a critic read what went wrong, steer the next attempt (depth).
check — a function that scores an answer pass/fail. It is the ground truth every loop optimizes
against.
Compare ways of spending a compute budget (sample vs refine vs your own) against your own pass/fail check. Offline via an in-process fake model; TANGLE_API_KEY swaps in the real one.
delegate(intent): the supervisor writes and spawns a worker that does real work on disk, and the run only settles once the file it was asked to create actually exists. Needs TANGLE_API_KEY.
Benchmarking — score agents against a check
A round-based runner: plan tasks, run each in its own sandbox, parse and validate the output, decide,
repeat. A failing validator prunes a bad candidate so the loop can't keep it.
A research agent whose validator hard-fails if one tenant's data leaks into another's namespace, so the leak is pruned automatically. Needs the optional @tangle-network/agent-knowledge peer installed.
Rank coding agents (Claude Code, opencode, Codex, a bare CLI) on real tasks with an anti-cheat: each agent is graded on hidden tests it never saw, so it can't hardcode the answer. Includes a secondary quality judge and real significance stats. Offline by default; --live uses real agent boxes.
The real WebCode benchmark (Exa's 33-task dataset, graded by its own hidden tests) across a harness × model grid, rendered as a publishable leaderboard with charts, confidence bands, and pairwise significance.
Pick where an agent's streaming output comes from (in-process iterator, cloud sandbox, or an OpenAI-compatible endpoint) behind one wire format. The OpenAI path needs OPENAI_API_KEY; the rest is offline.
Give any agent a "delegate this" button by mounting the agent-runtime MCP server: a delegate verb plus always-on status/history/feedback tools. Run pnpm build first so the local server binary exists.
Full policy search with a safety gate: write new tactics from past losses, promote a champion only if a statistical test says the win isn't luck. Needs TANGLE_API_KEY.
The one self-improvement verb: improve(profile, findings) rewrites a prompt and ships the new version only if it beats the old one on a held-out test set. Offline.
The flywheel on a contamination-proof coding task: an agent writes strategies from its training losses, graded by real pytest, promoted only if a fresh holdout confirms the gain. CALIBRATE=1 is a $0 no-key check.
The full observability SDK (billing boundary, effort tiers, per-tool cost breakdown, OTLP export) instrumented over every cell of the WebCode benchmark. Needs a sandbox key.
The head-to-head behind the "supervisor beats raw compute by +20.8 points" result: three coordination styles compared cost-for-cost with a paired-bootstrap delta. Needs TANGLE_API_KEY; run ARMS=cal first (its README explains why).
Conventions
Everything runs from this repo's tsx, so edits to the runtime are picked up immediately — no
example creates its own throwaway package.json.
Examples are synthetic and offline unless a row above says otherwise. The ones that need a key:
supervise, delegate, strategy-evolution, product-eval (TANGLE_API_KEY); stream-backends'
OpenAI path (OPENAI_API_KEY). mcp-delegation needs pnpm build first; researcher-loop needs
the optional @tangle-network/agent-knowledge peer.
Where a domain type is yours to provide (a sandbox box, an evidence store), the example defines a
stub inline and comments mark which parts are yours vs the runtime's.
Every loop emits loop.* trace events. Set OTEL_EXPORTER_OTLP_ENDPOINT and they export as standard
OpenTelemetry GenAI spans — the same open format any observability backend reads. Example #21
(agents-of-all-shapes) shows the traces-to-insights pipe end to end.