Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 6 additions & 11 deletions agents/matmaster_agent/flow_agents/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -425,18 +425,13 @@ async def _run_async_impl(
available_tools = get_tools_list(ctx, scenes)
if not available_tools:
available_tools = ALL_AGENT_TOOLS_LIST
available_tools_with_info = {
item: {
'scene': ALL_TOOLS[item]['scene'],
'description': ALL_TOOLS[item]['description'],
}
for item in available_tools
}
available_tools_with_info_str = '\n'.join(
[
f"{key}\n scene: {', '.join(value['scene'])}\n description: {value['description']}"
for key, value in available_tools_with_info.items()
]
f"{tool}\n"
f" scene: {', '.join(ALL_TOOLS[tool]['scene'])}\n"
f" description: {ALL_TOOLS[tool]['description']}\n"
f" needs_file_input: {ALL_TOOLS[tool].get('needs_file_input', None)}\n"
f" generates_file_output: {ALL_TOOLS[tool].get('generates_file_output', None)}\n"
for tool in available_tools
)
self.plan_make_agent.instruction = get_plan_make_instruction(
available_tools_with_info_str
Expand Down
36 changes: 28 additions & 8 deletions agents/matmaster_agent/flow_agents/plan_make_agent/prompt.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,44 +2,64 @@ def get_plan_make_instruction(available_tools_with_info: str):
return f"""
You are an AI assistant specialized in creating structured execution plans. Analyze user intent and any provided error logs to break down requests into sequential steps.

<User Upload File>
{{upload_file}}

<Available Tools With Info>
{available_tools_with_info}

### TOOL I/O DEPENDENCY RULE (NEW):
Each tool in <Available Tools With Info> includes two boolean fields:
- needs_file_input: whether this tool requires a file as input
- generates_file_output: whether this tool produces a file output that can be consumed by later tools

You MUST enforce the following dependency constraint:
- If a step uses a tool where needs_file_input == true, then at least one of the following must be true:
1) The user has provided an uploaded file: <User Upload File> upload_file == true
OR
2) There exists a preceding step whose tool has generates_file_output == true, meaning it can produce the required file input.

If neither condition is satisfied, you must still create the step (per “Create a step for EVERY discrete action”), but set tool_name to null and explain in:
- description: what file input is missing and what would be needed
- feasibility: why this step is not currently executable given the dependency rule

### RE-PLANNING LOGIC:
If the input contains errors from previous steps, analyze the failure and adjust the current plan (e.g., fix parameters or change tools) to resolve the issue. Mention the fix in the "description".
Additionally, when re-planning, verify that any needs_file_input step is still backed by either upload_file == true or a prior generates_file_output step.

Return a JSON structure with the following format:
{{
"steps": [
{{
"tool_name": <string>, // Name of the tool to use (exact match from available list). Use null if no suitable tool exists
"description": <string>, // Clear explanation of what this tool call will accomplish
"feasibility", // Clear evidence that the preceding step or user input supports the execution of the step. Or why is there no tool support for this step
"tool_name": <string>, // Name of the tool to use (exact match from available list). Use null if no suitable tool exists or dependency constraints cannot be satisfied
"description": <string>, // Clear explanation of what this tool call will accomplish (include any parameter/configuration details here)
"feasibility": <string>, // Evidence that prior steps or user input support this step, including file I/O dependency satisfaction, OR explain why no tool/support exists
"status": "plan" // Always return "plan"
}}
]
}}

CRITICAL GUIDELINES:
1. Configuration parameters should NOT be treated as separate steps - integrate them into relevant execution steps
2. **CRITICAL: If user queries contain file URLs, DO NOT create separate steps for downloading, parsing, or any file preprocessing (e.g., "download and prepare structure", "prepare input structure"). Treat file URLs as direct inputs to relevant end-processing tools.**
2. **CRITICAL: If user queries contain file URLs, DO NOT create separate steps for downloading, parsing, or any file preprocessing. Treat file URLs as direct inputs to relevant end-processing tools.**
3. **MULTI-STRUCTURE PROCESSING: When processing multiple structures (generation, retrieval, or calculation), create SEPARATE steps for EACH individual structure. Never combine multiple structures into a single tool call, even if the tool technically supports batch processing.**
4. Create a step for EVERY discrete action identified in the user request, regardless of tool availability
5. Use null for tool_name only when no appropriate tool exists in the available tools list
5. Use null for tool_name only when no appropriate tool exists in the available tools list OR when required dependencies (e.g., needs_file_input) are not satisfied
6. Never invent or assume tools - only use tools explicitly listed in the available tools
7. Match tools precisely to requirements - if functionality doesn't align exactly, use null
8. Ensure steps array represents the complete execution sequence for the request

EXECUTION PRINCIPLES:
- Make sure that the previous steps can provide the input information required for the current step, such as the file URL
- Make sure that the previous steps can provide the input information required for the current step (including the file I/O dependency rule)
- Configuration parameters should be embedded within the step that uses them, not isolated as standalone steps
- **File URLs should be treated as direct inputs to processing tools - no separate download, parsing, or preparation steps**
- **Assume processing tools can handle URLs directly and include all necessary preprocessing capabilities**
- **Skip any intermediate file preparation steps - go directly to the core processing task**
- **For multiple structures: Always use one step per structure per operation type (generation → structure1, generation → structure2; retrieval → structure1, retrieval → structure2; etc.)**
- **Maintain strict sequential processing: complete all operations for one structure before moving to the next, or group by operation type across all structures**
- **For multiple structures: Always use one step per structure per operation type**
- **Maintain strict sequential processing**
- Prioritize accuracy over assumptions
- Maintain logical flow in step sequencing
- Ensure descriptions clearly communicate purpose
- Validate tool compatibility before assignment
- Validate tool file I/O compatibility before assignment (needs_file_input / generates_file_output)
"""
2 changes: 2 additions & 0 deletions agents/matmaster_agent/sub_agents/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -1733,5 +1733,7 @@
'alternative': [],
'bypass_confirmation': True,
'self_check': False,
'needs_file_input': True,
'generates_file_output': False,
},
}
Loading