新增: LLM目标列表主动修正

This commit is contained in:
lxy
2026-10-05 00:35:01 +08:00
parent 7dea2b86c4
commit c8c13d302a
2 changed files with 157 additions and 2 deletions
+26 -2
View File
@@ -391,6 +391,7 @@ pub(crate) use stall_detector::{
};
pub(crate) use helpers::try_continue_agent_loop;
pub(crate) use helpers::infer_goal_from_tool_calls;
pub(crate) use helpers::extract_update_goals_block;
pub(crate) use helpers::{
tool_call_signature, is_repetitive_exploration, is_write_evidence_tool, is_pure_greeting, is_tool_call_over_limit,
DestructiveLoopSample, destructive_loop_sample, detect_destructive_loop,
@@ -1777,16 +1778,39 @@ async fn finalize_round_output(
);
return RoundEpilogue::Exit;
}
// UPDATE_GOALS 剥离(先于 push):LLM 输出含 [UPDATE_GOALS] 块时,用户看到的
// assistant 消息用剥离后的干净文本(标记是实现细节,不入历史/不推前端)。
let (goals_override, text_to_push): (Option<Vec<(String, bool)>>, String) =
match extract_update_goals_block(full_text) {
Some((goals, cleaned)) => (Some(goals), cleaned),
None => (None, full_text.to_string()),
};
push_assistant_message(
&mut session, conv_id, has_tool_calls, tool_calls_acc,
full_text, resolved_model, last_reasoning_content,
&text_to_push, resolved_model, last_reasoning_content,
round_usage.prompt_tokens, round_usage.completion_tokens,
round_usage.prompt_cache_hit_tokens, round_usage.prompt_cache_miss_tokens,
round_usage.reasoning_tokens,
round_is_estimated,
);
if GOAL_PIN_ENABLED {
update_pinned_goals(&mut session, conv_id, tool_calls_acc);
// UPDATE_GOALS 优先:LLM 显式修正标记存在 → **替换** pinned_goals(纠偏语义),
// 跳过工具推理追加(追加会与本轮显式修正打架)。
if let Some(goals) = goals_override {
let goal_conv = session.conv(conv_id);
goal_conv.pinned_goals = goals
.into_iter()
.map(|(text, active)| {
let mut e = super::GoalEntry::new(text);
if !active {
e.status = super::GoalStatus::Completed;
}
e
})
.collect();
} else {
update_pinned_goals(&mut session, conv_id, tool_calls_acc);
}
}
}