Skip to main content
Glama

pio_memory_watch

Monitor serial output for heap and stack metrics to detect memory leaks, fragmentation, and stack headroom issues.

Instructions

Watch serial output for heap and stack telemetry and diagnose leaks, fragmentation, and stack headroom. Give session_id of an open monitor session (its buffer plus seconds more) or a port for a one-shot capture. Understands Arduino-ESP32 'Free heap: N min: N largest: N', ESP.getFreeHeap() prints, ESP-IDF heap_caps_print_heap_info blocks, FreeRTOS vTaskList tables, and uxTaskGetStackHighWaterMark lines; pattern (regex with a (?P) group) adds a custom metric. Returns per-metric min/max/trend with a stable/shrinking/growing verdict, a per-task stack table flagged below stack_warn_bytes, and a fragmentation hint. When the firmware prints nothing usable, instrumentation_hint has copy-paste snippets.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
envNo
baudNo
portNo
patternNo
secondsNo
max_linesNo
session_idNo
project_dirNo
stack_warn_bytesNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Schema Changelog

Changes observed during successful MCP inspections.

  1. Addedv0.2.0

TDQS

A4.2/5.0
Behavior3/5

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

No annotations are provided, so the description carries the full burden. It discloses that it reads serial output over a session or port, parses specific formats, and returns verdicts and a stack table. It also mentions a fallback behavior (instrumentation_hint) when no usable output. However, it does not explicitly state whether the operation is read-only or if it consumes/modifies the session buffer, nor does it mention any side effects on the firmware. This is a moderate gap for a monitoring tool.

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

Conciseness5/5

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

The description is dense but well-organized: it leads with the purpose, then gives usage modes, then supported formats, custom pattern, output summary, and fallback. Every sentence adds distinct information without redundancy. The structure is logical and front-loaded, making it easy for an agent to grasp the essential function quickly.

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

Completeness4/5

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

For a tool with 9 parameters, two capture modes, multiple format parsers, and a rich output (per-metric trends, stack table, fragmentation hint), the description covers the core use cases thoroughly. It explains how to invoke it, what it understands, what it returns, and the fallback when output is unusable. It omits details on a few parameters (env, baud, max_lines, project_dir) and does not specify exact output schema, but an output schema exists separately. Overall, it is sufficiently complete for an agent to use it correctly in most situations.

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

Parameters4/5

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

Schema description coverage is 0%, so the description must compensate. It explains the key parameters: session_id and port (alternative capture modes), seconds (how much buffer to use), pattern (regex with a named group for custom metrics), and stack_warn_bytes (implicitly via "flagged below stack_warn_bytes"). However, it does not cover env, baud, max_lines, or project_dir, leaving about half of the parameters unexplained. It adds value for the most important ones, but not complete coverage.

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 opens with a clear verb+resource: "Watch serial output for heap and stack telemetry and diagnose leaks, fragmentation, and stack headroom." This immediately distinguishes it from generic monitor tools (e.g., pio_monitor_start) by focusing on memory diagnosis. It also lists the specific firmware output formats it understands, which makes its scope concrete.

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

Usage Guidelines4/5

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

The description explains two clear usage modes: "Give session_id of an open monitor session (its buffer plus `seconds` more) or a port for a one-shot capture." It also tells the user what happens when nothing usable is printed (instrumentation_hint). However, it does not explicitly compare to alternative tools or say when not to use it, so it lacks explicit exclusions.

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