Command Palette

Search for a command to run...

UnylyUnyly
Назад к скиллам

reasoning-trace-optimizer

БесплатноЗапускает вложенные скриптыНе проверен

Debug and optimize AI agents by analyzing reasoning traces, context degradation, tool confusion, instruction drift, repeated task failures, and performance…

muratcankoylanот muratcankoylan★ 18 470 звёзд на GitHub

Об этом скилле

Reasoning Trace Optimizer

Debug and optimize AI agents by analyzing their reasoning traces. This skill uses MiniMax M2.1's interleaved thinking to provide deep insight into agent decision-making and generate concrete improvements.

When to Activate

  • Agent reasoning traces need debugging, analysis, or prompt optimization
  • Agent task fails and user wants to understand why
  • User mentions "context degradation", "tool confusion", or "instruction drift"
  • Request to improve agent performance or reduce errors
  • User wants to generate shareable learnings from debugging sessions
  • After repeated failures on similar tasks

Core Concepts

Interleaved Thinking

Unlike standard reasoning models that think once at the start, interleaved thinking allows reasoning BETWEEN each tool interaction. This is critical because:

  1. Long-horizon tasks require maintaining focus across many turns
  2. External perturbations (tool outputs, environment changes) need real-time adaptation
  3. Debugging requires seeing HOW decisions were made, not just WHAT was output

The Optimization Loop

Execute Agent → Capture Traces → Analyze Patterns → Optimize Prompt → Re-run
                                                          ↑____________|

Each iteration improves the prompt based on detected patterns until convergence.

Pattern Detection

Common failure patterns the analyzer detects:

Pattern Description
context_degradation Model loses track of information over long contexts
tool_confusion Model misunderstands tool capabilities or outputs
instruction_drift Model gradually deviates from original instructions
goal_abandonment Model stops pursuing the original goal
circular_reasoning Model repeats similar actions without progress
premature_conclusion Model concludes before completing the task

Usage Modes

Mode 1: M2.1 Agent Debugging

Run a task through M2.1 and analyze its reasoning:

from reasoning_trace_optimizer import TraceCapture, TraceAnalyzer

capture = TraceCapture()
trace = capture.run(
    task="Search for Python tutorials and summarize them",
    system_prompt="You are a research assistant.",
    tools=[search_tool],
    tool_executor=execute_search
)

analyzer = TraceAnalyzer()
analysis = analyzer.analyze(trace)

print(f"Score: {analysis.overall_score}/100")
for pattern in analysis.patterns:
    print(f"Found: {pattern.type.value} - {pattern.suggestion}")

Mode 2: Full Optimization Loop

Automatically iterate until the prompt is optimized:

from reasoning_trace_optimizer import OptimizationLoop, LoopConfig

config = LoopConfig(
    max_iterations=5,
    min_score_threshold=80.0,
)

loop = OptimizationLoop(config=config)
result = loop.run(
    task="Analyze this codebase and suggest improvements",
    initial_prompt="You are a code reviewer.",
    tools=[read_file_tool, search_tool],
    tool_executor=execute_tool
)

print(f"Improved: {result.initial_score} → {result.final_score}")
print(f"Final prompt:\n{result.final_prompt}")

Mode 3: Universal Session Analysis

Analyze any agent's previous thinking (works with Claude, GPT, etc.):

When this skill is activated in Claude Code, it can analyze the current session's thinking blocks to identify issues and suggest improvements.

/reasoning-trace-optimizer analyze-session

Mode 4: Generate Shareable Skills

Convert optimization learnings into reusable Agent Skills:

from reasoning_trace_optimizer import SkillGenerator

generator = SkillGenerator()
skill_path = generator.generate(
    result=loop_result,
    skill_name="web-search-best-practices",
    output_dir="./skills"
)

CLI Commands

# Capture reasoning trace
rto capture "Search for Python tutorials" -s "You are a helpful assistant."

# Analyze a task
rto analyze "Debug this code" -o analysis.txt

# Run optimization loop
rto optimize "Research AI papers" --max-iterations 5 --generate-skill

# Generate skill from artifacts
rto generate-skill my-skill-name --artifacts-dir ./optimization_artifacts

Integration with Claude Code

Auto-trigger on Failure

Add to your hooks to automatically analyze failures:

{
  "hooks": {
    "post_tool_error": {
      "command": "rto analyze-session --last-error"
    }
  }
}

On-demand Analysis

Use the slash command to analyze current session:

/reasoning-trace-optimizer

This will:

  1. Extract thinking blocks from the current session
  2. Identify patterns and issues
  3. Suggest prompt improvements
  4. Optionally update the system prompt

Guidelines

  1. Preserve full context: M2.1 requires full response history including thinking blocks for optimal performance
  2. Use appropriate tools: Define tools clearly with unambiguous descriptions
  3. Set realistic convergence thresholds: 5-10% improvement per iteration is typical
  4. Review generated skills: Auto-
Полный SKILL.md на GitHub

Установить reasoning-trace-optimizer в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

Вложенные файлы

README.mddocs/agentthinking.mddocs/interleavedthinking.mddocs/m2-1.mdexamples/01_basic_capture.pyexamples/02_tool_usage.pyexamples/03_full_optimization.pygenerated_skills/comprehensive-research-agent/SKILL.mdgenerated_skills/comprehensive-research-agent/references/optimization_summary.jsongenerated_skills/comprehensive-research-agent/references/optimized_prompt.txtgenerated_skills/comprehensive-research-agent/references/patterns_found.jsonoptimization_artifacts/final_prompt.txtoptimization_artifacts/iteration_1/analysis.txtoptimization_artifacts/iteration_1/optimization.txtoptimization_artifacts/iteration_1/optimized_prompt.txtoptimization_artifacts/iteration_1/trace.txtoptimization_artifacts/iteration_10/analysis.txtoptimization_artifacts/iteration_10/trace.txtoptimization_artifacts/iteration_2/analysis.txtoptimization_artifacts/iteration_2/optimization.txtoptimization_artifacts/iteration_2/optimized_prompt.txtoptimization_artifacts/iteration_2/trace.txtoptimization_artifacts/iteration_3/analysis.txtoptimization_artifacts/iteration_3/optimization.txtoptimization_artifacts/iteration_3/optimized_prompt.txtoptimization_artifacts/iteration_3/trace.txtoptimization_artifacts/iteration_4/analysis.txtoptimization_artifacts/iteration_4/optimization.txtoptimization_artifacts/iteration_4/optimized_prompt.txtoptimization_artifacts/iteration_4/trace.txtoptimization_artifacts/iteration_5/analysis.txtoptimization_artifacts/iteration_5/optimization.txtoptimization_artifacts/iteration_5/optimized_prompt.txtoptimization_artifacts/iteration_5/trace.txtoptimization_artifacts/iteration_6/analysis.txtoptimization_artifacts/iteration_6/optimization.txtoptimization_artifacts/iteration_6/optimized_prompt.txtoptimization_artifacts/iteration_6/trace.txtoptimization_artifacts/iteration_7/analysis.txtoptimization_artifacts/iteration_7/optimization.txt

FAQ

Что делает скилл reasoning-trace-optimizer?

Debug and optimize AI agents by analyzing reasoning traces, context degradation, tool confusion, instruction drift, repeated task failures, and performance regressions.

Как установить скилл reasoning-trace-optimizer?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл reasoning-trace-optimizer запускает скрипты?

Да, скилл несёт исполняемые скрипты. Проверь исходник перед установкой.

Похожие скиллы

Сравнить reasoning-trace-optimizer с