♻️ refactor(schedule-refine): [WIP] 重构 Plan-and-Execute ReAct 链路,并增强 JSON 解析兜底能力 - 🧩 重构 `schedulerefine` 主流程,引入 `Planner` / `Replan` 机制,以及执行预算与轮次状态管理 - 🧠 扩展状态与观察上下文,补充工具结果、失败签名、连续失败计数与后置反思策略等信息 - 🔧 增强工具层能力与参数兼容性,补齐 `Query` / `Move` / `Swap` / `BatchMove` / `Verify` 等行为及约束校验 - 🛡️ 提升解析鲁棒性,支持从代码块或混杂文本中提取首个 JSON 对象,并增加单次解析重试机制 - 👀 增强可观测性,补充 `debug raw` 阶段输出与分片透传能力 - ✍️ 优化提示词近端约束,将严格 JSON 输出协议追加到各节点 `userPrompt` 末尾 - 🚧 备注:当前链路仍处于持续调优阶段,稳定性与可用性仍需进一步验证
42 lines
1.4 KiB
Go
42 lines
1.4 KiB
Go
package schedulerefine
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/cloudwego/eino-ext/components/model/ark"
|
|
)
|
|
|
|
// scheduleRefineRunner 是“单次图运行”的请求级依赖容器。
|
|
//
|
|
// 职责边界:
|
|
// 1. 负责收口模型与阶段回调,避免 graph.go 出现大量闭包;
|
|
// 2. 负责把节点函数适配为统一签名;
|
|
// 3. 不负责分支决策(当前链路为线性图)。
|
|
type scheduleRefineRunner struct {
|
|
chatModel *ark.ChatModel
|
|
emitStage func(stage, detail string)
|
|
}
|
|
|
|
func newScheduleRefineRunner(chatModel *ark.ChatModel, emitStage func(stage, detail string)) *scheduleRefineRunner {
|
|
return &scheduleRefineRunner{
|
|
chatModel: chatModel,
|
|
emitStage: emitStage,
|
|
}
|
|
}
|
|
|
|
func (r *scheduleRefineRunner) contractNode(ctx context.Context, st *ScheduleRefineState) (*ScheduleRefineState, error) {
|
|
return runContractNode(ctx, r.chatModel, st, r.emitStage)
|
|
}
|
|
|
|
func (r *scheduleRefineRunner) reactNode(ctx context.Context, st *ScheduleRefineState) (*ScheduleRefineState, error) {
|
|
return runReactLoopNode(ctx, r.chatModel, st, r.emitStage)
|
|
}
|
|
|
|
func (r *scheduleRefineRunner) hardCheckNode(ctx context.Context, st *ScheduleRefineState) (*ScheduleRefineState, error) {
|
|
return runHardCheckNode(ctx, r.chatModel, st, r.emitStage)
|
|
}
|
|
|
|
func (r *scheduleRefineRunner) summaryNode(ctx context.Context, st *ScheduleRefineState) (*ScheduleRefineState, error) {
|
|
return runSummaryNode(ctx, r.chatModel, st, r.emitStage)
|
|
}
|