The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.
Rust agent-orchestrationai-agentsai-assistantdesktopllmlocal-firstmcppersonal-aiprivacyrustsecond-braintauri
docs(embed): make fleet commands and memory comparisons reproducible
Steven Enamakeleb6d3d2baa5d
diff --git a/crates/openhuman-embed/examples/linux_fleet.rs b/crates/openhuman-embed/examples/linux_fleet.rsindex 664297fc4f..469259f649 100644--- a/crates/openhuman-embed/examples/linux_fleet.rs+++ b/crates/openhuman-embed/examples/linux_fleet.rs@@ -1,7 +1,9 @@//! Title: Linux agent fleet memory and latency//! Summary: Measure retained runtime-owned agents using loopback inference and two worker threads.//! Run: offline on Linux; use a fresh constrained cgroup for release measurements.+//! Profile: release//! Feature: default+//! Default features: disabled#![recursion_limit = "512"]diff --git a/docs/gitbooks/en/developing/embed/cookbook.md b/docs/gitbooks/en/developing/embed/cookbook.mdindex 3462bef8af..04b708f7de 100644--- a/docs/gitbooks/en/developing/embed/cookbook.md+++ b/docs/gitbooks/en/developing/embed/cookbook.md@@ -82,7 +82,7 @@ Measure retained runtime-owned agents using loopback inference and two worker th[Source](https://github.com/tinyhumansai/openhuman/blob/main/crates/openhuman-embed/examples/linux_fleet.rs) · offline on Linux; use a fresh constrained cgroup for release measurements.-Run: `cargo run -p openhuman-embed --example linux_fleet`+Run: `cargo run -p openhuman-embed --release --example linux_fleet --no-default-features`## Connect an actual MCP protocol stub over loopbackdiff --git a/docs/gitbooks/en/developing/performance.md b/docs/gitbooks/en/developing/performance.mdindex 0d4f8af81f..c407bd491c 100644--- a/docs/gitbooks/en/developing/performance.md+++ b/docs/gitbooks/en/developing/performance.md@@ -21,7 +21,7 @@ The original measurements below were made on Apple Silicon macOS with a `--relea| 100 | 1,866 | 356 | 3 | 123 | 820 || 500 | 1,770 | 1,393 | 3 | 211 | 3,220 |-500 agents fit in one process at roughly 1.77 MiB marginal cost each. Idle CPU stays flat as N grows, which matters because an agent that is not mid-turn should not spend cycles. Thread count grows by about 0.35 per agent. Watch that line before pushing past 500 in production.+500 agents fit in one process at 1,770 KiB (about 1.73 MiB) marginal cost each. Idle CPU stays flat as N grows, which matters because an agent that is not mid-turn should not spend cycles. Thread count grows by about 0.35 per agent. Watch that line before pushing past 500 in production.Thousands of agents on one box is a goal, not a measured result. The marginal cost settles across 50, 100 and 500 agents instead of rising, which makes the goal plausible.@@ -114,8 +114,8 @@ Other builds were running on the host, so these are shared-host measurements.Each run starts in a fresh cgroup with `memory.max = 2147483648` and`cpu.max = 200000 100000` (2 GiB and a two-CPU quota). Three fresh processes-were measured at each size; the table gives medians. RSS is sampled after every-agent completes one concurrent turn, with all agent handles retained. Marginal+were measured at each size with the default swap limit; the table gives medians.+RSS is sampled after every agent completes one concurrent turn, with all agent handles retained. MarginalRSS is `(RSS after turns - RSS after Runtime::build) / N`, without allocatortrimming. The cgroup peak includes the HTTP mock and the Python measurementwrapper. Mock request recording is disabled, so retained HTTP request history@@ -128,8 +128,9 @@ charged outside the new cgroup.| 100 | 437.38 MiB | 4.028 MiB | 417.89 MiB | 3,537 ms | 3,370 ms || 500 | 1,712.97 MiB | 3.355 MiB | 1,760.32 MiB | 20,784 ms | 19,450 ms |-The 500-agent median is within twice the earlier macOS/mock 1.77 MiB-figure (3.54 MiB); the 50- and 100-agent medians miss that target. The+The 500-agent median is within twice the earlier macOS/mock 1,770 KiB+figure (1.728515625 MiB per agent, doubled to 3.45703125 MiB, or about+3.46 MiB); the 50- and 100-agent medians miss that target. The500-agent runs ranged from 3.341 to 3.585 MiB per agent. These are differenthosts and harness entry points, so the table is a capacity measurement ratherthan a controlled comparison of the platforms. This run also incorporates the@@ -144,8 +145,10 @@ executable; the OS page cache was warm.A separate 500-agent run with **swap disabled** (`MemorySwapMax=0`) completedin 19,090 ms, with 3.541 MiB marginal RSS per agent and a-1,884.52 MiB cgroup peak. Its marginal RSS narrowly exceeds the 3.54 MiB-target. Every run recorded zero `max`, `oom`, and `oom_kill` memory events.+1,884.52 MiB cgroup peak. Its marginal RSS exceeds the approximately+3.46 MiB target. The integration ticket used a nominal 1.77 MiB baseline+and 3.54 MiB doubled target; this run also narrowly exceeds that nominal target.+Every run recorded zero `max`, `oom`, and `oom_kill` memory events.This does not establish capacity for real providers, tool subprocesses, MCPservers, or 1,000 simultaneously active turns. Measure those workloads beforesizing a production fleet.@@ -154,11 +157,19 @@ To reproduce from the OpenHuman repository root:```shcargo build -p openhuman-embed --locked --release --no-default-features --example linux_fleet+systemd-run --user --scope -p MemoryMax=2G -p CPUQuota=200% --quiet \+ python3 crates/openhuman-embed/examples/linux_fleet_cgroup.py 500+```++Use `50` or `100` for the other sizes and repeat each command in a fresh scope+three times to reproduce the main table medians. Leave swap at its default+limit for those runs. To reproduce the separate no-swap 500-agent run:++```shsystemd-run --user --scope -p MemoryMax=2G -p MemorySwapMax=0 -p CPUQuota=200% --quiet \python3 crates/openhuman-embed/examples/linux_fleet_cgroup.py 500```-Use `50` or `100` for the other sizes and repeat each command in a fresh scope.The JSON output records process RSS, bootstrap/turn timings, cgroup limits,peak memory, and OOM counters. The raw runs are checked in as[`docs/benchmarks/medulla-embed-linux.json`](../../../benchmarks/medulla-embed-linux.json).diff --git a/gitbooks/developing/embed/cookbook.md b/gitbooks/developing/embed/cookbook.mdindex 3462bef8af..04b708f7de 100644--- a/gitbooks/developing/embed/cookbook.md+++ b/gitbooks/developing/embed/cookbook.md@@ -82,7 +82,7 @@ Measure retained runtime-owned agents using loopback inference and two worker th[Source](https://github.com/tinyhumansai/openhuman/blob/main/crates/openhuman-embed/examples/linux_fleet.rs) · offline on Linux; use a fresh constrained cgroup for release measurements.-Run: `cargo run -p openhuman-embed --example linux_fleet`+Run: `cargo run -p openhuman-embed --release --example linux_fleet --no-default-features`## Connect an actual MCP protocol stub over loopbackdiff --git a/gitbooks/developing/performance.md b/gitbooks/developing/performance.mdindex 1303d625f9..ec69bea4ae 100644--- a/gitbooks/developing/performance.md+++ b/gitbooks/developing/performance.md@@ -21,7 +21,7 @@ The original measurements below were made on Apple Silicon macOS with a `--relea| 100 | 1,866 | 356 | 3 | 123 | 820 || 500 | 1,770 | 1,393 | 3 | 211 | 3,220 |-500 agents fit in one process at roughly 1.77 MiB marginal cost each. Idle CPU stays flat as N grows, which matters because an agent that is not mid-turn should not spend cycles. Thread count grows by about 0.35 per agent. Watch that line before pushing past 500 in production.+500 agents fit in one process at 1,770 KiB (about 1.73 MiB) marginal cost each. Idle CPU stays flat as N grows, which matters because an agent that is not mid-turn should not spend cycles. Thread count grows by about 0.35 per agent. Watch that line before pushing past 500 in production.Thousands of agents on one box is a goal, not a measured result. The marginal cost settles across 50, 100 and 500 agents instead of rising, which makes the goal plausible.@@ -114,8 +114,8 @@ Other builds were running on the host, so these are shared-host measurements.Each run starts in a fresh cgroup with `memory.max = 2147483648` and`cpu.max = 200000 100000` (2 GiB and a two-CPU quota). Three fresh processes-were measured at each size; the table gives medians. RSS is sampled after every-agent completes one concurrent turn, with all agent handles retained. Marginal+were measured at each size with the default swap limit; the table gives medians.+RSS is sampled after every agent completes one concurrent turn, with all agent handles retained. MarginalRSS is `(RSS after turns - RSS after Runtime::build) / N`, without allocatortrimming. The cgroup peak includes the HTTP mock and the Python measurementwrapper. Mock request recording is disabled, so retained HTTP request history@@ -128,8 +128,9 @@ charged outside the new cgroup.| 100 | 437.38 MiB | 4.028 MiB | 417.89 MiB | 3,537 ms | 3,370 ms || 500 | 1,712.97 MiB | 3.355 MiB | 1,760.32 MiB | 20,784 ms | 19,450 ms |-The 500-agent median is within twice the earlier macOS/mock 1.77 MiB-figure (3.54 MiB); the 50- and 100-agent medians miss that target. The+The 500-agent median is within twice the earlier macOS/mock 1,770 KiB+figure (1.728515625 MiB per agent, doubled to 3.45703125 MiB, or about+3.46 MiB); the 50- and 100-agent medians miss that target. The500-agent runs ranged from 3.341 to 3.585 MiB per agent. These are differenthosts and harness entry points, so the table is a capacity measurement ratherthan a controlled comparison of the platforms. This run also incorporates the@@ -144,8 +145,10 @@ executable; the OS page cache was warm.A separate 500-agent run with **swap disabled** (`MemorySwapMax=0`) completedin 19,090 ms, with 3.541 MiB marginal RSS per agent and a-1,884.52 MiB cgroup peak. Its marginal RSS narrowly exceeds the 3.54 MiB-target. Every run recorded zero `max`, `oom`, and `oom_kill` memory events.+1,884.52 MiB cgroup peak. Its marginal RSS exceeds the approximately+3.46 MiB target. The integration ticket used a nominal 1.77 MiB baseline+and 3.54 MiB doubled target; this run also narrowly exceeds that nominal target.+Every run recorded zero `max`, `oom`, and `oom_kill` memory events.This does not establish capacity for real providers, tool subprocesses, MCPservers, or 1,000 simultaneously active turns. Measure those workloads beforesizing a production fleet.@@ -154,11 +157,19 @@ To reproduce from the OpenHuman repository root:```shcargo build -p openhuman-embed --locked --release --no-default-features --example linux_fleet+systemd-run --user --scope -p MemoryMax=2G -p CPUQuota=200% --quiet \+ python3 crates/openhuman-embed/examples/linux_fleet_cgroup.py 500+```++Use `50` or `100` for the other sizes and repeat each command in a fresh scope+three times to reproduce the main table medians. Leave swap at its default+limit for those runs. To reproduce the separate no-swap 500-agent run:++```shsystemd-run --user --scope -p MemoryMax=2G -p MemorySwapMax=0 -p CPUQuota=200% --quiet \python3 crates/openhuman-embed/examples/linux_fleet_cgroup.py 500```-Use `50` or `100` for the other sizes and repeat each command in a fresh scope.The JSON output records process RSS, bootstrap/turn timings, cgroup limits,peak memory, and OOM counters. The raw runs are checked in as[`docs/benchmarks/medulla-embed-linux.json`](../../docs/benchmarks/medulla-embed-linux.json).diff --git a/llms-full.txt b/llms-full.txtindex 760b0e639c..03a61a1492 100644--- a/llms-full.txt+++ b/llms-full.txt@@ -2614,7 +2614,7 @@ Measure retained runtime-owned agents using loopback inference and two worker th[Source](https://github.com/tinyhumansai/openhuman/blob/main/crates/openhuman-embed/examples/linux_fleet.rs) · offline on Linux; use a fresh constrained cgroup for release measurements.-Run: `cargo run -p openhuman-embed --example linux_fleet`+Run: `cargo run -p openhuman-embed --release --example linux_fleet --no-default-features`## Connect an actual MCP protocol stub over loopbackdiff --git a/scripts/__tests__/generate-embed-docs.test.mjs b/scripts/__tests__/generate-embed-docs.test.mjsindex abf8a3df7a..52e45e7d00 100644--- a/scripts/__tests__/generate-embed-docs.test.mjs+++ b/scripts/__tests__/generate-embed-docs.test.mjs@@ -36,6 +36,25 @@ test('cookbook metadata must come from example headers', () => {assert.deepEqual(exampleMetadata(example, 'hello'), { name: 'hello', title: 'Hello', summary: 'Builds an offline agent.', run: 'offline', feature: undefined });assert.throws(() => exampleMetadata('fn main() {}', 'bad'), /headers/);});+test('cookbook benchmark commands use the declared release profile without default features', () => {+ const root = mkdtempSync(resolve(tmpdir(), 'embed-benchmark-docs-'));+ try {+ mkdirSync(resolve(root, 'gitbooks/developing/embed'), { recursive: true });+ mkdirSync(resolve(root, 'crates/openhuman-embed/examples'), { recursive: true });+ mkdirSync(resolve(root, 'crates/openhuman-embed/src'), { recursive: true });+ writeFileSync(resolve(root, 'gitbooks/developing/embed/index.md'), '# Benchmarks\n');+ writeFileSync(resolve(root, 'crates/openhuman-embed/src/lib.rs'), 'pub use runtime::Runtime;');+ writeFileSync(resolve(root, 'crates/openhuman-embed/examples/retained_fleet.rs'), example + '//! Profile: release\n//! Feature: default\n//! Default features: disabled\n');+ writeFileSync(resolve(root, 'crates/openhuman-embed/examples/hello.rs'), example);+ const capabilities = resolve(root, 'capabilities.json');+ writeFileSync(capabilities, '{"schema_version":1,"compiled_features":{}}');+ generateEmbedDocs({ root, capabilities });+ const cookbook = readFileSync(resolve(root, 'gitbooks/developing/embed/cookbook.md'), 'utf8');+ assert.match(cookbook, /Run: `cargo run -p openhuman-embed --release --example retained_fleet --no-default-features`/);+ assert.match(cookbook, /Run: `cargo run -p openhuman-embed --example hello`/);+ assert.doesNotMatch(cookbook, /--features none/);+ } finally { rmSync(root, { recursive: true, force: true }); }+});test('generate then check is stable, edited source fails check, no prose authored by tooling', () => {const root = mkdtempSync(resolve(tmpdir(), 'embed-docs-'));try {diff --git a/scripts/generate-embed-docs.mjs b/scripts/generate-embed-docs.mjsindex 2b5ee93340..78949a2999 100644--- a/scripts/generate-embed-docs.mjs+++ b/scripts/generate-embed-docs.mjs@@ -106,7 +106,14 @@ export function exampleMetadata(source, name) {const summary = field('Summary');if (!title || !summary) throw new Error(`Example ${name} needs //! Title: and //! Summary: headers`);const feature = field('Feature');- return { name, title, summary, run: field('Run') ?? 'offline', feature: feature === 'default' ? undefined : feature };+ const profile = field('Profile');+ if (profile && !['dev', 'release'].includes(profile)) throw new Error(`Example ${name} has unsupported Profile: ${profile}`);+ return {+ name, title, summary, run: field('Run') ?? 'offline',+ feature: feature === 'default' ? undefined : feature,+ ...(profile ? { profile } : {}),+ ...(field('Default features') === 'disabled' ? { noDefaultFeatures: true } : {}),+ };}/** Public facade exports, suitable for rustdoc search links (including aliases). */@@ -197,7 +204,7 @@ export function generateEmbedDocs({ root = ROOT, check = false, capabilities } =desired.set(path, updated);}const examples = readdirSync(resolve(root, 'crates/openhuman-embed/examples')).filter(name => name.endsWith('.rs')).sort().map(file => exampleMetadata(readFileSync(resolve(root, 'crates/openhuman-embed/examples', file), 'utf8'), file.slice(0, -3)));- desired.set(resolve(directory, 'cookbook.md'), '# Cookbook\n\n<!-- Generated by scripts/generate-embed-docs.mjs; do not edit. -->\n\nExecutable recipes are indexed from their source headers. Each entry records the declared run mode and any named Embed feature required by the example. Full source includes the surrounding setup and assertions.\n\n' + examples.map(example => `## ${example.title}\n\n${example.summary}\n\n[Source](https://github.com/tinyhumansai/openhuman/blob/main/crates/openhuman-embed/examples/${example.name}.rs) · ${example.run}${example.feature ? ` · feature: ${example.feature}` : ''}\n\nRun: \`cargo run -p openhuman-embed --example ${example.name}${example.feature ? ` --features ${example.feature}` : ''}\`\n`).join('\n'));+ desired.set(resolve(directory, 'cookbook.md'), '# Cookbook\n\n<!-- Generated by scripts/generate-embed-docs.mjs; do not edit. -->\n\nExecutable recipes are indexed from their source headers. Each entry records the declared run mode and any named Embed feature required by the example. Full source includes the surrounding setup and assertions.\n\n' + examples.map(example => `## ${example.title}\n\n${example.summary}\n\n[Source](https://github.com/tinyhumansai/openhuman/blob/main/crates/openhuman-embed/examples/${example.name}.rs) · ${example.run}${example.feature ? ` · feature: ${example.feature}` : ''}\n\nRun: \`cargo run -p openhuman-embed${example.profile === 'release' ? ' --release' : ''} --example ${example.name}${example.noDefaultFeatures ? ' --no-default-features' : ''}${example.feature ? ` --features ${example.feature}` : ''}\`\n`).join('\n'));const report = capabilities ? JSON.parse(readFileSync(capabilities, 'utf8')) : JSON.parse(execFileSync('bash', ['scripts/ci-cancel-aware.sh', 'cargo', 'run', '--quiet', '-p', 'openhuman-embed', '--example', 'capability_report', '--', '--json'], { cwd: root, encoding: 'utf8', stdio: ['ignore', 'pipe', 'inherit'] }));const exports = exportedNames(readFileSync(resolve(root, 'crates/openhuman-embed/src/lib.rs'), 'utf8'));if (!report || typeof report !== 'object' || !Number.isInteger(report.schema_version) || !report.compiled_features || typeof report.compiled_features !== 'object') throw new Error('Capability report must be versioned RuntimeInfo JSON');