Skip to content

Commit a00acfe

Browse files
committed
feat:增加文件链接验证以判断目标是否完成
1 parent 90faa57 commit a00acfe

2 files changed

Lines changed: 19 additions & 11 deletions

File tree

agents/matmaster_agent/flow_agents/agent.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -809,8 +809,10 @@ async def _run_research_flow(
809809
yield _plan_execute_event
810810

811811
# 回顾历史执行
812+
history_steps = ctx.session.state[HISTORY_STEPS]
813+
session_files = await get_session_files(ctx.session.id)
812814
self.all_finished_agent.instruction = create_all_finished_instruction(
813-
ctx.session.state[HISTORY_STEPS]
815+
history_steps, session_files
814816
)
815817
async for _all_finished_event in self.all_finished_agent.run_async(ctx):
816818
yield _all_finished_event
Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,20 @@
11
import json
22

33

4-
def create_all_finished_instruction(history_steps):
4+
def create_all_finished_instruction(history_steps, session_files):
55
"""
66
Build an instruction prompt for an agent that decides whether the user's overall goal
77
has been completed up to the current point in the tool-call history.
8-
98
The agent must output a structured JSON:
109
{"finished": bool, "reason": str}
1110
"""
1211
history_text = json.dumps(history_steps, ensure_ascii=False, indent=2)
12+
session_files_text = json.dumps(session_files, ensure_ascii=False, indent=2)
1313

1414
return f"""
1515
You are a "Goal Completion Judge" agent. Your task is to determine whether the user's
1616
overall final objective/task has been completed *as of now*, based solely on the provided
17-
tool-call history: history_steps.
18-
17+
tool-call history: history_steps and the provided session_files list.
1918
# Input
2019
history_steps is a list. Each element is a past tool invocation record, typically including
2120
(but not limited to):
@@ -24,27 +23,34 @@ def create_all_finished_instruction(history_steps):
2423
- status: the step status (e.g., success/failed/running/cancelled/unknown, etc.)
2524
- other fields: such as result/output/error/args/time, etc.
2625
26+
session_files is a list of file links (OSS URLs). Only files that were actually generated
27+
and persisted for this session will appear here. Use session_files as verifiable evidence
28+
that a file deliverable truly exists.
29+
2730
Below is the raw history_steps data (JSON):
2831
{history_text}
2932
33+
Below is the raw session_files data (JSON):
34+
{session_files_text}
35+
3036
# Decision Rules (must follow)
3137
1) Use "whether the user's final goal is achieved" as the ONLY criterion, not whether all steps were executed.
3238
2) If there is clear evidence that the final deliverable/final outcome has been produced and is usable, set finished=true.
39+
- For file deliverables, you MUST verify the file exists by checking that an appropriate OSS link is present in session_files.
3340
3) If any critical step failed, is missing, is still running, or the outputs are insufficient to prove goal completion, set finished=false.
34-
4) If the information in history_steps is insufficient to confirm completion (e.g., no final output, only partial logs),
41+
4) If the information in history_steps and session_files is insufficient to confirm completion (e.g., no final output, only partial logs,
42+
or expected output file link is not present in session_files),
3543
you MUST return finished=false and explain what information is missing in reason.
3644
5) If there are contradictions in history_steps, prefer the later entries. If you still cannot decide, return finished=false
3745
and explain the contradiction in reason.
38-
6) Do NOT assume results that are not explicitly supported by history_steps. Judge only from verifiable evidence.
39-
46+
6) Do NOT assume results that are not explicitly supported by history_steps or session_files. Judge only from verifiable evidence.
4047
# Output Format (very important)
4148
You must output ONLY ONE JSON object that strictly matches this schema:
4249
{{
4350
"finished": true|false,
44-
"reason": "A brief, specific explanation in English that cites key evidence from history_steps (e.g., a tool_name status/output). If not finished, state the critical blocking reason(s) or missing info."
51+
"reason": "A brief, specific explanation in English that cites key evidence from history_steps and/or session_files (e.g., a tool_name status/output or the presence/absence of an OSS link). If not finished, state the critical blocking reason(s) or missing info."
4552
}}
46-
4753
# Output Constraints
4854
- Output ONLY valid JSON (no Markdown, no code fences, no extra commentary).
49-
- reason must be an English string and should reference concrete evidence from history_steps.
55+
- reason must be an English string and should reference concrete evidence from history_steps and/or session_files.
5056
""".strip()

0 commit comments

Comments
 (0)