fix(planner): skip human feedback if context is sufficient

Change-Id: I2b5628a7a8ecb6a6bad2712a9ff81b9b1cd323c6
This commit is contained in:
Zhao Longjie 2025-04-29 18:17:27 +08:00
parent eabf1f2080
commit dab1ba4789
2 changed files with 19 additions and 1 deletions

View File

@ -116,6 +116,24 @@ def planner_node(
logger.debug(f"Current state messages: {state['messages']}") logger.debug(f"Current state messages: {state['messages']}")
logger.info(f"Planner response: {full_response}") logger.info(f"Planner response: {full_response}")
try:
curr_plan = json.loads(repair_json_output(full_response))
except json.JSONDecodeError:
logger.warning("Planner response is not a valid JSON")
if plan_iterations > 0:
return Command(goto="reporter")
else:
return Command(goto="__end__")
if curr_plan.get("has_enough_context"):
logger.info("Planner response has enough context.")
new_plan = Plan.model_validate(curr_plan)
return Command(
update={
"messages": [AIMessage(content=full_response, name="planner")],
"current_plan": new_plan,
},
goto="reporter",
)
return Command( return Command(
update={ update={
"messages": [AIMessage(content=full_response, name="planner")], "messages": [AIMessage(content=full_response, name="planner")],

View File

@ -32,7 +32,7 @@ class Plan(BaseModel):
thought: str thought: str
title: str title: str
steps: List[Step] = Field( steps: List[Step] = Field(
..., default_factory=list,
description="Research & Processing steps to get more context", description="Research & Processing steps to get more context",
) )