mirror of
https://git.mirrors.martin98.com/https://github.com/bytedance/deer-flow
synced 2025-08-20 05:19:06 +08:00
refactor: add existing research findings into step human message (#140)
This commit is contained in:
parent
d983149984
commit
f73a7a229c
@ -308,17 +308,34 @@ async def _execute_agent_step(
|
|||||||
observations = state.get("observations", [])
|
observations = state.get("observations", [])
|
||||||
|
|
||||||
# Find the first unexecuted step
|
# Find the first unexecuted step
|
||||||
|
current_step = None
|
||||||
|
completed_steps = []
|
||||||
for step in current_plan.steps:
|
for step in current_plan.steps:
|
||||||
if not step.execution_res:
|
if not step.execution_res:
|
||||||
|
current_step = step
|
||||||
break
|
break
|
||||||
|
else:
|
||||||
|
completed_steps.append(step)
|
||||||
|
|
||||||
logger.info(f"Executing step: {step.title}")
|
if not current_step:
|
||||||
|
logger.warning("No unexecuted step found")
|
||||||
|
return Command(goto="research_team")
|
||||||
|
|
||||||
# Prepare the input for the agent
|
logger.info(f"Executing step: {current_step.title}")
|
||||||
|
|
||||||
|
# Format completed steps information
|
||||||
|
completed_steps_info = ""
|
||||||
|
if completed_steps:
|
||||||
|
completed_steps_info = "# Existing Research Findings\n\n"
|
||||||
|
for i, step in enumerate(completed_steps):
|
||||||
|
completed_steps_info += f"## Existing Finding {i+1}: {step.title}\n\n"
|
||||||
|
completed_steps_info += f"<finding>\n{step.execution_res}\n</finding>\n\n"
|
||||||
|
|
||||||
|
# Prepare the input for the agent with completed steps info
|
||||||
agent_input = {
|
agent_input = {
|
||||||
"messages": [
|
"messages": [
|
||||||
HumanMessage(
|
HumanMessage(
|
||||||
content=f"#Task\n\n##title\n\n{step.title}\n\n##description\n\n{step.description}\n\n##locale\n\n{state.get('locale', 'en-US')}"
|
content=f"{completed_steps_info}# Current Task\n\n## title\n\n{current_step.title}\n\n## description\n\n{current_step.description}\n\n## locale\n\n{state.get('locale', 'en-US')}"
|
||||||
)
|
)
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@ -340,8 +357,8 @@ async def _execute_agent_step(
|
|||||||
logger.debug(f"{agent_name.capitalize()} full response: {response_content}")
|
logger.debug(f"{agent_name.capitalize()} full response: {response_content}")
|
||||||
|
|
||||||
# Update the step with the execution result
|
# Update the step with the execution result
|
||||||
step.execution_res = response_content
|
current_step.execution_res = response_content
|
||||||
logger.info(f"Step '{step.title}' execution completed by {agent_name}")
|
logger.info(f"Step '{current_step.title}' execution completed by {agent_name}")
|
||||||
|
|
||||||
return Command(
|
return Command(
|
||||||
update={
|
update={
|
||||||
|
Loading…
x
Reference in New Issue
Block a user