Skip to main content
Glama

stability_metrics

Read-onlyIdempotent

Identify all unity-gain and -180° phase crossovers in a loop-gain AC sweep, compute per-crossing margins, and classify stability.

Instructions

Find EVERY unity-gain and -180° phase crossover in a loop-gain AC sweep, report phase margin at each unity-gain crossing and gain margin at each -180° crossing. Replaces the single-crossing approximation in simulation_summary, which returns wrong margins on conditionally-stable systems.

Run this on a LOOP-GAIN signal (typically a dedicated middlebrook probe or .AC of the open loop). Running on a closed-loop output gives meaningless margins — if the DC phase starts near ±180° (a closed-loop / inverting output rather than a loop probe, which starts near 0°), a warning says so in warnings.

Returns: dc_gain_db, high_freq_gain_db, stability classification (stable / unstable / conditional / unconditional / always_below_unity), all crossings, per-crossing margins, and the worst-case values.

Nuances:

  • Phase is UNWRAPPED first, so systems whose phase drops past -360° are handled correctly (otherwise the raw wrap hides the crossing).

  • If phase NEVER crosses -180°, gain margin is 'infinite' (returned as null with stability='unconditional'). That's stable, not an error.

  • If gain NEVER reaches unity, phase margin is undefined (returned as null with stability='always_below_unity').

  • Multiple crossovers trigger stability='conditional' and a warning — each one needs its own review.

For -3 dB filter cutoffs use bode_metrics(mode='filter'); for custom crossings use bode_metrics(mode='crossing').

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
raw_fileYesPath to loop-gain AC analysis .raw file
signalYesLoop-gain signal (e.g. 'V(loop)')
min_separation_decadesNoMerge near-duplicate crossovers closer than this many decades.
stepNoStep index for .step sweeps
formatNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
dc_gain_dbYes
high_freq_gain_dbYes
stabilityYes
unity_gain_crossoversYes
phase_180_crossoversYes
phase_marginsYes
gain_marginsYes
phase_margin_worst_degNo
gain_margin_worst_dbNo
warningsYes
signalYes
Behavior5/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations indicate readOnlyHint=true and idempotentHint=true, and the description adds rich behavioral details such as phase unwrapping, handling of never-crossing cases (returning null with stability strings), and multiple crossovers triggering a conditional stability warning. No contradictions with annotations.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is well-structured with a clear first paragraph stating the main purpose, followed by bullet points for nuances. It is somewhat verbose but still efficient and front-loaded with essential information.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a complex tool dealing with stability analysis and multiple crossovers, the description thoroughly covers usage scenarios, return fields (dc_gain_db, stability classification, etc.), and edge cases. The presence of an output schema allows the description to focus on behavioral aspects.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema has 80% coverage with descriptions for all parameters. The description does not add extra semantic detail beyond the schema, except for reinforcing the 'signal' parameter context. Given high schema coverage, the baseline of 3 is appropriate.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly defines the tool's purpose: finding unity-gain and -180° phase crossovers in a loop-gain AC sweep and reporting margins. It explicitly distinguishes itself from the sibling tool 'simulation_summary' by noting that the sibling returns wrong margins on conditionally-stable systems.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides explicit guidance on when to use this tool (on a loop-gain signal) and when not to (closed-loop output, which gives meaningless margins). It also directs the user to alternative tools 'bode_metrics' for filter cutoffs or custom crossings.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/Cognitohazard/ltspice-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server