refactor: add existing research findings into step human message (#140)

This commit is contained in:
DanielWalnut 2025-05-14 03:40:14 -07:00 committed by GitHub
parent d983149984
commit f73a7a229c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -308,17 +308,34 @@ async def _execute_agent_step(
observations = state.get("observations", [])
# Find the first unexecuted step
current_step = None
completed_steps = []
for step in current_plan.steps:
if not step.execution_res:
current_step = step
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 = {
"messages": [
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}")
# Update the step with the execution result
step.execution_res = response_content
logger.info(f"Step '{step.title}' execution completed by {agent_name}")
current_step.execution_res = response_content
logger.info(f"Step '{current_step.title}' execution completed by {agent_name}")
return Command(
update={