[fix] fix overlong steps of thinking and avoid redundant steps after task completion && [add timer] set max time 1h to run the agent
This commit is contained in:
parent
7a9e22d093
commit
e6ed98e53c
@ -109,12 +109,14 @@ class PlanningFlow(BaseFlow):
|
||||
|
||||
# Create a system message for plan creation
|
||||
system_message = Message.system_message(
|
||||
"You are a planning assistant. Your task is to create a detailed plan with clear steps."
|
||||
"You are a planning assistant. Create a concise, actionable plan with clear steps. "
|
||||
"Focus on key milestones rather than detailed sub-steps. "
|
||||
"Optimize for clarity and efficiency."
|
||||
)
|
||||
|
||||
# Create a user message with the request
|
||||
user_message = Message.user_message(
|
||||
f"Create a detailed plan to accomplish this task: {request}"
|
||||
f"Create a reasonable plan with clear steps to accomplish the task: {request}"
|
||||
)
|
||||
|
||||
# Call LLM with PlanningTool
|
||||
|
@ -1,25 +1,27 @@
|
||||
PLANNING_SYSTEM_PROMPT = """
|
||||
You are an expert Planning Agent tasked with solving complex problems by creating and managing structured plans.
|
||||
You are an expert Planning Agent tasked with solving problems efficiently through structured plans.
|
||||
Your job is:
|
||||
1. Analyze requests to understand the task scope
|
||||
2. Create clear, actionable plans with the `planning` tool
|
||||
2. Create a clear, actionable plan that makes meaningful progress with the `planning` tool
|
||||
3. Execute steps using available tools as needed
|
||||
4. Track progress and adapt plans dynamically
|
||||
5. Use `finish` to conclude when the task is complete
|
||||
4. Track progress and adapt plans when necessary
|
||||
5. Use `finish` to conclude immediately when the task is complete
|
||||
|
||||
|
||||
Available tools will vary by task but may include:
|
||||
- `planning`: Create, update, and track plans (commands: create, update, mark_step, etc.)
|
||||
- `finish`: End the task when complete
|
||||
|
||||
Break tasks into logical, sequential steps. Think about dependencies and verification methods.
|
||||
Break tasks into logical steps with clear outcomes. Avoid excessive detail or sub-steps.
|
||||
Think about dependencies and verification methods.
|
||||
Know when to conclude - don't continue thinking once objectives are met.
|
||||
"""
|
||||
|
||||
NEXT_STEP_PROMPT = """
|
||||
Based on the current state, what's your next step?
|
||||
Consider:
|
||||
1. Do you need to create or refine a plan?
|
||||
2. Are you ready to execute a specific step?
|
||||
3. Have you completed the task?
|
||||
Based on the current state, what's your next action?
|
||||
Choose the most efficient path forward:
|
||||
1. Is the plan sufficient, or does it need refinement?
|
||||
2. Can you execute the next step immediately?
|
||||
3. Is the task complete? If so, use `finish` right away.
|
||||
|
||||
Provide reasoning, then select the appropriate tool or action.
|
||||
Be concise in your reasoning, then select the appropriate tool or action.
|
||||
"""
|
||||
|
21
run_flow.py
21
run_flow.py
@ -1,4 +1,5 @@
|
||||
import asyncio
|
||||
import time
|
||||
|
||||
from app.agent.manus import Manus
|
||||
from app.flow.base import FlowType
|
||||
@ -26,12 +27,24 @@ async def run_flow():
|
||||
logger.warning("Skipping empty prompt.")
|
||||
continue
|
||||
logger.warning("Processing your request...")
|
||||
result = await flow.execute(prompt)
|
||||
logger.info(result)
|
||||
|
||||
try:
|
||||
start_time = time.time()
|
||||
result = await asyncio.wait_for(
|
||||
flow.execute(prompt),
|
||||
timeout=3600 # 60 minute timeout for the entire execution
|
||||
)
|
||||
elapsed_time = time.time() - start_time
|
||||
logger.info(f"Request processed in {elapsed_time:.2f} seconds")
|
||||
logger.info(result)
|
||||
except asyncio.TimeoutError:
|
||||
logger.error("Request processing timed out after 1 hour")
|
||||
logger.info("Operation terminated due to timeout. Please try a simpler request.")
|
||||
|
||||
except KeyboardInterrupt:
|
||||
logger.warning("Goodbye!")
|
||||
break
|
||||
logger.info("Operation cancelled by user.")
|
||||
except Exception as e:
|
||||
logger.error(f"Error: {str(e)}")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
Loading…
x
Reference in New Issue
Block a user