Skip to main content
Glama
MartinLoop — Stop Runaway Loops, Bad Code & Token Waste

MartinLoop — Stop Runaway Loops, Bad Code & Token Waste

martin_run

Destructive

Executes a governed coding run after workflow admission, enforcing budget, scope, and verification to prevent runaway loops and bad code.

Instructions

Execute a governed MartinLoop coding run after MCP workflow admission is satisfied. Use when the user has authorized implementation, bug fixing, tests, or refactoring and doctor/estimate/plan/preflight receipts match this task. Do not use for question-only diagnosis or when policy, budget, credentials, or scope still need consent. Next: read martin_dossier and verifier evidence.

Tool call template

Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "objective": "<objective>"
    },
    "name": "martin_run"
  }
}

Input Schema

NameRequiredDescriptionDefault
modelNoOptional model override passed to the primary provider.
engineNoWhich agent CLI to use. Defaults to claude.
maxUsdNoHard budget ceiling in USD.
maxTokensNoMaximum total tokens across all attempts.
objectiveYesThe coding task to complete. Be specific about what needs to change.
projectIdNoProject identifier for telemetry.
deniedPathsNoRepo-relative path globs Martin must never modify.
workspaceIdNoWorkspace identifier for telemetry.
allowedPathsNoRepo-relative path globs Martin may modify.
maxIterationsNoMaximum number of loop attempts.
fallbackEnginesNoExplicit ordered provider fallbacks authorized for this run. No provider is added implicitly.
verifyTimeoutMsNoHard timeout for each verifier command in milliseconds.
verificationPlanNoCommands that must all exit 0 for the task to be considered complete.
workingDirectoryNoOptional repo-root override resolved under the MCP workspace root. Must stay within that safe root.
pricePerMTokenUsdNoExplicit conservative per-million-token pricing authority for a catalog-unknown OpenAI-compatible model.
providerExecutionTimeoutMsNoHard timeout for each provider coding process in milliseconds.

Output Schema

NameRequiredDescriptionDefault
budgetYes
engineYes
loopIdYes
reasonYes
statusYes
costUsdYes
attemptsYes
pressureYes
inspectionYes
shouldStopYes
lifecycleStateYes
remainingTokensNo
workingDirectoryYes
remainingBudgetUsdYes
verificationPassedYes
remainingIterationsYes

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed1 schema field changedv0.10.0
    • addedInput schema / properties / pricePerMTokenUsd
      Added value: +{
      +  "description": "Explicit conservative per-million-token pricing authority for a catalog-unknown OpenAI-compatible model.",
      +  "minimum": 0,
      +  "type": "number"
      +}
  2. Changed2 schema fields changedv0.8.9
    • addedInput schema / properties / fallbackEngines
      Added value: +{
      +  "description": "Explicit ordered provider fallbacks authorized for this run. No provider is added implicitly.",
      +  "items": {
      +    "enum": [
      +      "claude",
      +      "codex",
      +      "gemini",
      +      "openai"
      +    ],
      +    "type": "string"
      +  },
      +  "type": "array",
      +  "uniqueItems": true
      +}
    • changedInput schema / properties / model / description
      Previous value: -"Optional model override passed to the CLI."New value: +"Optional model override passed to the primary provider."
  3. Changed1 schema field changedv0.6.5
    • addedOutput schema / properties / inspection / properties / loop / properties / activeAttemptId
      Added value: +{
      +  "description": "ID of the currently active attempt, when a run is in progress.",
      +  "type": "string"
      +}
  4. Changed3 schema fields changedv0.5.6
    • changedOutput schema / properties / budget / required
      Previous value: -[
      -  "maxUsd",
      -  "softLimitUsd",
      -  "maxIterations",
      -  "maxTokens"
      -]New value: +[
      +  "maxUsd",
      +  "softLimitUsd",
      +  "maxIterations"
      +]
    • changedOutput schema / properties / inspection / properties / loop / required
      Previous value: -[
      -  "loopId",
      -  "title",
      -  "objective",
      -  "status",
      -  "lifecycleState",
      -  "attempts",
      -  "costUsd",
      -  "avoidedUsd",
      -  "pressure",
      -  "shouldStop",
      -  "remainingBudgetUsd",
      -  "remainingIterations",
      -  "remainingTokens"
      -]New value: +[
      +  "loopId",
      +  "title",
      +  "objective",
      +  "status",
      +  "lifecycleState",
      +  "attempts",
      +  "costUsd",
      +  "avoidedUsd",
      +  "pressure",
      +  "shouldStop",
      +  "remainingBudgetUsd",
      +  "remainingIterations"
      +]
    • changedOutput schema / required
      Previous value: -[
      -  "status",
      -  "lifecycleState",
      -  "reason",
      -  "attempts",
      -  "costUsd",
      -  "verificationPassed",
      -  "loopId",
      -  "pressure",
      -  "shouldStop",
      -  "remainingBudgetUsd",
      -  "remainingIterations",
      -  "remainingTokens",
      -  "engine",
      -  "workingDirectory",
      -  "budget",
      -  "inspection"
      -]New value: +[
      +  "status",
      +  "lifecycleState",
      +  "reason",
      +  "attempts",
      +  "costUsd",
      +  "verificationPassed",
      +  "loopId",
      +  "pressure",
      +  "shouldStop",
      +  "remainingBudgetUsd",
      +  "remainingIterations",
      +  "engine",
      +  "workingDirectory",
      +  "budget",
      +  "inspection"
      +]
  5. Changed4 schema fields changedv0.5.5
    • removedOutput schema / properties / costProvenance
      Removed value: -{
      -  "enum": [
      -    "actual",
      -    "calculated",
      -    "estimated",
      -    "unavailable"
      -  ],
      -  "type": "string"
      -}
    • removedOutput schema / properties / inspection / properties / loop / properties / costProvenance
      Removed value: -{
      -  "enum": [
      -    "actual",
      -    "calculated",
      -    "estimated",
      -    "unavailable"
      -  ],
      -  "type": "string"
      -}
    • changedOutput schema / properties / inspection / properties / loop / required
      Previous value: -[
      -  "loopId",
      -  "title",
      -  "objective",
      -  "status",
      -  "lifecycleState",
      -  "attempts",
      -  "costUsd",
      -  "costProvenance",
      -  "avoidedUsd",
      -  "pressure",
      -  "shouldStop",
      -  "remainingBudgetUsd",
      -  "remainingIterations",
      -  "remainingTokens"
      -]New value: +[
      +  "loopId",
      +  "title",
      +  "objective",
      +  "status",
      +  "lifecycleState",
      +  "attempts",
      +  "costUsd",
      +  "avoidedUsd",
      +  "pressure",
      +  "shouldStop",
      +  "remainingBudgetUsd",
      +  "remainingIterations",
      +  "remainingTokens"
      +]
    • changedOutput schema / required
      Previous value: -[
      -  "status",
      -  "lifecycleState",
      -  "reason",
      -  "attempts",
      -  "costUsd",
      -  "costProvenance",
      -  "verificationPassed",
      -  "loopId",
      -  "pressure",
      -  "shouldStop",
      -  "remainingBudgetUsd",
      -  "remainingIterations",
      -  "remainingTokens",
      -  "engine",
      -  "workingDirectory",
      -  "budget",
      -  "inspection"
      -]New value: +[
      +  "status",
      +  "lifecycleState",
      +  "reason",
      +  "attempts",
      +  "costUsd",
      +  "verificationPassed",
      +  "loopId",
      +  "pressure",
      +  "shouldStop",
      +  "remainingBudgetUsd",
      +  "remainingIterations",
      +  "remainingTokens",
      +  "engine",
      +  "workingDirectory",
      +  "budget",
      +  "inspection"
      +]
  6. Changed2 schema fields changedv0.5.4
    • addedInput schema / properties / providerExecutionTimeoutMs
      Added value: +{
      +  "description": "Hard timeout for each provider coding process in milliseconds.",
      +  "exclusiveMinimum": 0,
      +  "type": "integer"
      +}
    • addedInput schema / properties / verifyTimeoutMs
      Added value: +{
      +  "description": "Hard timeout for each verifier command in milliseconds.",
      +  "exclusiveMinimum": 0,
      +  "type": "integer"
      +}
  7. Changed4 schema fields changedv0.5.3
    • addedOutput schema / properties / costProvenance
      Added value: +{
      +  "enum": [
      +    "actual",
      +    "calculated",
      +    "estimated",
      +    "unavailable"
      +  ],
      +  "type": "string"
      +}
    • addedOutput schema / properties / inspection / properties / loop / properties / costProvenance
      Added value: +{
      +  "enum": [
      +    "actual",
      +    "calculated",
      +    "estimated",
      +    "unavailable"
      +  ],
      +  "type": "string"
      +}
    • changedOutput schema / properties / inspection / properties / loop / required
      Previous value: -[
      -  "loopId",
      -  "title",
      -  "objective",
      -  "status",
      -  "lifecycleState",
      -  "attempts",
      -  "costUsd",
      -  "avoidedUsd",
      -  "pressure",
      -  "shouldStop",
      -  "remainingBudgetUsd",
      -  "remainingIterations",
      -  "remainingTokens"
      -]New value: +[
      +  "loopId",
      +  "title",
      +  "objective",
      +  "status",
      +  "lifecycleState",
      +  "attempts",
      +  "costUsd",
      +  "costProvenance",
      +  "avoidedUsd",
      +  "pressure",
      +  "shouldStop",
      +  "remainingBudgetUsd",
      +  "remainingIterations",
      +  "remainingTokens"
      +]
    • changedOutput schema / required
      Previous value: -[
      -  "status",
      -  "lifecycleState",
      -  "reason",
      -  "attempts",
      -  "costUsd",
      -  "verificationPassed",
      -  "loopId",
      -  "pressure",
      -  "shouldStop",
      -  "remainingBudgetUsd",
      -  "remainingIterations",
      -  "remainingTokens",
      -  "engine",
      -  "workingDirectory",
      -  "budget",
      -  "inspection"
      -]New value: +[
      +  "status",
      +  "lifecycleState",
      +  "reason",
      +  "attempts",
      +  "costUsd",
      +  "costProvenance",
      +  "verificationPassed",
      +  "loopId",
      +  "pressure",
      +  "shouldStop",
      +  "remainingBudgetUsd",
      +  "remainingIterations",
      +  "remainingTokens",
      +  "engine",
      +  "workingDirectory",
      +  "budget",
      +  "inspection"
      +]
  8. First observedv0.3.9

TDQS

A4.3/5.0
Behavior4/5

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

Annotations already flag destructiveHint=true, idempotentHint=false and openWorldHint=false, so the description does not need to re-state that this mutates code. It adds genuinely new behavioral context: workflow admission gating, the receipt-match requirement, consent conditions, and the recommended post-run evidence read. It stops short of saying what concretely changes on disk (beyond the schema's allowed/denied paths) or what a failed run returns.

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?

Three tightly packed sentences with the action, the admission condition, and the exclusions front-loaded, followed by a next-step pointer. Dense but almost every clause carries decision-relevant information; the 'Next:' pointer is useful rather than filler.

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 16-parameter destructive tool with an output schema and annotations present, the description covers the prerequisites, authorization boundary, and follow-up evidence path an agent needs before calling it. What it omits (failure modes, what counts as a receipt match) is minor given the rich schema and output schema.

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?

Schema description coverage is 100%, so every one of the 16 parameters is already documented (objective, engine enum, budgets, path globs, verification plan, timeouts). The description adds no parameter-level meaning such as how maxIterations interacts with verificationPlan or how fallbackEngines is authorized, so the baseline 3 applies.

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?

States a specific verb and resource ('Execute a governed MartinLoop coding run') and bounds it with an admission precondition, so an agent can immediately distinguish it from read-only siblings like martin_status or martin_doctor.

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?

Gives both the positive condition (user authorized implementation, bug fixing, tests, refactoring and doctor/estimate/plan/preflight receipts match) and explicit exclusions (question-only diagnosis, unresolved policy/budget/credentials/scope). It also points to the follow-up tools, leaving little to inference.

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