@@ -35,6 +35,7 @@ def multi_agent_reasoning_system(
3535 initial_query : str ,
3636 client ,
3737 model : str ,
38+ request_config : dict = None ,
3839 request_id : str = None
3940) -> Tuple [str , int ]:
4041 """
@@ -51,21 +52,30 @@ def multi_agent_reasoning_system(
5152 Tuple of (final_solution, total_reasoning_tokens)
5253 """
5354 return asyncio .run (_run_mars_parallel (
54- system_prompt , initial_query , client , model , request_id
55+ system_prompt , initial_query , client , model , request_config , request_id
5556 ))
5657
5758async def _run_mars_parallel (
5859 system_prompt : str ,
5960 initial_query : str ,
6061 client ,
6162 model : str ,
63+ request_config : dict = None ,
6264 request_id : str = None
6365) -> Tuple [str , int ]:
6466 """Async implementation of MARS with parallel execution"""
6567 logger .info (f"Starting MARS with model: { model } " )
6668
6769 # Initialize configuration
6870 config = DEFAULT_CONFIG .copy ()
71+
72+ # Override max_tokens from request_config if provided
73+ if request_config and 'max_tokens' in request_config :
74+ config ['max_tokens' ] = request_config ['max_tokens' ]
75+ logger .info (f"Using max_tokens from request: { config ['max_tokens' ]} " )
76+ else :
77+ logger .info (f"Using default max_tokens: { config ['max_tokens' ]} " )
78+
6979 total_reasoning_tokens = 0
7080
7181 # Calculate optimal worker count for parallel execution
@@ -191,6 +201,14 @@ async def generate_solution_async(agent: MARSAgent):
191201 workspace .add_solution (solution )
192202 total_tokens += tokens
193203 successful_solutions += 1
204+
205+ # ENHANCED LOGGING: Log individual agent solution details
206+ logger .info (f"Agent { agent_id } exploration complete:" )
207+ logger .info (f" - Solution length: { solution .solution_length } chars" )
208+ logger .info (f" - Total tokens: { solution .total_tokens } " )
209+ logger .info (f" - Reasoning tokens: { solution .reasoning_tokens } " )
210+ logger .info (f" - Confidence: { solution .confidence :.2f} " )
211+ logger .info (f" - Solution preview: { solution .solution [:200 ]} ..." )
194212 else :
195213 logger .error (f"Agent { agent_id } generated no solution" )
196214
@@ -274,15 +292,22 @@ def _synthesize_final_solution(
274292
275293 # Extract reasoning tokens from correct nested structure (matching agent.py fix)
276294 reasoning_tokens = 0
295+ total_tokens = 0
277296 if hasattr (response , 'usage' ) and response .usage :
297+ total_tokens = getattr (response .usage , 'total_tokens' , 0 )
278298 # Check completion_tokens_details first (OpenRouter structure)
279299 if hasattr (response .usage , 'completion_tokens_details' ) and response .usage .completion_tokens_details :
280300 reasoning_tokens = getattr (response .usage .completion_tokens_details , 'reasoning_tokens' , 0 )
281301 # Fallback to direct usage field (standard OpenAI structure)
282302 if reasoning_tokens == 0 :
283303 reasoning_tokens = getattr (response .usage , 'reasoning_tokens' , 0 )
284304
285- logger .info (f"Synthesis complete with { reasoning_tokens } reasoning tokens" )
305+ # ENHANCED LOGGING: Log synthesis details
306+ logger .info (f"Synthesis complete:" )
307+ logger .info (f" - Synthesis solution length: { len (final_solution )} characters" )
308+ logger .info (f" - Reasoning tokens: { reasoning_tokens } " )
309+ logger .info (f" - Total tokens: { total_tokens } " )
310+ logger .info (f" - Final solution preview: { final_solution [:200 ]} ..." )
286311 return final_solution , reasoning_tokens
287312
288313 except Exception as e :
0 commit comments