auto-sync: 2026-05-26 23:26:38
This commit is contained in:
@@ -363,6 +363,10 @@ def scan_trial_error(messages: list) -> list:
|
|||||||
|
|
||||||
def scan_success(messages: list) -> list:
|
def scan_success(messages: list) -> list:
|
||||||
"""Pattern ③: Complex task (5+ tool_use in a session) with no correction."""
|
"""Pattern ③: Complex task (5+ tool_use in a session) with no correction."""
|
||||||
|
# Need at least 4 messages to be meaningful
|
||||||
|
if len(messages) < 4:
|
||||||
|
return []
|
||||||
|
|
||||||
# First check if the session has any corrections
|
# First check if the session has any corrections
|
||||||
has_correction = any(
|
has_correction = any(
|
||||||
m.role == 'user' and match_signals(m.text, CORRECTION_SIGNALS)
|
m.role == 'user' and match_signals(m.text, CORRECTION_SIGNALS)
|
||||||
@@ -379,29 +383,27 @@ def scan_success(messages: list) -> list:
|
|||||||
if len(all_tools) < 5:
|
if len(all_tools) < 5:
|
||||||
return []
|
return []
|
||||||
|
|
||||||
# Find the richest assistant message (most tool_use)
|
# Use the last assistant message as the completion point
|
||||||
best_msg = None
|
last_asst = None
|
||||||
best_count = 0
|
for m in reversed(messages):
|
||||||
for m in messages:
|
if m.role == 'assistant':
|
||||||
if m.role == 'assistant' and len(m.tool_names) > best_count:
|
last_asst = m
|
||||||
best_count = len(m.tool_names)
|
break
|
||||||
best_msg = m
|
if not last_asst:
|
||||||
|
|
||||||
if not best_msg:
|
|
||||||
return []
|
return []
|
||||||
|
|
||||||
ctx_before, ctx_after = get_context(messages, best_msg.idx)
|
ctx_before, ctx_after = get_context(messages, last_asst.idx)
|
||||||
tools = get_tools_in_context(messages, best_msg.idx)
|
tools = get_tools_in_context(messages, last_asst.idx)
|
||||||
|
|
||||||
return [{
|
return [{
|
||||||
'mode': 'success',
|
'mode': 'success',
|
||||||
'timestamp': best_msg.timestamp,
|
'timestamp': last_asst.timestamp,
|
||||||
'trigger_message': best_msg.raw_text_snippet,
|
'trigger_message': last_asst.raw_text_snippet,
|
||||||
'trigger_role': 'assistant',
|
'trigger_role': 'assistant',
|
||||||
'context_before': ctx_before,
|
'context_before': ctx_before,
|
||||||
'context_after': ctx_after,
|
'context_after': ctx_after,
|
||||||
'tool_calls_in_context': tools,
|
'tool_calls_in_context': tools,
|
||||||
'summary': f"复杂任务成功完成,共使用 {len(all_tools)} 次 tool_call"
|
'summary': f"复杂任务成功完成,共使用 {len(all_tools)} 次 tool_call,无用户纠正"
|
||||||
}]
|
}]
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user