instruments
instruments
¶
Instrument Plugin System data models.
Defines the config-driven instrument profile system that allows CLI tools to be added as mzt instruments via YAML configuration files, without writing Python backend code.
An InstrumentProfile describes everything Marianne needs to execute prompts through an instrument: identity, capabilities, CLI flags, output parsing, error detection, and model metadata. Profiles are loaded from YAML files in ~/.marianne/instruments/ (organization) and .marianne/instruments/ (venue).
The music metaphor: an instrument is what the musician plays. The profile is the instrument's spec sheet — what it can do, how it's held, what sounds it makes. The musician doesn't need to know how the instrument was built — they just need to know how to play it.
v1: CLI instruments only. HTTP instruments designed for but not implemented. v1.1+: HTTP backends, code-mode techniques.
Attributes¶
Classes¶
InstrumentRouteBinding
¶
Bases: BaseModel
Reviewed declared route, not proof of a service's loaded model weights.
CodeModeInterface
¶
Bases: BaseModel
A TypeScript interface exposed to agent-generated code.
Part of the code-mode technique system (v1: foundation only, not wired). Instead of sequential MCP tool calls, agents write code against typed interfaces in a sandboxed runtime. Based on Cloudflare's Dynamic Workers pattern — 81% token reduction vs MCP.
CodeModeConfig
¶
Bases: BaseModel
Code-mode technique configuration.
v1: This type exists in the data model but is not wired into execution. The field on InstrumentProfile is populated from YAML but ignored at runtime. v1.1+: A sandboxed runtime (Deno subprocess or Node.js vm) runs agent-generated code against the declared interfaces.
EffortMapping
¶
Bases: BaseModel
How a profile delivers instrument_config.effort to its harness (GH #535).
A score names a level in Marianne's vocabulary (minimal .. max);
levels maps it to the harness's own word and delivery says where
that word goes. Third-party profiles under ~/.marianne/instruments/ or
.marianne/instruments/ declare the same block; no code change is needed
to give a new harness the key.
Methods:¶
defaults_in
¶
Every native value a fixed flag list already sets through this mapping.
Source code in src/marianne/core/config/instruments.py
apply
¶
flags with this mapping's value set to native (CLI shapes).
A default is replaced where it stands (never a second one); with no
default the pair is appended. Another switch that shares the flag (a
second codex -c override) is kept. Callers check the refusal first.
Source code in src/marianne/core/config/instruments.py
apply_to_body
¶
payload with this mapping's dotted key set to native (HTTP).
Source code in src/marianne/core/config/instruments.py
ToolsMapping
¶
Bases: BaseModel
How a profile delivers instrument_config.tools to its harness (GH #534).
Tool names are the harness's own; Marianne has no tool vocabulary. The
flag must be the one that REMOVES tool definitions from the model's
context (Claude Code --tools), not a permission-only flag such as
--allowedTools.
Methods:¶
joined
¶
apply
¶
flags with this mapping's flag set to tools.
A default already in flags is replaced where it stands (never a
second one); with none, the pair is appended.
Source code in src/marianne/core/config/instruments.py
ModelCapacity
¶
Bases: BaseModel
Per-model metadata for cost tracking and context management.
Each instrument can offer multiple models (e.g., gemini-2.5-pro and gemini-2.5-flash). ModelCapacity records what each model can do and what it costs — used by the conductor for cost tracking, context budget calculation, and instrument selection.
CliCommand
¶
Bases: BaseModel
How to build the CLI command for an instrument.
Maps Marianne execution concepts (prompt, model, auto-approve, output format) to CLI flags. When a field is None, the instrument doesn't support that concept via flags. When prompt_flag is None, the prompt is passed as a positional argument.
CliOutputConfig
¶
Bases: BaseModel
How to parse CLI output into an ExecutionResult.
Three output modes: - text: stdout is the result, no structured extraction - json: parse stdout as JSON, extract via dot-path - jsonl: split stdout into JSON lines, find completion event
CliErrorConfig
¶
Bases: BaseModel
How to detect errors from CLI instrument output.
Supplements Marianne's existing ErrorClassifier with instrument-specific patterns for rate limit detection and auth error recognition.
InteractiveGate
¶
Bases: BaseModel
A startup dialog the interactive driver may need to dismiss.
Some TUI agents present blocking dialogs before reaching their ready prompt (e.g. Claude Code's trust-folder check). Each gate pairs a screen pattern with the keys that dismiss it. Gates fire at most once per session and are skipped entirely once the ready prompt has been seen — a late-matching gate must never type into the agent's input.
InteractiveUsageConfig
¶
Bases: BaseModel
Where an interactive harness records per-session token usage (GH #533).
A tmux session has no JSON stdout, so the backend picks the session id
itself, launches the harness with session_id_flag, and after the sheet
reads the harness's own session record. Sessions whose profile has no
block, or whose record is missing or empty, are reported UNMEASURED
(cost_uncertain), never as a free zero.
InteractiveCliConfig
¶
Bases: BaseModel
How to drive a CLI instrument through a live interactive session.
Present only on profiles whose interactive behavior has been verified against the real TUI (screen patterns are empirical, not guessed). When a score opts into interactive mode for an instrument without this block, backend creation fails with a structured config error.
See docs/specs/2026-06-10-interactive-mode-design.md.
CliProfile
¶
Bases: BaseModel
Everything needed to invoke a CLI instrument and parse its output.
Composed of four concerns: - command: how to build the CLI invocation - output: how to parse the result - errors: how to detect failures - interactive: how to drive a live TUI session (optional, verified instruments only)
HttpProfile
¶
Bases: BaseModel
Configuration for the shared OpenAI-compatible HTTP executor.
InstrumentProfile
¶
Bases: BaseModel
Everything Marianne needs to execute prompts through an instrument.
This is the top-level type for the instrument plugin system. Each instrument profile describes a CLI tool or HTTP API that Marianne can use as a backend. Profiles are loaded from YAML files and validated by Pydantic at conductor startup.
The profile carries: - Identity (name, display_name, kind) - Capabilities (what the instrument can do) - Models (what models are available, their costs and limits) - Execution config (CLI flags or HTTP endpoints) - Code-mode technique config (foundation — not wired in v1)
A file in the organization or venue layer may start with extends: <name>
(GH #543). That key is read and removed by the loader, which deep-merges
the file over the named profile from a lower layer (mappings merge;
scalars and lists replace; an explicit null clears a key) before this
model validates the result, so it is not a field here.
Methods:¶
tools_refusal
¶
Why this profile cannot run a sheet with tools, or None when it can.
The ONE wording shared by mzt validate (V337), dispatch and the
backends' command builders.
Source code in src/marianne/core/config/instruments.py
effort_levels_for
¶
Marianne level -> native word for model ({} = nothing mapped).
A model row with effort_levels replaces the profile's map; a model
not listed (or None, the profile default) uses the profile's map.
Source code in src/marianne/core/config/instruments.py
accepted_effort_levels
¶
The Marianne levels a sheet may set here, in vocabulary order.
Source code in src/marianne/core/config/instruments.py
effort_refusal
¶
Why this profile cannot run a sheet at level, or None when it can.
The ONE wording shared by mzt validate (V335), dispatch and the
backends' command builders, so the author reads the same sentence
wherever the refusal surfaces. It always ends with the accepted levels.
Source code in src/marianne/core/config/instruments.py
native_effort
¶
The harness word for level; callers check effort_refusal first.
Functions:¶
validate_openai_response_format
¶
Validate an OpenAI-compatible response_format object.
Single source of truth for the structured-output wire contract, shared
by the HttpProfile config validator (profile YAML) and the generic
backend setter (per-sheet instrument_config). Accepts exactly the
two structured-output shapes OpenAI-compatible servers support:
{"type": "json_object"}{"type": "json_schema", "json_schema": {"name": str, "schema": dict, "strict": bool (optional)}}
Unknown keys at either level are allowed (provider extensions) and are forwarded unchanged — validation catches authoring mistakes, it does not rewrite the object. Returns a deep copy so later mutation of the source config can never alias into a request payload.
Raises:
| Type | Description |
|---|---|
ValueError
|
with a message naming |