Documentation

Kata

Kata is a Hermes Agent plugin. It records the tool calls your agent makes, detects multi-step routines repeated across conversations, and proposes each as a reusable tool. A proposal becomes a tool only after you approve it. The compiled tool replays the routine deterministically, with no model calls between steps.

Install

Kata requires Hermes Agent 0.22.0 or newer and has no third-party Python dependencies.

hermes plugins install kata          # from the catalog, pinned to a reviewed commit
hermes plugins enable kata
hermes plugins validate ~/.hermes/plugins/kata   # optional: same checks as catalog CI

Start a new session. Kata begins recording immediately and stays silent until it has something to show you. Open the Kata tab in hermes dashboard to review proposals visually.

To try it without a model or API key, clone the repository and run python scripts/demo.py. It drives the real plugin through a stand-in host that fires the same hooks Hermes does.

Daily use

Work normally. When a routine has appeared in three separate conversations (configurable), Kata proposes it at the end of the session.

/kata                         # list proposals and active katas
/kata review 2                # steps, data flow, permissions, schemas, side effects, validation
/kata approve 2 as deploy_preview
/kata runs kata_deploy_preview  # traces of recent executions
/kata disable kata_deploy_preview
/kata rollback kata_deploy_preview 1

Once approved, the agent sees a new tool, for example kata_deploy_preview(branch), and calls it once instead of repeating the steps. The same commands are available as hermes kata ... in a shell.

Architecture

ModuleResponsibility
runtime.pyHook handlers, tool registration and unregistration, the compiled-tool handler, per-call approval.
miner.pySegmentation, windowed counting, maximality, leave-one-out scoring, baseline measurement.
templating.pyArgument inference (constants, parameters, data-flow references), rendering and matching.
validator.pyOffline pre-activation checks with a replaying stub dispatcher.
executor.pyDeterministic step execution with timeouts, bounded retries and traces.
service.pyLifecycle and state transitions shared by the slash command, CLI and dashboard.
effects.py, redact.pySide-effect classification and secret masking.
store.pyEvents, model requests, katas, versions, runs and audit log in one WAL-mode SQLite file.

Pattern discovery

Segmentation

History is split into runs of successful calls inside a single user turn. Failures, pauses longer than five minutes and calls to conversational tools such as clarify break a run. A routine therefore never stitches together work from different requests.

Counting

Every contiguous window of 2 to 8 calls is keyed by its signature: the tool names plus each call's argument keys. Windows are counted once per turn and must recur in at least min_support distinct conversations, so repeating something many times in one chat proves nothing. A window contained in an equally frequent longer window is dropped, which yields whole routines rather than fragments.

Coherence

Every step after the first must be tied to the routine, either by data flow from an earlier result or by a fixed argument. Sequences of tools that recur by chance, with unrelated arguments, are rejected before scoring.

Generalisation

For each argument across occurrences, Kata infers an expression:

ObservedBecomesExample
Same value every timeConstantpath="src"
Equals a field of an earlier resultReference<step 1.matches.0.path>
Contains an earlier resultConcatenation with a reference"wc -l <step 2.path>"
Changes, not derivableInput parameter"TODO({pattern})"

Confidence

For each occurrence, a template is built from all the others and must reproduce the held-out call sequence exactly. The share that pass is the fit rate. Confidence is fit_rate x (1 - 0.6^support): 0.78 at three conversations with perfect fit, 0.87 at four. Candidates below min_confidence (0.75) are reported as seen but not proposed.

Validation

Validation runs before a proposal is stored and again at approval. No real tool is called.

CheckWhat it proves
replay_matches_recordedInputs recovered from each recorded example re-render its exact arguments.
holdout_fitThe template generalises to examples it was not built from (at least 90%).
executor_replayThe executor issues the recorded calls, in order, with identical arguments.
failure_handlingAn injected error stops the run and skips every later step.
timeout_handlingA hung step times out, is not re-issued, and stops the run.
input_schema, output_schemaSchemas accept recorded data and reject an incomplete call.
no_secretsNo credential or redacted value appears in the spec.
tools_availableEvery tool exists today with the schema it had when recorded.
compilable_tools, recorded_examples, side_effectsStructural requirements and disclosure.

Execution

A compiled tool validates its arguments, then for each step renders arguments from inputs and earlier results and calls ctx.dispatch_tool. A step fails on an error payload, [TOOL_ERROR] text, success: false or a non-zero exit_code. The run stops there and returns a trace with every step's status, so the agent can continue by hand from the exact point of failure.

Lifecycle

StatusMeaningRegistered
candidateProposed, waiting for youNo
activeApproved and healthyYes
staleA tool schema changed or your manual runs no longer fit; a revised version is prepared for reviewNo
suspendedThree consecutive failed runsNo
disabledTurned off by you; can be re-enabled after re-validationNo
rejectedDeclined by you; never proposed againNo

Every version is kept. Approving creates the active version, rollback switches to any earlier approved version after re-validating it, and every transition is written to the audit log with its actor.

Configuration

Settings live under plugins.entries.kata.settings in config.yaml and appear in the Desktop settings form.

KeyDefaultEffect
min_support3Distinct conversations before proposing
min_confidence0.75Proposal threshold
max_steps8Longest routine considered
step_timeout_s60Per-step timeout
read_retries1Retries for read-only steps
retention_days30History kept for mining
recordtruePause or resume observation

Reference

Hermes surfaces used

Hooks: post_tool_call, post_api_request, pre_tool_call, pre_llm_call, on_session_start, on_session_end. Context: register_tool (and the returned handle's dispose), register_command, register_cli_command, dispatch_tool, get_config. Storage: plugins.plugin_storage.plugin_db. Drift detection reads tools.registry.registry.get_schema. All are on Hermes's public plugin API list.

Dashboard API

Mounted at /api/plugins/kata/ behind the dashboard's authentication: GET overview, GET katas, GET katas/{id}, POST katas/{id}/approve|reject|disable|enable|rollback, POST mine, GET audit.

Limitations