@takk/noeticos - v1.0.0 - Apache-2.0

Tune the runtime while it runs.

Agent parameters are usually frozen at deploy time: one model, one temperature, one retry budget for every task the agent will ever see. NoeticOS is the JIT compiler for Massive Intelligence (IM) agents. It classifies every task, learns the optimal parameters per task class with confidence-bound bandits, promotes changes only through deterministic canary rollouts with automatic rollback, and records every decision with the numeric evidence behind it. Catch the optimum while it runs.

pnpm add @takk/noeticos
159tests passing
92.15%line coverage
0runtime deps
11.15 kBbrotli core
What it does

Five components, one invariant.

createNoeticOS() wires a classifier, per-class bandits, a canary rollout judge, an audit log, and pluggable state behind two calls: recommend() before the task, report() after it.

Task classifier

Sorts every task into one of 10 task kinds plus an unknown fallback (factual-qa, code-generation, extraction, summarization, and more) from keyword and shape signals: prompt length, tool count, caller metadata. A caller-asserted kind overrides the classifier entirely.

Parameters are learned per task class, not per agent average, and every recommendation reports the classification confidence and the exact signals that fired.

Parameter bandits

One discounted UCB1-tuned bandit per parameter dimension and task class, across six dimensions: model, temperature, topP, maxTurns, retryBudget, contextShare. A global exponential discount tick keeps the statistics tracking non-stationary workloads: idle arms lose effective count, so stale optima are re-challenged instead of frozen out.

The engine keeps adapting when the workload shifts, without a retraining step or an offline pipeline.

Canary rollout

Cohort assignment is deterministic: a seeded hash sends a fixed share of executions (10% by default) to the canary, which differs from the baseline in exactly one parameter. Promotion is statistically gated; rollback fires earlier by design, backed by a hard quality floor and a futility bound.

Any reward difference is attributable to the single parameter under test, so every verdict has one cause.

Decision audit

Every promotion, rollback, freeze, and release is appended to an immutable decision log: type, parameter, from and to values, human-readable reasoning, and the numeric evidence (means, confidence bounds, sample counts) that justified it.

When someone asks why the temperature changed on Tuesday, the answer is one decisions() call away, with the statistics attached.

State

Learned state serializes to a versioned snapshot of aggregate statistics only. memoryState and fileState ship in the box; any StateBackend with load and save plugs in. Persistence is best-effort by contract.

A failing backend never blocks recommendation traffic, and profiles survive restarts when you want them to.

One invariant

Exploration never touches baseline traffic. The canary cohort, 10% of executions by default, differs from the stable configuration in exactly one parameter at a time, and scenario S7 of the CI benchmark re-proves the contract on every run, zero violations allowed.

The riskiest thing the engine ever does is serve a small, audited share of traffic one value away from stable, and it can always show the evidence.

The safety invariant

Exploration never touches baseline traffic.

The invariant is stated in the type contract and enforced on every code path. The asymmetry is deliberate: a missed improvement costs less than a regression served to baseline traffic.

The engine never

Five prohibitions

  1. explore-on-baseline Baseline executions always receive the current stable values. Exploration lives exclusively inside the canary cohort.
  2. two-moving-parts A canary never differs from the baseline in more than one parameter. Attribution requires a single cause.
  3. premature-promotion No promotion below minSamplesPerArm (8) canary samples or below the configured confidence (0.95).
  4. audit-edits Decision entries are append-only: never edited, never deleted, monotonic sequence numbers.
  5. prompt-retention Prompts and tool arguments are never stored. Snapshots, decisions, and telemetry carry aggregate statistics only.
The engine always

Five obligations

  1. deterministic-cohorts A seeded hash assigns cohorts (canaryShare 0.1 by default), so assignment is reproducible run over run.
  2. gated-promotion Welch's t test under a Bonferroni look budget, plus the candidate's lower confidence bound clearing the baseline's upper bound.
  3. earlier-rollback An exact binomial test on failures, a Wilson score bound against the quality floor, and a futility bound at four times the sample budget.
  4. recorded-evidence Every decision carries the means, bounds, and sample counts that justified it.
  5. freeze-under-turbulence Credential rotation or behavioral drift signals pause experiments through freezeTuning until the world stabilizes.
Quickstart

Recommend, run, report.

1. Add the package

pnpm add @takk/noeticos
npm install @takk/noeticos
yarn add @takk/noeticos
bun add @takk/noeticos

2. Wrap each execution in the two-call loop

import { createNoeticOS } from '@takk/noeticos';

const runtime = createNoeticOS({
  objective: 'cost',
  qualityFloor: { minSuccessRate: 0.9 },
});

// Before the task: the full parameter set for this execution.
const rec = runtime.recommend({
  agentId: 'support-bot',
  prompt: 'Summarize this incident thread for the on-call engineer.',
});
// rec.parameters -> { temperature: 0.4, topP: 1, maxTurns: 32,
//                     retryBudget: 1, contextShare: 0.6 }
// rec.cohort -> 'baseline' or 'canary'; rec.reasoning explains every value.

// ... run the agent task with rec.parameters applied ...

// After the task: report what happened.
runtime.report({
  executionId: rec.executionId,
  latencyMs: 2310,
  costUsd: 0.0042,
  turns: 3,
  finishReason: 'stop',
});

3. Watch the decisions land

runtime.on((event) => {
  if (event.type === 'decision.recorded') {
    console.log(event.entry.reasoning, event.entry.evidence);
  }
});

const audit = runtime.decisions({ agentId: 'support-bot', limit: 20 });

recommend() is synchronous and allocation-light, safe on the hot path. Outcomes with unknown execution ids are ignored, so a crash between the two calls cannot corrupt learning.

Parameter grid

Six dimensions, discrete arms, learned per task class.

Omitted dimensions get the default arms below; the model dimension is tuned only when candidates are declared. Locked parameters never enter a canary, and constraints.baseline overrides any starting value.

Parameter Default arms What it controls
model declared ModelCandidate list (no default) Which model id serves the class. Tier hints (fast, balanced, frontier) inform reasoning strings, never rewards.
temperature 0, 0.2, 0.4, 0.7, 1.0 Sampling temperature.
topP 0.9, 1.0 Nucleus sampling mass.
maxTurns 8, 16, 32, 64 Ceiling on agent loop turns per execution.
retryBudget 0, 1, 3 Retries allowed per execution.
contextShare 0.4, 0.6, 0.8 Fraction of the context window the agent may fill before NoeticOS recommends trimming.
Objective presets

Say what good means; the reward follows.

Every outcome is scored into a composite reward from quality, cost, and latency terms, normalized against the running per-class statistics. Presets fix the weights; custom weights are normalized to sum to 1. Quality uses the explicit qualityScore when reported, otherwise it is derived from the finish reason, tool failures, and detected tool loops.

Preset Quality Cost Latency Use it when
balanced 0.5 0.25 0.25 Default. No single term dominates.
cost 0.35 0.5 0.15 Spend is the constraint. The quality floor still applies.
latency 0.35 0.15 0.5 Interactive agents where waiting is the real cost.
quality 0.7 0.15 0.15 Correctness-critical work; cost and latency are tiebreakers.
Deterministic demo

One command, a byte-identical transcript.

The CLI ships a synthetic workload that exercises the whole loop. One seed yields one byte-identical transcript; the excerpt below is real output, truncated in the middle. The same tuned-versus-static comparison runs as a 9-scenario benchmark gate in CI.

$ noeticos simulate --executions 2400 --seed 7
decision canary.started factual-qa temperature 0.4 -> 0
decision canary.started creative-writing temperature 0.4 -> 0
decision canary.started extraction temperature 0.4 -> 0
decision canary.promoted factual-qa temperature 0.4 -> 0
decision canary.started factual-qa topP 1 -> 0.9
decision canary.rolledback factual-qa topP 0.9 -> 1
(19 decision lines omitted)
--- summary ---
executions: 2400
decisions: 25 (2 promoted, 9 rolled back)
canary share observed: 0.115
per-kind promoted parameters:
factual-qa: temperature=0 topP=1 maxTurns=32 retryBudget=1 contextShare=0.6
creative-writing: temperature=0.4 topP=1 maxTurns=32 retryBudget=1 contextShare=0.6
extraction: temperature=0.4 topP=1 maxTurns=8 retryBudget=1 contextShare=0.6
counterfactual: identical workload and noise, static baseline versus tuned
static baseline: cost=$17.6000 quality=0.879
noeticos tuned: cost=$8.0000 quality=0.925
delta: cost -54.5% quality +5.3%

Same workload, same noise: 54.5% lower cost at 5.3% higher quality than the static baseline, on this synthetic workload. Run it yourself; the transcript will match byte for byte.

Surfaces

Seven surfaces, one engine.

Every entry point ships ESM and CJS with its own type declarations. Sizes are brotli over the published build, enforced by size-limit in CI.

11.15 kB brotli

@takk/noeticos

The core engine: createNoeticOS, classifier, bandits, rollout judge, decision log, objective presets, memory and file state. Zero runtime dependencies.

863 B brotli

@takk/noeticos/otel

OTel GenAI ingestion: taskFromSpan, outcomeFromSpan, and parametersFromSpan read GenAI semantic-convention spans structurally, importing no OpenTelemetry package. Prompt content is never extracted.

981 B brotli

@takk/noeticos/vercel

Packaged Vercel AI SDK middleware: noeticosMiddleware for wrapLanguageModel applies the recommended temperature and topP per call and reports usage, latency, and finish reason automatically.

595 B brotli

@takk/noeticos/integrations

Structural bridges into the family stack below: sibling signals freeze and release tuning, and learned models feed routing. The siblings are optional peers, never imported.

10.54 kB brotli

@takk/noeticos/web

Browser entry: the full engine minus the Node file backend, so bundles never reference node:fs.

10.54 kB brotli

@takk/noeticos/edge

Edge entry for Cloudflare Workers, Vercel Edge, Deno, and Bun. Deterministic seeded PRNG, no platform randomness, no Node-only APIs.

ships in the package

noeticos CLI

simulate runs the deterministic demo, inspect renders a state snapshot, version prints the package version, and serve starts a local HTTP bridge that exposes recommend/report to non-Node runtimes, Hermes Agent included: constant-time bearer-token auth, a non-loopback refusal without a token, JSON content-type enforcement, and gated CORS preflight.

0 dependencies

Statistics, from scratch

The numerical layer behind every surface is written from the literature: Welford moments, P2 quantile estimation, the exact one-sided binomial tail, the exact Student t tail via the regularized incomplete beta, Wilson intervals, and discounted UCB1-tuned bounds. Nothing to audit transitively.

6 event kinds

Telemetry stream

One on(listener) call streams the typed engine events: recommendations issued, outcomes recorded with their reward, every audit decision, loop detection, limit warnings, and tuning releases. A throwing listener never breaks the engine.

Family stack

Four packages, one runtime layer.

NoeticOS is the adaptive layer of the @takk family. Each sibling owns one concern, and the bridges keep every canary verdict attributable to exactly one cause: tuning freezes while credentials rotate or behavior drifts, and resumes when the world stabilizes.

@takk/keymesh

API key rotation, failover, and circuit breaking for provider credentials. The bridge freezes tuning while keys are in flux and releases it after a successful rotation.

davccavalcante/keymesh

@takk/modelchain

Model routing and fallback chains across providers. The read-side bridge exposes the model NoeticOS has learned per agent and task class to any routing strategy.

davccavalcante/modelchain

@takk/behavioralai

Behavioral observability for agents: learned fingerprints, drift detection, predictive alerts. Critical drift freezes tuning until the agent recovers, keeping both audit trails truthful.

davccavalcante/behavioralai
FAQ

Common questions.

What does NoeticOS actually do?

It tunes the runtime parameters of your agents while they run. Before each task, recommend() returns the full parameter set (model, temperature, topP, maxTurns, retryBudget, contextShare) learned for that agent and task class. After the task, report() feeds back what happened. The engine scores each outcome into a reward, updates per-class bandits, and converges on the values that maximize your objective.

Why call it the JIT compiler for agents?

A JIT compiler observes a running program and recompiles its hot paths with better optimizations, without stopping it. NoeticOS does the same for agent runtime parameters: it observes executions, identifies the hot task classes, and recompiles their parameter sets through canary experiments, while production traffic keeps flowing.

Is it safe to let a library tune production parameters?

That constraint shaped the whole design. NoeticOS never explores on baseline traffic: exploration is confined to a deterministic canary cohort, 10% of executions by default, and a canary differs from the baseline in exactly one parameter at a time. Promotion requires statistical confidence, rollback fires on much weaker evidence by design, and a hard quality floor rolls back any violating canary regardless of reward. Every change lands in an append-only audit log with the numbers that justified it.

Which statistics gate promotion and rollback?

Promotion uses Welch's t test on mean reward, with the alpha spread across a Bonferroni look budget, plus confidence-bound separation: the candidate's lower bound must clear the baseline's upper bound. Rollback uses an exact binomial test on failure counts, a Wilson score upper bound checked against the quality floor, and a futility bound that abandons a canary after four times the minimum sample budget without a verdict.

Does NoeticOS read or store my prompts?

No. The prompt is an optional classifier input and is never stored: snapshots, decisions, and telemetry carry aggregate statistics only. The OTel ingestion deliberately ignores span events, which can carry message bodies, and tool-call arguments enter only as caller-computed hashes.

How many runtime dependencies does it add?

Zero. The core is 11.15 kB brotli and uses nothing beyond the JavaScript standard library; the statistics (Welch, Wilson, exact binomial, P2 quantile estimators) are implemented inside the package. The family bridges are structural, so even the optional peer packages are never imported by the engine itself.

Does it run in browsers and edge runtimes?

Yes. The web and edge entry points (10.54 kB brotli each) expose the full engine minus the Node file backend, so bundles never reference node:fs. Cohort assignment uses a seeded deterministic PRNG, not platform randomness, so the same configuration behaves identically in Node, Cloudflare Workers, Vercel Edge, Deno, Bun, and the browser.

How does it integrate with the Vercel AI SDK and OpenTelemetry?

@takk/noeticos/vercel ships a packaged middleware for wrapLanguageModel: it applies the recommended temperature and topP per call and reports token usage, latency, and finish reason automatically, for generateText and streamText alike. @takk/noeticos/otel converts OTel GenAI semantic-convention spans into task descriptors and outcomes structurally, without importing any OpenTelemetry package; ingestion is live by design, and replaying exported traces warms the cost and latency quantile bands rather than performing historical credit assignment.

What evidence backs version 1.0.0?

159 tests across 12 files run on Node 22 and Node 24, with 92.15% line coverage. A 9-scenario tuning benchmark runs in CI, so a change that stops the engine from beating a static baseline fails the build. Bundle size budgets are enforced per entry point, and every release is published with SLSA provenance through GitHub Actions OIDC.

What is the policy on breaking changes?

Strict SemVer 2.0.0 from 1.0.0. Everything exported from the six entry points is the public API, the state snapshot schema is versioned (version 1 across the 1.x line), and new task kinds may be added in minor releases, so exhaustive switches over TaskKind should keep a default branch. Breaking changes require a major bump and a deprecation cycle.

Author

Built and maintained by David C Cavalcante.

David C Cavalcante

Founder, Takk Innovate Studio

Product Engineer, IM Engineer, ML Engineer, LLM Architect, Researcher. Builder of the @takk family of NPM packages for Massive Intelligence (IM) infrastructure.

NoeticOS is the fourth package in a planned portfolio of NPM libraries targeting infrastructure for Massive Intelligence (IM) agents through 2030: adaptive runtime intelligence here, with credential rotation, model routing, and behavioral observability in its siblings. Adjacent research by the author covers systemic intelligence frameworks (MAIC, HIM, NHE) published independently of this codebase, with research notes on PhilPapers and PhilArchive linked from the repository README.

If NoeticOS cut your token bill or caught a bad parameter before it reached baseline traffic, the most useful thing you can do is open a GitHub issue when you find an edge case the test suite missed. The release runbook, the threat model, and the contributor agreement all live in the repository.