mcpField
A
auto-review-loop-llm

auto-review-loop-llm

github.com/wanshuiyin生产力18.2k504 次安装4 天前更新
代码仓库

关于 auto-review-loop-llm

面向研究项目的自动改进技能,支持任意兼容 OpenAI 的 API。它最多循环四轮外部评审、修复和复审,记录评估结果,并在评分和结论同时达标时停止。

主要功能

  1. 01兼容 OpenAI 的 API 评审
  2. 02评审、修复与复审循环
  3. 03最多四轮迭代
  4. 04持久化轮次状态与记录
  5. 05依据评估结果停止

适用场景

  1. 01投稿前迭代改进研究项目
  2. 02跟踪评审评分和待办事项
  3. 03实施修复后重新评估
  4. 04恢复中断的评审循环

MCP 相关

可用时,技能通过 llm-chat MCP 服务执行外部评审,并将 curl 作为备用方式。

安装

复制下面的命令,在终端中运行。

$npx skills add https://github.com/wanshuiyin/auto-claude-code-research-in-sleep --skill auto-review-loop-llm

安装后在 Claude Code 中输入/auto-review-loop-llm确认已加载。

详细介绍

自动审查循环(通用大模型):自主研究改进

🔒 请勿将此技能包装在 /loop、/schedule 或 CronCreate 中。 与 /auto-review-loop 一样,它已经在内部循环(审查 → 修复 → 再审查), 并将上一轮的摘要传入下一轮审查提示词(后端是无状态的逐轮 API/MCP 调用,而非共享线程)。外部计时器每次触发都会从头开始,丢弃累积的 上下文,并依据墙上时钟而非产物变更触发判定——没有任何新信号,却要付出全部令牌成本。应安排判定前的外部等待,而不是判定本身。参见 shared-references/external-cadence.md。

自主迭代:审查 → 实施修复 → 再审查,直到外部审查者给出正面评价,或达到 MAX_ROUNDS。

上下文:$ARGUMENTS

常量

  • MAX_ROUNDS = 4
  • POSITIVE_THRESHOLD:score >= 6/10 且 verdict ∈ {"ready", "almost"} — 两项都必须满足,与下方实际执行的 STOP 检查一致。Verdict 词汇为 {"ready", "almost", "not ready"}。(早期措辞使用了 or,且 verdict 集合已过时;以 AND 形式为准。)
  • REVIEW_DOC:review-stage/AUTO_REVIEW.md(累计日志)(旧版项目请回退使用 ./AUTO_REVIEW.md)

大模型配置

此技能通过 llm-chat MCP 服务,使用任何兼容 OpenAI 的 API进行外部审查。

通过 MCP 服务配置(推荐)

添加到 ~/.claude/settings.json:

{
  "mcpServers": {
    "llm-chat": {
      "command": "/usr/bin/python3",
      "args": ["/Users/yourname/.claude/mcp-servers/llm-chat/server.py"],
      "env": {
        "LLM_API_KEY": "your-api-key",
        "LLM_BASE_URL": "https://api.deepseek.com/v1",
        "LLM_MODEL": "deepseek-chat"
      }
    }
  }
}
支持的提供商
提供商LLM_BASE_URLLLM_MODEL
OpenAIhttps://api.openai.com/v1gpt-6.1-sol、gpt-6-astra
DeepSeekhttps://api.deepseek.com/v1deepseek-chat、deepseek-reasoner
MiniMaxhttps://api.minimax.io/v1MiniMax-M3
Kimi(Moonshot)https://api.moonshot.cn/v1moonshot-v1-8k、moonshot-v1-32k
智谱(GLM)https://open.bigmodel.cn/api/paas/v4glm-4、glm-4-plus
SiliconFlowhttps://api.siliconflow.cn/v1Qwen/Qwen2.5-72B-Instruct
阿里云百炼https://dashscope.aliyuncs.com/compatible-mode/v1qwen-max
零一万物https://api.lingyiwanwu.com/v1yi-large

llm-chat 服务默认使用 gpt-6.1-sol。如果未设置 LLM_FALLBACK_MODEL,504 超时回退模型将沿用 LLM_MODEL(因此它并非固定的其他模型)。对 api.openai.com 的调用会自动使用 max_completion_tokens;第三方兼容 OpenAI 的端点使用 max_tokens。设置 LLM_MAX_TOKENS_FIELD=max_tokens 或 LLM_MAX_TOKENS_FIELD=max_completion_tokens 可覆盖此自动选择。

API 调用方式

主要方式:MCP 工具

mcp__llm-chat__chat:
  prompt: |
    [Review prompt content]
  model: "deepseek-chat"
  system: "You are a senior ML reviewer..."

备用方式:curl

对于第三方兼容 OpenAI 的端点,请使用 max_tokens:

curl -s "${LLM_BASE_URL}/chat/completions" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer ${LLM_API_KEY}" \
  -d '{
    "model": "${LLM_MODEL}",
    "messages": [
      {"role": "system", "content": "You are a senior ML reviewer..."},
      {"role": "user", "content": "[review prompt]"}
    ],
    "max_tokens": 4096
  }'

对于直接调用 OpenAI,请改用 max_completion_tokens:

curl -s "https://api.openai.com/v1/chat/completions" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer ${LLM_API_KEY}" \
  -d '{
    "model": "gpt-6.1-sol",
    "messages": [
      {"role": "system", "content": "You are a senior ML reviewer..."},
      {"role": "user", "content": "[review prompt]"}
    ],
    "max_completion_tokens": 4096
  }'

状态持久化(紧凑恢复)

每轮结束后,将状态持久化到 review-stage/REVIEW_STATE.json:

{
  "round": 2,
  "status": "in_progress",
  "last_score": 5.0,
  "last_verdict": "not ready",
  "pending_experiments": [],
  "timestamp": "2026-03-15T10:00:00"
}

每个阶段 E 结束时(记录该轮内容后)都要写入此文件。

完成时,将 "status": "completed" 设为完成状态。

工作流

初始化
  1. **检查 review-stage/REVIEW_STATE.json以恢复状态(若未找到,则回退使用 ./REVIEW_STATE.json — 旧版路径)
  2. 阅读项目上下文和先前的审查记录
  3. 初始化轮次计数器
循环(最多 MAX_ROUNDS 轮)
阶段 A:审查

如果 MCP 可用:

mcp__llm-chat__chat:
  system: "You are a senior ML reviewer (NeurIPS/ICML level)."
  prompt: |
    [Round N/MAX_ROUNDS of autonomous review loop]

    [Full research context: claims, methods, results, known weaknesses]
    [Changes since last round, if any]

    1. Score this work 1-10 for a top venue
    2. List remaining critical weaknesses (ranked by severity)
    3. For each weakness, specify the MINIMUM fix
    4. State clearly: is this READY for submission? Yes/No/Almost

    Be brutally honest. If the work is ready, say so clearly.

如果 MCP 不可用: 对于第三方兼容 OpenAI 的端点,请使用 max_tokens;对于直接调用 OpenAI,请改用 max_completion_tokens。

curl -s "${LLM_BASE_URL}/chat/completions" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer ${LLM_API_KEY}" \
  -d '{
    "model": "${LLM_MODEL}",
    "messages": [
      {"role": "system", "content": "You are a senior ML reviewer (NeurIPS/ICML level)."},
      {"role": "user", "content": "[Full review prompt]"}
    ],
    "max_tokens": 4096
  }'
阶段 B:解析评估

**重要:逐字保存完整的原始响应。**然后提取:

  • 分数(数字,范围 1-10)
  • Verdict("ready" / "almost" / "not ready")
  • 待办事项(按优先级排序的修复列表)

停止条件:如果 score >= 6 且 verdict ∈ {"ready", "almost"}(必须完全符合——"not ready" 不符合条件)

阶段 C:实施修复

优先级:新增指标 > 重新构建框架 > 新实验

阶段 D:等待结果

监控远程实验

阶段 E:记录本轮内容

追加到 review-stage/AUTO_REVIEW.md:

## Round N (timestamp)

### Assessment (Summary)
- Score: X/10
- Verdict: [ready/almost/not ready]
- Key criticisms: [bullet list]

### Reviewer Raw Response

<details>
<summary>Click to expand full reviewer response</summary>

[Paste the COMPLETE raw response here — verbatim, unedited.]

</details>

### Actions Taken
- [what was implemented/changed]

### Results
- [experiment outcomes, if any]

### Status
- [continuing to round N+1 / stopping]

编写 review-stage/REVIEW_STATE.json,记录当前状态。

终止
  1. 将 review-stage/REVIEW_STATE.json 的状态设为 "completed"
  2. 编写最终总结

关键规则

  • 处理大型文件:如果 Write 工具因文件过大而失败,请立即使用 Bash(cat << 'EOF' > file)重试,分块写入。不要征求用户许可——直接静默执行。

  • 防止引用幻觉:添加参考文献时,绝不要编造 BibTeX。请依次通过 DBLP → CrossRef → [VERIFY] 核验。不要凭记忆生成 BibTeX。

  • 如实说明不足之处

  • 重新审查前先实施修复

  • 记录所有内容

  • 在第 2 轮及后续轮次的提示词中包含先前上下文

  • 如果有可用的 MCP 工具,优先使用它,而不是 curl

第 2 轮及后续轮次的提示词模板

mcp__llm-chat__chat:
  system: "You are a senior ML reviewer (NeurIPS/ICML level)."
  prompt: |
    [Round N/MAX_ROUNDS of autonomous review loop]

    ## Previous Review Summary (Round N-1)
    - Previous Score: X/10
    - Previous Verdict: [ready/almost/not ready]
    - Previous Key Weaknesses: [list]

    ## Changes Since Last Review
    1. [Action 1]: [result]
    2. [Action 2]: [result]

    ## Updated Results
    [paste updated metrics/tables]

    Please re-score and re-assess:
    1. Score this work 1-10 for a top venue
    2. List remaining critical weaknesses (ranked by severity)
    3. For each weakness, specify the MINIMUM fix
    4. State clearly: is this READY for submission? Yes/No/Almost

    Be brutally honest. If the work is ready, say so clearly.

输出协议

所有输出文件均须遵循以下共享协议:

评论

支持 Markdown