建立 Provider 推理旁路契约

为 LlmStreamDelta 和 LlmRunResponse 增加独立 reasoning 字段

新增默认关闭的 reasoning 捕获开关并保持请求体不变

补齐 AGC、api-server 和 handoff 构造点及第一轮验收计划
This commit is contained in:
2026-09-14 11:42:19 +08:00
parent 33336d6242
commit 6ab7047eff
17 changed files with 152 additions and 0 deletions
@@ -0,0 +1,67 @@
# 【实施计划】Provider 推理契约与兼容开关
| 字段 | 值 |
| --- | --- |
| Milestone | `docs/project-memory/plans/【里程碑】Provider推理与正文分离及策划Agent展示-2026-09-14.md` |
| Status | awaiting-review |
| Owner | Codex |
## 修改边界
允许修改:
- `server-rs/crates/platform-llm/src/lib.rs` 中的 Provider 请求/响应共享类型;
- 受新增字段影响的 Rust 构造点和测试辅助函数;
- 与共享字段语义直接相关的单元测试;
- 本实施计划文档。
明确不修改:
- Responses / Chat reasoning 解析逻辑;
- `design_runtime.rs`、Tauri 事件和前端 UI;
- GameAgent 的正文过滤、工具调用和消息展示逻辑;
- HTTP、OpenAPI、SpacetimeDB 和持久化 schema。
## 实现顺序
1. 在 `LlmStreamDelta` 和 `LlmRunResponse` 中增加独立 reasoning 字段,并明确空值语义。
2. 在 `LlmRunRequest` 增加默认关闭的 reasoning 捕获开关,确保既有请求默认行为不变。
3. 补齐共享层及 AGC Rust 侧全部结构体构造点,新增字段统一使用空值。
4. 增加契约级测试,证明默认关闭时正文、工具调用和 finish reason 语义不受影响。
5. 检查 GameAgent 及其它调用方仍只读取正文字段,形成第一轮验收证据。
## 验证命令
```text
cargo test -p platform-llm
cargo test --manifest-path apps/ai-game-creator-shell/src-tauri/Cargo.toml
npm run check:encoding
git diff --check
```
## 风险与回滚点
- 共享结构体字段增加会触及多个构造点;以编译错误和全量搜索确保没有遗漏。
- reasoning 字段只能作为旁路数据,任何正文拼接都不属于本轮范围。
- 若发现现有调用方依赖结构体字段数量或序列化形状,停止扩展并回滚共享契约改动。
- 本轮可整体回退共享类型与构造点提交,不影响既有策划 UI 预留代码。
## 第一轮执行记录
- 已完成:`LlmRunRequest.capture_reasoning` 默认关闭,并提供显式 builder;该字段不会进入 Provider 请求体。
- 已完成:`LlmStreamDelta` 增加独立 reasoning 增量/累计字段;本轮所有现有调用点填空值。
- 已完成:`LlmRunResponse` 增加独立 reasoning 字段;本轮所有现有解析和恢复构造点填空值。
- 已确认:未修改 reasoning 解析逻辑、策划事件、前端 UI、GameAgent 正文过滤和工具调用规则。
### 第一轮验收证据
| 证据 | 结果 |
| --- | --- |
| `cargo test --manifest-path server-rs/Cargo.toml -p platform-llm` | PASS,146 个测试通过 |
| `cargo check --manifest-path apps/ai-game-creator-shell/src-tauri/Cargo.toml --tests` | PASS |
| `cargo fmt --manifest-path server-rs/Cargo.toml --all -- --check` | PASS |
| `cargo fmt --manifest-path apps/ai-game-creator-shell/src-tauri/Cargo.toml -- --check` | PASS |
| `npm run check:encoding` | PASS |
| `git diff --check` | PASS |
第一轮完成后暂停,等待评审通过再进入 Provider reasoning 解析和策划 Runtime 接通。