Make ordering of fields expected by research planner consistent

Make research planner consistently select tool before query. As the
model should tune it's query for the selected tool. It got space to
think about tool to use in the scratchpad already.
This commit is contained in:
Debanjum
2025-04-04 09:42:13 +05:30
parent 443c5a4420
commit 38dd02afbf
2 changed files with 6 additions and 4 deletions

View File

@@ -770,7 +770,7 @@ Which of the tool AIs listed below would you use to answer the user's question?
Return the next tool AI to use and the query to ask it. Your response should always be a valid JSON object. Do not say anything else.
Response format:
{{"scratchpad": "<your_scratchpad_to_reason_about_which_tool_to_use>", "query": "<your_detailed_query_for_the_tool_ai>", "tool": "<name_of_tool_ai>"}}
{{"scratchpad": "<your_scratchpad_to_reason_about_which_tool_to_use>", "tool": "<name_of_tool_ai>", "query": "<your_detailed_query_for_the_tool_ai>"}}
""".strip()
)

View File

@@ -41,11 +41,9 @@ logger = logging.getLogger(__name__)
class PlanningResponse(BaseModel):
"""
Schema for the response from planning agent when deciding the next tool to pick.
The tool field is dynamically validated based on available tools.
"""
scratchpad: str = Field(..., description="Reasoning about which tool to use next")
query: str = Field(..., description="Detailed query for the selected tool")
scratchpad: str = Field(..., description="Scratchpad to reason about which tool to use next")
class Config:
arbitrary_types_allowed = True
@@ -56,6 +54,9 @@ class PlanningResponse(BaseModel):
Factory method that creates a customized PlanningResponse model
with a properly typed tool field based on available tools.
The tool field is dynamically generated based on available tools.
The query field should be filled by the model after the tool field for a more logical reasoning flow.
Args:
tool_options: Dictionary mapping tool names to values
@@ -68,6 +69,7 @@ class PlanningResponse(BaseModel):
# Create and return a customized response model with the enum
class PlanningResponseWithTool(PlanningResponse):
tool: tool_enum = Field(..., description="Name of the tool to use")
query: str = Field(..., description="Detailed query for the selected tool")
return PlanningResponseWithTool