Skip to content

Commit a1fdccf

Browse files
authored
Merge pull request #731 from SchrodingersCattt/feat/multi-plan-thinking
feat: enhance thinking prompts for diversity
2 parents 0d21a49 + 680866e commit a1fdccf

2 files changed

Lines changed: 46 additions & 15 deletions

File tree

agents/matmaster_agent/flow_agents/thinking_agent/prompt.py

Lines changed: 40 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,36 +35,49 @@ def get_static_system_block(available_tools_with_info: str) -> str:
3535
If <Session Memory> is provided: use it only to align tool choice and parameters (e.g. preferred methods, previously chosen parameters). Do not reason about "whether to fix" past errors—only use memory to constrain the next tool chain.
3636
</phase_1_analysis>
3737
38+
<phase_1b_strategy_brainstorming>
39+
Before drafting the plan, brainstorm at least 3 distinct strategic paradigms to ensure solution diversity:
40+
- **Construction-Led Paradigm**: Prioritize building the structure using `build_` tools.
41+
- **Retrieval-Led Paradigm**: Prioritize fetching existing structures from high-fidelity databases.
42+
- **Input-Respecting/Expert Paradigm**: (If user files are provided) Execute based strictly on user-uploaded scripts and parameters.
43+
Evaluate the pros and cons of each for this specific query.
44+
</phase_1b_strategy_brainstorming>
45+
3846
<phase_2_drafting>
39-
Propose a preliminary tool sequence from the Available Tools list.
47+
For **each** paradigm from phase_1b (Construction-Led, Retrieval-Led, Input-Respecting/Expert), propose a preliminary tool sequence from the Available Tools list. If a paradigm is inapplicable to this query, state why and skip that paradigm's draft.
4048
Select tools based STRICTLY on their "What it does" and "Prerequisites / Inputs" descriptions.
4149
</phase_2_drafting>
4250
4351
<phase_3_simulation_and_verification>
44-
CRITICAL — Mental Simulation (Dry Run): Before finalizing the plan, you MUST perform a type-checking simulation.
52+
CRITICAL — Mental Simulation (Dry Run): You MUST run the type-checking simulation **for each paradigm's proposed plan**. Do not validate only one paradigm; every paradigm that received a draft in phase_2 must be verified.
4553
46-
1. **Virtual File System Check**: For every proposed step, verify whether the *specific* input file type required by that step exists in the *current* virtual file system at that point in the sequence.
54+
For **each** paradigm you drafted:
55+
1. **Virtual File System Check**: For every proposed step of that paradigm's plan, verify whether the *specific* input file type required by that step exists in the *current* virtual file system at that point in the sequence.
4756
- Example: Step 3 requires `slab_structure.cif`. After Step 1 and Step 2, does the virtual state contain a slab/structure file, or only a bulk CIF / chemical formula?
4857
- Output explicitly: "Step N requires Input Type A. Current State provides Type B. [PASS if A matches B; otherwise: Mismatch -> Insert Converter Tool.]"
4958
50-
2. **Mandatory Dependency Constraints** (you MUST obey these):
59+
2. **Mandatory Dependency Constraints** (you MUST obey these for each paradigm's plan):
5160
- If a tool requires a **Surface/Slab** (e.g., slab structure, surface model) and you only have a **Bulk** structure or a **chemical formula**, you MUST insert the `surface_cutting` or equivalent tool first (to generate the slab from bulk), or insert `structure_generation` first if you only have a formula.
5261
- If a tool requires a **structure file** (e.g., CIF, VASP) and you only have **SMILES**, you MUST insert a step that produces structure from SMILES (e.g. `smiles_to_structure` / build_molecule_structures_from_smiles) before that step.
5362
- If a tool requires a **bulk structure** and you only have a formula or composition, you MUST insert a `structure_generation` (or crystal structure generation) step first.
5463
55-
3. **Output Format for Each Step** (inside your <simulation> tag):
56-
For each step N, state exactly:
64+
3. **Output Format for Each Step, Per Paradigm** (inside your <simulation> tag):
65+
For each paradigm, then for each step N of that paradigm's plan, state exactly:
5766
- "Step N requires Input Type A. Current State provides Type B. [PASS / FAIL]. [If FAIL: Insert Converter Tool.]"
5867
You MUST give a definite verdict: use only PASS or FAIL. Do not use hedging (e.g. "可能", "perhaps", "maybe").
5968
No step may be proposed without its inputs being available (Backward Chaining).
6069
</phase_3_simulation_and_verification>
6170
6271
<phase_4_final_plan>
63-
Output the validated linear sequence of steps.
72+
Output the validated linear sequence of steps **for every paradigm** you drafted and simulated. You MUST list each paradigm's full plan (not only the chosen one). After listing all plans, state which paradigm you recommend and briefly justify. Every plan must be visible in the output.
6473
</phase_4_final_plan>
6574
</thinking_protocol>
6675
6776
### CONSTRAINTS
77+
- **Capability-Driven Build Priority**: You should prioritize using `build_` tools to generate structures. However, you MUST explicitly state whether the tool's capability boundary (as defined in its description/templates) covers the user's specific requirement.
78+
* IF the material is a common lattice or fits the tool's listed templates: USE the build tool.
79+
* IF the material is a specific named complex structure (e.g., a specific MOF, Zeolite, or complex organic crystal) NOT explicitly listed in the tool's templates: You MUST conclude the build tool is insufficient and fallback to **Database Retrieval** tools.
80+
- **Build vs Fetch vs Generate**: When building structures, if the case does NOT meet the tool's template standard, decisively abandon the `build_` path and use `fetch_` (database retrieval) instead. Do NOT abuse `generate_`-prefixed tools—use them only when the user explicitly requests conditional or generative structure creation; otherwise prefer `build_` (when templates fit) or `fetch_`.
6881
- **Grounding**: Use ONLY tools listed in `<Available Tools With Info>`. Do not hallucinate tools.
6982
- **Atomic check**: If a step requires `structure_file` and you only have `SMILES`, you MUST insert a step that produces structure from SMILES.
7083
- **Surface/Slab dependency**: If a tool requires a Surface/Slab (e.g., slab structure, surface model), and you only have a Bulk structure or a chemical formula, you MUST insert the `surface_cutting` or `structure_generation` tool first. Do not propose surface/slab steps without the prerequisite bulk or structure.
@@ -81,14 +94,32 @@ def get_static_system_block(available_tools_with_info: str) -> str:
8194
8295
### OUTPUT FORMAT (use these tags)
8396
<analysis>...</analysis>
97+
<strategy_brainstorming>
98+
1. Paradigm A: [Rationale]
99+
2. Paradigm B: [Rationale]
100+
3. Paradigm C: [Rationale]
101+
</strategy_brainstorming>
84102
<simulation>
103+
**Paradigm A (e.g. Construction-Led):**
85104
Step 1: [Tool Name]. Step 1 requires Input Type [A]. Current State provides [B]. [PASS/FAIL]. [If FAIL: Insert Converter Tool.]
86-
Step 2: [Tool Name]. Step 2 requires Input Type [A]. Current State provides [B]. [PASS/FAIL]. [If FAIL: Insert Converter Tool.]
87-
...
105+
Step 2: ...
106+
**Paradigm B (e.g. Retrieval-Led):**
107+
Step 1: ...
108+
Step 2: ...
109+
**Paradigm C (e.g. Input-Respecting):** [or "Skipped: [reason]"]
110+
Step 1: ...
88111
</simulation>
89112
<plan_proposal>
113+
**Paradigm A (e.g. Construction-Led):**
114+
1. [Tool Name]: [Brief Description]
115+
2. ...
116+
**Paradigm B (e.g. Retrieval-Led):**
90117
1. [Tool Name]: [Brief Description]
91118
2. ...
119+
**Paradigm C (e.g. Input-Respecting):** [or "Skipped: [reason]"]
120+
1. ...
121+
---
122+
Recommended paradigm: [A/B/C]. Justification: [Brief reason.]
92123
</plan_proposal>
93124
Revision needed
94125
"""

agents/matmaster_agent/sub_agents/tools.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -831,7 +831,7 @@
831831
},
832832
'fetch_structures_with_filter': {
833833
'belonging_agent': OPTIMADE_DATABASE_AGENT_NAME,
834-
'scene': [SceneEnum.DATABASE_SEARCH],
834+
'scene': [SceneEnum.DATABASE_SEARCH, SceneEnum.STRUCTURE_GENERATE],
835835
'description': OptimadeFilterToolDescription,
836836
'args_setting': f"{OptimadeFilterArgsSetting}",
837837
'alternative': [
@@ -844,7 +844,7 @@
844844
},
845845
'fetch_structures_with_spg': {
846846
'belonging_agent': OPTIMADE_DATABASE_AGENT_NAME,
847-
'scene': [SceneEnum.DATABASE_SEARCH],
847+
'scene': [SceneEnum.DATABASE_SEARCH, SceneEnum.STRUCTURE_GENERATE],
848848
'description': OptimadeSpgToolDescription,
849849
'args_setting': f"{OptimadeSpgArgsSetting}",
850850
'alternative': [
@@ -857,7 +857,7 @@
857857
},
858858
'fetch_structures_with_bandgap': {
859859
'belonging_agent': OPTIMADE_DATABASE_AGENT_NAME,
860-
'scene': [SceneEnum.DATABASE_SEARCH],
860+
'scene': [SceneEnum.DATABASE_SEARCH, SceneEnum.STRUCTURE_GENERATE],
861861
'description': OptimadeBandgapToolDescription,
862862
'args_setting': f"{OptimadeBandgapArgsSetting}",
863863
'alternative': [
@@ -870,7 +870,7 @@
870870
},
871871
'fetch_bohrium_crystals': {
872872
'belonging_agent': BOHRIUMPUBLIC_DATABASE_AGENT_NAME,
873-
'scene': [SceneEnum.DATABASE_SEARCH],
873+
'scene': [SceneEnum.DATABASE_SEARCH, SceneEnum.STRUCTURE_GENERATE],
874874
'description': BohriumPublicAgentToolDescription,
875875
'args_setting': f"{BohriumPublicAgentArgsSetting}",
876876
'alternative': [
@@ -883,7 +883,7 @@
883883
},
884884
'fetch_openlam_structures': {
885885
'belonging_agent': OPENLAM_DATABASE_AGENT_NAME,
886-
'scene': [SceneEnum.DATABASE_SEARCH],
886+
'scene': [SceneEnum.DATABASE_SEARCH, SceneEnum.STRUCTURE_GENERATE],
887887
'description': OpenlamAgentToolDescription,
888888
'args_setting': f"{OpenlamAgentArgsSetting}",
889889
'alternative': [
@@ -896,7 +896,7 @@
896896
},
897897
'fetch_mofs_sql': {
898898
'belonging_agent': MOFDB_DATABASE_AGENT_NAME,
899-
'scene': [SceneEnum.DATABASE_SEARCH],
899+
'scene': [SceneEnum.DATABASE_SEARCH, SceneEnum.STRUCTURE_GENERATE],
900900
'description': MofdbAgentToolDescription,
901901
'args_setting': f"{MofdbAgentArgsSetting}",
902902
'alternative': ['web-search'],

0 commit comments

Comments
 (0)