@@ -126,15 +126,20 @@ def _process_query_with_cot(self, query: str, analysis: QueryAnalysis) -> Dict[s
126
126
plan = self .agents ["planner" ].plan (query , initial_context )
127
127
logger .info (f"Generated plan:\n { plan } " )
128
128
129
- # Step 2: Research each step
129
+ # Step 2: Research each step (if researcher is available)
130
130
logger .info ("Step 2: Research" )
131
131
research_results = []
132
- for step in plan .split ("\n " ):
133
- if not step .strip ():
134
- continue
135
- step_research = self .agents ["researcher" ].research (query , step )
136
- research_results .append ({"step" : step , "findings" : step_research })
137
- logger .info (f"Research for step: { step } \n Findings: { step_research } " )
132
+ if self .agents ["researcher" ] is not None and initial_context :
133
+ for step in plan .split ("\n " ):
134
+ if not step .strip ():
135
+ continue
136
+ step_research = self .agents ["researcher" ].research (query , step )
137
+ research_results .append ({"step" : step , "findings" : step_research })
138
+ logger .info (f"Research for step: { step } \n Findings: { step_research } " )
139
+ else :
140
+ # If no researcher or no context, use the steps directly
141
+ research_results = [{"step" : step , "findings" : []} for step in plan .split ("\n " ) if step .strip ()]
142
+ logger .info ("No research performed (no researcher agent or no context available)" )
138
143
139
144
# Step 3: Reasoning about each step
140
145
logger .info ("Step 3: Reasoning" )
@@ -143,7 +148,7 @@ def _process_query_with_cot(self, query: str, analysis: QueryAnalysis) -> Dict[s
143
148
step_reasoning = self .agents ["reasoner" ].reason (
144
149
query ,
145
150
result ["step" ],
146
- result ["findings" ]
151
+ result ["findings" ] if result [ "findings" ] else [{ "content" : "Using general knowledge" , "metadata" : { "source" : "General Knowledge" }}]
147
152
)
148
153
reasoning_steps .append (step_reasoning )
149
154
logger .info (f"Reasoning for step: { result ['step' ]} \n { step_reasoning } " )
0 commit comments