Generated banner for Tao Token Efficient Execution
Generated logo for Tao Token Efficient Execution

Tao Token Efficient Execution

NVIDIAOfficialCreated by NVIDIA Corporation

  • Skill
  • Workflow
  • Agent tooling
  • Apache-2.0
  • Medium risk
  • Has scripts

From the author

Token-efficient execution kit for repeated TAO agentic workflows. Compiles a skill into stage cards once (with a strong model), then executes them forever in fresh, small headless sessions coordinated by a bash driver — measured 67-91% token reduction and 3-5x lower peak context vs one long conversation. Use when a TAO workflow will be run repeatedly, when token cost matters, when the target model has a small context window, or on trigger phrases like "token efficient", "reduce token cost", "card pack", "stage cards", "run this workflow on a small model", "compile this skill into cards".
— the description by NVIDIA Corporation

AutoGineer summary

Written by AutoGineer from the skill’s own files, not by the author

The TAO Token-Efficient Execution kit optimizes agentic workflows by replacing long, context-heavy conversations with a series of fresh, stateless headless sessions. By compiling a skill into discrete 'stage cards' using a strong model, the system enables smaller, more cost-effective models to execute complex tasks reliably. State is maintained on disk rather than in chat history, significantly reducing token consumption and context window pressure. The kit includes a bash-based driver for orchestration, harness adapters for tool interception, and a structured contract for state management.

What it does

  • Compiles complex agentic workflows into a series of discrete, stateless stage cards.
  • Executes workflows using fresh agent sessions to minimize context window usage.
  • Maintains persistent state on disk through a defined contract, avoiding reliance on chat history.
  • Uses a bash driver to manage stage routing, job waiting, and error handling.
  • Provides harness adapters to record executed commands and guard against known failure modes.
  • Enables the use of smaller, more efficient models for executing pre-compiled workflows.

When to use it

  • When a specific agentic workflow needs to be run repeatedly.
  • When reducing token costs and context window usage is a priority.
  • When the target model has a limited context window.
  • When you need to ensure deterministic execution of a multi-stage process.
  • When you want to avoid the performance degradation associated with long, single-session conversations.

Advantages

  • Significant reduction in token consumption (measured 67-91% reduction).
  • Lower peak context requirements (3-5x reduction).
  • Improved reliability by using pre-compiled, verified stage cards.
  • Stateless execution prevents model drift and context-related errors.
  • Clear separation between the one-time compilation cost and the efficient execution phase.

Usage examples

“Compile this skill into cards for token-efficient execution.”
The agent reads the skill and workspace, then generates a set of stage cards and a driver configuration to enable stateless, low-token execution.
“Run this workflow on a small model using the card pack.”
The bash driver initiates the workflow, executing one stage card per session and managing state via on-disk contracts.

Install

  1. Download the skill as a ZIP:

    https://mp-staging.autogineer.com/agent-skills/nvidia/tao-token-efficient-execution/download
  2. Unzip it into the cross-client skills folder of your project:

    mkdir -p .agents/skills && unzip tao-token-efficient-execution.zip -d .agents/skills

Documentation by NVIDIA Corporation

TAO Token-Efficient Execution

Run a staged TAO workflow as a series of fresh headless agent sessions — one stage card per session — instead of one long conversation. State lives on disk, never in chat history, so no session ever rereads the run's past.

Measured on real workflows (same tasks, same outcomes, billed tokens):

WorkflowOne long conversationCard executionPeak context
DEFT AOI loop9.6M2.5M (-74%)242k → 59k
AutoML (VCN classify)5.8M0.5M (-91%)198k → 42k
HuggingFace finetune1.7M0.5M (-67%)119k → 42k

The mechanism: an agent API is stateless, so a long conversation resends its entire history with every message — by mid-run that is ~100k+ tokens of skill text, spec edits, and training logs reread on every tool call, of which the current step needs ~3k. Cards make each step's 3k explicit and drop the rest.

The three layers

  1. Core (harness-agnostic) — stage cards (markdown, env-var contract), a bash driver (stage routing + job waiting), and on-disk state contracts (references/CONTRACTS.md).

  2. Harness adapters (adapters/) — guard + recorder implemented per harness: hooks for Claude Code, extensions for Pi. Same logic, ~150 lines each. Guards block known dead ends before tokens are burned; the recorder appends executed commands to commands.log so later sessions reuse instead of re-derive.

  3. Card packs (per application skill) — compiled cards living next to the skill they were authored from, e.g. skills/applications/tao-run-deft-aoi/cards/ and skills/applications/tao-run-automl/cards/. Each pack ships its own driver.sh and README.md (version pin, required env, how to run).

Cards shrink the model's job; they don't remove it. The driver owns routing and waiting (deterministic), helper scripts own state commits (deterministic), and the model executes one pre-planned stage: run verbatim commands, read a gate table, decide pass/fail from real output, fill in the one dynamic value. If a stage ever becomes 100% deterministic, graduate it out of the card into the driver or a helper script.

Quick start — run a shipped card pack

# plugin installs export TAO_SKILL_BANK_PATH automatically; standalone users set it first:
export TAO_SKILL_BANK_PATH=/path/to/tao-skill-bank

# one-time: scaffold ~/.tao-kit/kit.env and check harness prerequisites
bash "$TAO_SKILL_BANK_PATH/skills/core/tao-token-efficient-execution/scripts/install.sh"

# edit ~/.tao-kit/kit.env: set WS (and VENV for the AutoML pack) and MODEL;
# export your provider's API key in your shell — never put it in kit.env.
# then launch a pack driver detached (leave stderr attached: config errors print immediately):
nohup bash "$TAO_SKILL_BANK_PATH/skills/applications/tao-run-automl/cards/driver.sh" > /dev/null &

# monitor
tail -f ~/.tao-kit/automl/driver.log

The driver waits while jobs run (activity-based, not process-based), fires one fresh session per stage, halts on committed errors (no auto-retry — an operator decides), and exits 0 only after verified completion. DEFT prepares its inference handoff and passes the completion audit; AutoML requires its DONE marker with no trailing failure. Round-cap exhaustion exits nonzero.

Starting a pack driver is side-effecting work: complete the tao-launch-workflow gate (platform, credentials, image, datasets, launch review) before launching it, exactly as for in-conversation execution. Pi guards are not an OS sandbox: use an isolated trusted worker, not a workstation containing unrelated credentials (see adapters/pi/README.md).

Quick start — author a pack for another workflow

One authoring session with a strong model compiles the skill into cards (measured: ~10 minutes, one-time cost; every later run executes them):

  1. Read references/authoring_prompt.md (the round-0 contract) and references/authoring_prompt_v2.md (rules distilled from measured small-model failures: one command per step, mechanical state gates, exact artifact paths, explicit termination, bounded self-repair).

  2. Fill in run parameters — everything concrete for the target machine. Whatever you leave out, execution sessions will burn tokens rediscovering.

  3. The authoring session reads the skill + inspects the workspace + writes cards into skills/applications/<skill>/cards/. It must NOT run the workflow.

  4. Copy a shipped pack's driver.sh and edit its three config points: the stage→card routing table, the working() predicate, and the paths block. (templates/driver.template.sh is the harness-portable skeleton.)

references/CARD_AUTHORING.md reconstructs a real authoring session play by play.

Model floor (measured, execute-side)

Authoring always needs a strong model. Execution was measured across sizes:

Model classCard executionNotes
Frontier (e.g. Claude)flawlessreference bar: 0 guard fires, clean labels
~400B MoEnear-flawlesscorrect results; a few guard saves
~35B MoEworkflow-dependentAutoML clean end-to-end; DEFT completed but with sloppy stage labels
~30B dense w/o tool disciplinebelow floorfabricated results, loops; guards catch but cannot fix

Raw-skill execution (no cards) did not complete honestly on ANY of the small models measured — aborts, protocol violations, or falsely declared success. Cards are what make small-model execution possible, not a minor optimization.

Report, don't patch: when an execution model fails a card, report it and stop (the driver's no-auto-retry halt enforces this). Never edit cards or state to cover a model's mistakes; only genuine card-authoring defects get fixed, explicitly.

Files

PathWhat
references/CONTRACTS.mdprogress log, STAGE_DONE, commands.log, env contract
references/authoring_prompt.md / _v2.mdcard compilation prompts
references/CARD_AUTHORING.mda real authoring session, annotated
templates/driver.template.shdriver skeleton (three config points)
templates/kit.env.templateper-host config (~/.tao-kit/kit.env)
adapters/pi/, adapters/claude-code/guard + recorder per harness
scripts/install.shprerequisite check + kit.env scaffold
scripts/analyze_usage.pyper-session token accounting from session JSONL
scripts/smoke_test.shno-GPU adapter test (guard, recorder, accounting)

Files

adapters/pi/guard.ts

// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
// SPDX-License-Identifier: Apache-2.0
/**
 * Guard extension (port of the DEFT kit's PreToolUse guard.sh).
 *
 * Blocks known-bad invocations BEFORE the agent burns tokens on them.
 * Claude Code contract was: exit 2 blocks the call, stderr shown to the agent.
 * Pi contract: return { block: true, reason } from a tool_call handler —
 * the reason is returned to the model as the tool error.
 *
 * Defense in depth, NOT a sandbox: arbitrary shell code and Docker access
 * require a trusted, isolated worker. Provider credentials stay in Pi's
 * environment; the bash tool gets an explicit non-secret environment.
 */
import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
import { createBashToolDefinition, VERSION } from "@earendil-works/pi-coding-agent";
import { execSync } from "node:child_process";
import * as fs from "node:fs";
import * as path from "node:path";

// Do not inherit provider keys, shell startup hooks, exported functions, or
// arbitrary host variables into model-controlled subprocesses.
const TOOL_ENV = new Set([
	"PATH", "HOME", "USER", "LOGNAME", "TMPDIR", "TMP", "TEMP", "LANG", "LC_ALL", "TZ", "TERM",
	"WS", "RD", "ITER", "SB", "VENV", "TRAIN_IMG", "DS_IMG", "SKILL_ROOT", "DPY", "DEFT_PYTHON",
	"MOUNTS", "STAGE_T0", "AUTOML_RD", "PI_KIT_WS", "PI_KIT_RD", "PI_KIT_RUN_PREFIX",
]);

export function toolEnvironment(env: NodeJS.ProcessEnv): NodeJS.ProcessEnv {
	return Object.fromEntries(Object.entries(env).filter(([name]) => TOOL_ENV.has(name)));
}

export function supportsSafeBash(version: string): boolean {
	const match = /^(\d+)\.(\d+)\.(\d+)$/.exec(version);
	if (!match) return false;
	const [, major, minor, patch] = match.map(Number);
	return major > 0 || minor > 85 || (minor === 85 && patch >= 1);
}

const SECRET_REFERENCE = /\b(?:[A-Z0-9_]*(?:API_KEY|ACCESS_TOKEN|SECRET|PASSWORD)|NGC_KEY|HF_TOKEN)\b/;
const SECRET_PATH = /(?:^|[/\\\s("'\x60])(?:\.env(?:\.[^/\\\s"'\x60;|<>]*)?|secrets?\.[^/\\\s"'\x60;|<>]+|\.ssh|\.aws|\.azure|\.gnupg|\.netrc|\.npmrc|\.pypirc|auth\.json|credentials(?:\.json)?)(?:[/\\\s"'\x60;|<>]|$)|(?:^|[/\\\s("'\x60])\.config[/\\](?:gcloud|tao)(?:[/\\]|$)|(?:^|[/\\\s("'\x60])\.docker[/\\]config\.json\b|[/\\]proc[/\\][^/\\]+[/\\](?:environ|mem)\b|\.(?:pem|key)(?:[\s"'\x60;|<>]|$)/i;

function credentialPath(value: string, cwd: string): boolean {
	const expanded = value.replace(/^~(?=\/|$)/, process.env.HOME ?? "");
	const absolute = path.resolve(cwd, expanded);
	if (SECRET_PATH.test(expanded) || SECRET_PATH.test(absolute)) return true;
	// Resolve existing parents too, so writes through directory symlinks cannot
	// bypass the same check that protects reads of credential files.
	let parent = absolute;
	while (!fs.existsSync(parent) && path.dirname(parent) !== parent) parent = path.dirname(parent);
	try {
		return SECRET_PATH.test(path.join(fs.realpathSync(parent), path.relative(parent, absolute)));
	} catch {
		return true; // fail closed if the target cannot be inspected
	}
}

export default function (pi: ExtensionAPI) {
	const supported = supportsSafeBash(VERSION);
	const bash = createBashToolDefinition(process.cwd(), {
		shellPath: "/bin/bash",
		spawnHook: (context) => ({ ...context, env: toolEnvironment(context.env) }),
	});
	pi.registerTool({
		...bash,
		execute: (id, params, signal, onUpdate, ctx) => {
			if (!supported) throw new Error("Credential-safe tools require Pi 0.85.1 or newer.");
			return bash.execute(id, params, signal, onUpdate, ctx);
		},
	});
	const recent: string[] = [];
	let calls = 0;
	let budgetWarned = false;
	const budget = parseInt(process.env.PI_KIT_TURN_BUDGET ?? "0", 10) || 0;

	pi.on("tool_call", async (event, ctx) => {
		if (!supported) {
			ctx.abort();
			return { block: true, reason: "GUARD(runtime): upgrade to Pi 0.85.1+ before running this pack." };
		}
		// Turn budget (generic, env-gated) — measured: models that cannot end
		// their turn burn 1000+ messages per session. Warn near the budget,
		// hard-block past it.
		calls++;
		if (budget > 0 && calls > budget) {
			ctx.abort();
			return { block: true, reason: `GUARD(budget): tool-call budget (${budget}) exhausted for this session. STOP now: print the card's STAGE_DONE token as your final message and end your turn. The driver will re-enter with a fresh session.` };
		}
		if (budget > 0 && !budgetWarned && calls > budget - 10) {
			budgetWarned = true;
			return { block: true, reason: `GUARD(budget): only ${budget - calls + 1} tool calls left in this session. Finish the CURRENT card step, commit what is committable, print the STAGE_DONE token, and end your turn. (This call was blocked only to deliver the warning — you may re-issue it.)` };
		}

		if (["read", "edit", "write"].includes(event.toolName)) {
			if (credentialPath(String(event.input.path ?? ""), ctx.cwd)) {
				return { block: true, reason: "GUARD(secrets): credential files must not be read, changed, or copied into the session." };
			}
			return undefined;
		}
		if (event.toolName !== "bash") return undefined;
		const cmd = String(event.input.command ?? "");
		if (!cmd) return undefined;

		// Catch dumps inside compound commands and nested shells as well as
		// simple invocations. This is a diagnostic guard, not a shell parser;
		// the environment allowlist above is the subprocess credential boundary.
		if (SECRET_REFERENCE.test(cmd) || SECRET_PATH.test(cmd) ||
			/(?:^|[\s;&|("'\x60])(?:\/usr\/bin\/|\/bin\/)?(?:env|printenv)\b/.test(cmd) ||
			/(?:^|[\s;&|("'\x60])(?:export|declare)\s+-[a-zA-Z]*p\b/.test(cmd) ||
			/(?:^|[\s;&|("'\x60])set\s*(?:$|[;&|)"'\x60])/.test(cmd)) {
			return { block: true, reason: "GUARD(secrets): do not dump environments or access credential variables/files. Use only the card's named non-secret variables." };
		}

		// Loop breaker — at temperature 0 the nano model wedges itself repeating
		// NEAR-identical failing commands (measured: a 475-message session cycling
		// `find ... *.pth` variants differing only in whitespace/pipes). Match on
		// a normalized prefix over a sliding window, not exact equality.
		const sig = cmd.replace(/\s+/g, " ").trim().slice(0, 80);
		recent.push(sig);
		if (recent.length > 8) recent.shift();
		const same = recent.filter((s) => s === sig).length;
		if (same >= 4) {
			return {
				block: true,
				reason: `GUARD(loop): you have issued ${same} nearly-identical commands — this is not making progress, and whatever you keep searching for does not exist. STOP repeating. Re-read the card's failure branch and EXECUTE ITS FIX now (edit the spec file / relaunch from commands.log), or re-append the previous stage's ok line and end your turn.`,
			};
		}

		// Guard 0 — NO FABRICATED RESULTS. The nano model was measured writing
		// 'train ok' log entries (with invented metrics) while train.log ended
		// 'Execution status: FAIL' and no container had run. Verify reality
		// before allowing a train-success log entry.
		if (/(log_stage|commit_stage)/.test(cmd) && /--stage\s+train\b/.test(cmd) && !/--status\s+error\b/.test(cmd)) {
			const rd = process.env.PI_KIT_RD ?? process.env.RD ?? "";
			const iterMatch = cmd.match(/--iter-label\s+(\S+)/);
			// The command text is RAW (pre-shell-expansion): cards pass the literal
			// `$ITER`, so resolve env references and quotes before building the path,
			// falling back to the driver-exported ITER.
			let iter = (iterMatch ? iterMatch[1] : "").replace(/^["']|["']$/g, "");
			iter = iter.replace(/\$\{?([A-Za-z_]\w*)\}?/g, (_, v) => process.env[v] ?? "");
			if (!iter) iter = process.env.ITER ?? "";
			const trainLog = rd && iter ? path.join(rd, iter, "train", "train.log") : "";
			let passed = false;
			try {
				if (trainLog) passed = fs.readFileSync(trainLog, "utf8").includes("Execution status: PASS");
			} catch {
				/* missing log = definitely not passed */
			}
			if (!passed) {
				return {
					block: true,
					reason: `GUARD(verify-train): you are logging 'train ok' but ${trainLog || "$RD/<iter>/train/train.log"} does not contain 'Execution status: PASS'. Training has NOT succeeded — never fabricate results or metrics. Follow the card's failure branch instead: fix the spec issue named in the log, relaunch the recorded train command detached, and END YOUR TURN without logging.`,
				};
			}
		}

		// Baseline safety net (Pi has no permission system underneath us).
		if (/\brm\s+(-[a-zA-Z]*r[a-zA-Z]*f|-[a-zA-Z]*f[a-zA-Z]*r)\b\s+(\/|\$HOME|~)(\s|$)/.test(cmd) || /\bsudo\b/.test(cmd)) {
			return { block: true, reason: "GUARD(safety): destructive/root command blocked by kit policy. Work inside $WS and $RD only; nothing in this workflow needs sudo." };
		}

		// Guard 1 — SigLIP embedding has no cuDNN conv engine on this GPU (sm_75).
		// Scope the check to each `docker run` segment: a compound command may
		// legitimately pair a CPU embedding run with a --gpus knn run.
		const embeddingWithGpus = cmd
			.split(/docker run/)
			.some((seg) => seg.includes("image_embeddings") && seg.includes("--gpus"));
		if (embeddingWithGpus) {
			return {
				block: true,
				reason:
					"GUARD(sm_75-embedding): 'embedding image_embeddings' crashes on GPU on this host (cuDNN: 'GET was unable to find an engine'). Re-run WITHOUT --gpus and with -e CUDA_VISIBLE_DEVICES= (CPU is fast enough: ~100 imgs/min). 'tmm nearest_neighbors' may keep --gpus.",
			};
		}

		// Guard 2 — training writes ~1.9 GB/epoch of checkpoints; require headroom.
		// A truly full disk (0G) must block; only a failed df lets the call through.
		if (cmd.includes("visual_changenet train")) {
			let free: number | undefined;
			try {
				const raw = execSync("df --output=avail -BG / | tail -1", { encoding: "utf8" }).replace(/[^0-9]/g, "");
				if (raw.length > 0) free = parseInt(raw, 10);
			} catch {
				/* if df itself fails, let the call through rather than dead-lock the loop */
			}
			if (free !== undefined && free < 30) {
				return {
					block: true,
					reason: `GUARD(disk): only ${free}G free on /. A 10-epoch ChangeNet training writes ~19G of checkpoints and the run needs headroom (30G minimum). Free space (prune non-selected checkpoints from earlier iterations of THIS run) before training.`,
				};
			}
		}

		// Guard 3 — the ds:aoi container rejects '-e <spec>' for gap_analysis (pure Hydra CLI).
		if (cmd.includes("gap_analysis vcn_aoi") && /\s-e\s+\S+\.ya?ml/.test(cmd)) {
			return {
				block: true,
				reason:
					"GUARD(ds-aoi-cli): the nvcr.io/nvidian/iva/tao-toolkit-ds:aoi image rejects '-e <spec>' for gap_analysis (exits on argparse). Pass pure Hydra overrides (key=value) instead — see your stage card's exact invocation.",
			};
		}

		return undefined;
	});
}

Requirements and compatibility

Works with: Claude Code, Claude apps, OpenAI Codex, GitHub Copilot, Cursor, Gemini CLI, Kiro, OpenCode, Goose, Amp, Roo Code, JetBrains Junie, Factory Droid, Devin (ex-Windsurf), Mistral Vibe, OpenHands, Letta

“Works with” means the tool reads the open Agent Skills format; a skill written for one tool may use features others lack.

Needs: Declares allowed tools, Needs an API key, Needs Python, Needs Node.js

The author says: Requires bash, jq, Python 3.10+, and a headless agent harness with tool interception (see adapters/ for supported versions). The shipped card packs additionally need docker and the prerequisites of their application skill.

Security

What our scanner noticed· Medium risk

  • Large base64-encoded blobs
  • References to credential files
  • Scripts that your agent may run

This skill includes scripts that your agent may run. Read them before you use it.

A static scan is not a guarantee. Skills are third-party content: review a skill before you let an agent use it.

Attribution and licence

Created by
NVIDIA Corporation
Publisher
NVIDIA (Official)
Source
NVIDIA/skills · skills/tao-token-efficient-execution · commit fce3cca
Licence
Apache License 2.0 (redistribution allowed)
  • LICENSE (added by AutoGineer from LICENSE-APACHE)
  • ATTRIBUTION.md (written by AutoGineer)
Synced

AutoGineer is not affiliated with or endorsed by NVIDIA Corporation or NVIDIA.

Download ZIP

The ZIP holds the skill’s files, its licence files and an ATTRIBUTION.md. Download tao-token-efficient-execution.zip