Denis Davydov commited on
Commit ·
c80da8b
1
Parent(s): 11d4518
fix redundant question context
Browse files72 unmodified lines737475767778767778799 unmodified lines899091949293949895961019798103104991061071001011021033 unmodified lines10710810911711011111211312211411511672 unmodified lines ) builder.add_edge("tools", "assistant") # Add memory memory = MemorySaver() agent = builder.compile(checkpointer=memory) agent = builder.compile() return agent
9 unmodified lines try: print(f"\n🎯 Processing question: {question[:100]}...") # Create simple execution plan for logging plan = create_execution_plan(question, task_id) print(f"📋 Execution plan: {plan}") # Prepare the question with task_id context if available enhanced_question = question if task_id: enhanced_question = f"Task ID: {task_id}\n\nQuestion: {question}\n\nNote: If this question involves files, use the file_download tool with task_id '{task_id}' to access associated files." enhanced_question = f"Task ID: {task_id}\n\nQuestion: {question}" # Invoke the agent - let GPT-4o decide what tools to use thread_id = f"task-{task_id}" if task_id else "general" config = { "configurable": {"thread_id": thread_id}, "recursion_limit": 15 # Allow more tool usage for complex searches "recursion_limit": 15 } initial_state = {3 unmodified lines result = self.agent.invoke(initial_state, config=config) # Extract the final answer and reasoning trace if result and 'messages' in result and result['messages']: final_message = result['messages'][-1] raw_answer = final_message.content # Build reasoning trace from all messages reasoning_trace = [] for msg in result['messages']: if hasattr(msg, 'content') and msg.content:agent.py+3-12