Show data agent review summaries in sessions
This commit is contained in:
+61
-3
@@ -1118,17 +1118,25 @@ class LocalCodingAgent:
|
||||
if history_entry is not None:
|
||||
file_history.append(history_entry)
|
||||
if tool_result.metadata.get('requires_user_review') is True:
|
||||
review_output = self._build_user_review_required_output(tool_result)
|
||||
review_message_id = f'assistant_{len(session.messages)}'
|
||||
session.append_assistant(
|
||||
review_output,
|
||||
message_id=review_message_id,
|
||||
stop_reason='user_review_required',
|
||||
)
|
||||
stream_events.append(
|
||||
{
|
||||
'type': 'user_review_required',
|
||||
'tool_name': tool_call.name,
|
||||
'tool_call_id': tool_call.id,
|
||||
'message_id': session.messages[tool_message_index].message_id,
|
||||
'review_message_id': review_message_id,
|
||||
'metadata': dict(tool_result.metadata),
|
||||
}
|
||||
)
|
||||
result = AgentRunResult(
|
||||
final_output=self._build_user_review_required_output(tool_result),
|
||||
final_output=review_output,
|
||||
turns=turn_index + 1,
|
||||
tool_calls=tool_calls,
|
||||
transcript=session.transcript(),
|
||||
@@ -1904,10 +1912,60 @@ class LocalCodingAgent:
|
||||
payload = json.loads(tool_result.content)
|
||||
except json.JSONDecodeError:
|
||||
return fallback
|
||||
plan = payload.get('plan') if isinstance(payload, dict) else None
|
||||
if not isinstance(plan, dict):
|
||||
if not isinstance(payload, dict):
|
||||
return fallback
|
||||
goal = payload.get('goal')
|
||||
if isinstance(goal, dict):
|
||||
return self._format_generation_goal_review(goal)
|
||||
plan = payload.get('plan')
|
||||
if isinstance(plan, dict):
|
||||
return self._format_generation_plan_review(plan)
|
||||
return fallback
|
||||
|
||||
def _format_generation_goal_review(self, goal: dict[str, object]) -> str:
|
||||
lines = [
|
||||
'已生成待 review 的数据生成目标,本轮已暂停。',
|
||||
'',
|
||||
f"- goal_id: `{goal.get('goal_id', '')}`",
|
||||
f"- revision: `{goal.get('revision', '')}`",
|
||||
f"- dataset_label: {goal.get('dataset_label', '')}",
|
||||
f"- 目标摘要: {goal.get('goal_summary', '')}",
|
||||
]
|
||||
targets = goal.get('target_definitions')
|
||||
if isinstance(targets, list) and targets:
|
||||
lines.append('- target_definitions:')
|
||||
for item in targets:
|
||||
if isinstance(item, dict):
|
||||
lines.append(
|
||||
f" - {item.get('name', '')}: `{item.get('target', '')}`;规则:{item.get('rule', '')}"
|
||||
)
|
||||
elif goal.get('target'):
|
||||
lines.append(f"- target: `{goal.get('target')}`")
|
||||
if goal.get('plan_hint'):
|
||||
lines.append(f"- 计划提示: {goal.get('plan_hint')}")
|
||||
open_questions = goal.get('open_questions')
|
||||
if isinstance(open_questions, list) and open_questions:
|
||||
lines.append('- 待确认问题:')
|
||||
for item in open_questions:
|
||||
if isinstance(item, str) and item:
|
||||
lines.append(f' - {item}')
|
||||
source_refs = goal.get('source_refs')
|
||||
if isinstance(source_refs, list) and source_refs:
|
||||
lines.append('- 来源:')
|
||||
for item in source_refs:
|
||||
if isinstance(item, str) and item:
|
||||
lines.append(f' - {item}')
|
||||
lines.extend(
|
||||
[
|
||||
f"- 覆盖范围: {goal.get('coverage', '')}",
|
||||
f"- 排除项: {goal.get('exclusions', '')}",
|
||||
'',
|
||||
'请 review 这个生成目标:需要修改就直接回复修改意见;认可的话回复“确认目标”。',
|
||||
]
|
||||
)
|
||||
return '\n'.join(lines)
|
||||
|
||||
def _format_generation_plan_review(self, plan: dict[str, object]) -> str:
|
||||
lines = [
|
||||
'已生成待 review 的数据生成计划,本轮已暂停。',
|
||||
'',
|
||||
|
||||
Reference in New Issue
Block a user