用途
test-reasoning 用于验证 ReasoningConfig 字段是否被正确序列化为服务商特定的 JSON,涵盖 OpenRouter、Anthropic、GitHub Copilot 和 Codex。当用户需要测试推理序列化、检查 reasoning 参数是否正确发送到服务商 API 时,可使用该技能。
主要能力
它通过捕获 forge 发出的 HTTP 请求体,断言其中包含预期的 JSON 字段,从而验证推理参数的序列化结果。覆盖的服务商、模型与字段包括:
- open_router + openai/o4-mini:effort(none|minimal|low|medium|high|xhigh)对应 reasoning.effort;max_tokens: 4000 对应 reasoning.max_tokens;effort: high + exclude: true 对应 reasoning.effort + .exclude;enabled: true 对应 reasoning.enabled。
- open_router + anthropic/claude-opus-4-5:max_tokens: 4000 对应 reasoning.max_tokens。
- open_router + moonshotai/kimi-k2:max_tokens: 4000 对应 reasoning.max_tokens;effort: high 对应 reasoning.effort。
- open_router + minimax/minimax-m2:max_tokens: 4000 对应 reasoning.max_tokens;effort: high 对应 reasoning.effort。
- anthropic + claude-opus-4-6:effort(low|medium|high|max)对应 output_config.effort。
- anthropic + claude-3-7-sonnet-20250219:enabled: true + max_tokens: 8000 对应 thinking.type + budget_tokens。
- github_copilot + o4-mini:effort(none|minimal|low|medium|high|xhigh)对应顶层 reasoning_effort。
- codex + gpt-5.1-codex:effort(none|minimal|low|medium|high|xhigh)对应 reasoning.effort + .summary;effort: medium + exclude: true 对应 reasoning.summary = "concise"。
- 所有服务商(各取一个模型)+ effort: invalid:非零退出码,不写出请求。
使用方式
使用随附脚本运行全部测试:
./scripts/test-reasoning.sh
该脚本以 debug 模式构建 forge,运行每个服务商/模型组合,通过 FORGE_DEBUG_REQUESTS 捕获发出的 HTTP 请求体,并断言正确的 JSON 字段。
手动运行单个测试:
FORGE_DEBUG_REQUESTS="forge.request.json" \
FORGE_SESSION__PROVIDER_ID=<provider_id> \
FORGE_SESSION__MODEL_ID=<model_id> \
FORGE_REASONING__EFFORT=<effort> \
target/debug/forge -p "Hello!"
然后检查 .forge/forge.request.json 中的预期字段。
适用场景与限制
适用于需要在本地验证各服务商推理参数序列化行为的开发与测试场景。未配置的服务商测试会自动跳过;无效 effort 的测试无论凭据如何都会运行——因为拒绝发生在配置解析阶段,早于任何与服务商的交互。
参考资料
- OpenAI Reasoning guide
- OpenAI Chat Completions API reference
- Anthropic Extended Thinking
- OpenRouter Reasoning Tokens