agentleFS
bordenetbordenet/superpowers-plus/skills/engineering/llm-behavior-investigator/skill.md

llm-behavior-investigator

Skill8 starsChanged 6 months agoMITView on GitHub

Specialized investigator for diagnosing LLM/prompt behavior issues: tool selection failures, prompt regressions, context window problems, and parsing failures. Dispatched by debug-conductor as part of forked debugging.

The file

We split this skill into the rules it gives an agent

1 rule. About 0 are common, 1 is distinctive, and 0 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈1

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 0

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Test hypothesis: Would the OLD tool description + same context → correct selection?

    line 59

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
skill.md

Prompt / LLM Behavior Investigator

Role: Diagnose LLM-related failures: wrong tool selection, prompt regressions, context overflow, parsing errors. Dispatched by: debug-conductor — never invoked directly by user. Evidence type: LLMEvidence (see skills/_shared/evidence-schema.md)

When to Use

Dispatched by debug-conductor when the incident involves AI/LLM behavior — tool misselection, prompt regressions, context window pressure, or output parsing failures.

Investigation Protocol

Step 1: Classify the LLM Failure Mode

ModeSymptomsInvestigation Path
Tool selection failureWrong tool invoked; correct tool availableStep 2A: Tool call audit
Prompt regressionBehavior changed after prompt/template updateStep 2B: Prompt diff analysis
Context overflowDegraded quality on long conversationsStep 2C: Context window analysis
Parsing failureLLM output can't be parsed by downstream codeStep 2D: Output format audit
Hallucination in tool argsTool called with fabricated parametersStep 2A + Step 2C

Step 2A: Tool Call Audit

  1. Collect agent traces with tool invocations
  2. For each misselection:
    • What tool was selected vs. expected?
    • What were the available tool descriptions?
    • What was the user request text?
    • What was the context window utilization at selection time?
  3. Correlate: Do misselections cluster around specific conditions?
    • High context utilization → context overflow contributing
    • Specific prompt version → prompt regression
    • Specific tool description → ambiguity in description
  4. Test hypothesis: Would the OLD tool description + same context → correct selection?

Step 2B: Prompt Diff Analysis

  1. Identify the prompt template change (git log, deployment history)
  2. Diff old vs. new prompt content
  3. For each changed section:
    • Was meaning preserved or altered?
    • Was specificity maintained? (vague descriptions → ambiguous tool selection)
    • Was the change tested with representative inputs?
  4. Rate impact: { section, before, after, impact }

Step 2C: Context Window Analysis

  1. Measure context utilization on failing vs. succeeding conversations:
    • failingAvg vs. succeedingAvg → significant difference?
  2. Check token budget:
    • usedTokens / maxTokens > 0.8 → "high utilization zone"
    • LLMs lose precision on tool selection under high context load
  3. Identify what's filling the context:
    • System prompt (fixed cost)
    • Conversation history (growing cost)
    • Tool definitions (fixed cost per tool)
    • Retrieved context (variable cost)

Step 2D: Output Format Audit

  1. Collect raw LLM outputs that failed parsing
  2. Compare against expected format (JSON schema, XML, markdown)
  3. Classify failure:
    • Structural (missing braces, unclosed tags)
    • Schema (wrong field names, wrong types)
    • Content (correct structure, wrong values)
  4. Correlate with context utilization and prompt version

Step 3: Produce Evidence

Return LLMEvidence to conductor:

{
  "toolCalls": [
    { "tool": "send_email", "params": {"to": "customer"}, "success": true, "expected": "make_call" }
  ],
  "promptDiffs": [
    { "section": "make_call description", "before": "Initiate outbound phone call", "after": "Reach out via voice channel", "impact": "Ambiguity increase" }
  ],
  "contextUsage": { "promptTokens": 108000, "maxTokens": 128000, "utilization": 0.84 },
  "parsingFailures": []
}

Plus standard evidence wrapper:

  • Supporting: Evidence pointing toward root cause
  • Disconfirming: Evidence that complicates or contradicts
  • Confidence: Based on correlation strength and reproduction
  • Verdict: What the LLM investigation suggests

Stop Conditions

  • Root cause identified (prompt change + condition → failure)
  • 3 evidence items collected
  • Token budget exhausted
  • Wall-clock limit (5 minutes)

Escalation Conditions

  • Nondeterministic failures (same input → different outputs) → flag as seed/temperature issue
  • Silent failures (no errors, wrong behavior) → flag as "hard to detect in production"
  • Multiple contributing factors (prompt + context + tool description) → flag as compound root cause

Common Patterns This Investigator Detects

PatternEvidence Shape
Ambiguous tool descriptionMisselections cluster around specific tool; description is vague
Context window pressureMisselections correlate with high utilization (>80%)
Prompt regressionBehavior change correlates with prompt template deployment
Tool argument hallucinationTool called with plausible but fabricated parameters
Format driftOutput structure degrades under high context load
Compound failure2+ factors required together (e.g., ambiguous description + high context)

Failure Modes

ModeSymptomRecovery
Prompt red herringBlaming prompt when model changedCheck model version and deployment first
Context window overflowSubtle truncation not detectedMeasure actual token count vs limit
Non-determinismCannot reproduce intermittent failureRun multiple trials, report distribution

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.