Skip to content

Commit a2ae40a

Browse files
authored
refactor(cot_agent): improve ReAct prompt clarity and format specification (#2478)
- Simplify format instructions for better LLM understanding - Clarify when to use Action: vs FinalAnswer: prefixes - Add multi-parameter example in action_input format - Fix misleading 'always json' requirement in prompt - Optimize prompt structure for better tool call accuracy
1 parent e44b79d commit a2ae40a

File tree

2 files changed

+14
-18
lines changed

2 files changed

+14
-18
lines changed

agent-strategies/cot_agent/manifest.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
version: 0.0.30
1+
version: 0.0.31
22
type: plugin
33
author: "langgenius"
44
name: "agent"

agent-strategies/cot_agent/prompt/template.py

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,13 @@
1818
1919
Follow this format:
2020
21-
Question: input question to answer
22-
Thought: consider previous and subsequent steps
23-
Action: $JSON_BLOB
24-
Observation: action result
25-
... (repeat Thought/Action/Observation N times)
26-
Thought: I know what to respond
27-
FinalAnswer: final response to human
28-
29-
Begin! Reminder to ALWAYS respond with a valid json blob of a single action. Use tools if necessary. Respond directly if appropriate. Format is Action: $JSON_BLOB then Observation:.
21+
Thought: [your reasoning]
22+
Action: {"action": "tool_name", "action_input": {"param": "value"}}
23+
Observation: [tool output]
24+
... (repeat as needed)
25+
FinalAnswer: [your response]
26+
27+
Begin! Use "Action:" only when calling tools. End with "FinalAnswer:".
3028
{{historic_messages}}
3129
Question: {{query}}
3230
{{agent_scratchpad}}
@@ -56,15 +54,13 @@
5654
5755
Follow this format:
5856
59-
Question: input question to answer
60-
Thought: consider previous and subsequent steps
61-
Action: $JSON_BLOB
62-
Observation: action result
63-
... (repeat Thought/Action/Observation N times)
64-
Thought: I know what to respond
65-
FinalAnswer: final response to human
57+
Thought: [your reasoning]
58+
Action: {"action": "tool_name", "action_input": {"param": "value"}}
59+
Observation: [tool output]
60+
... (repeat as needed)
61+
FinalAnswer: [your response]
6662
67-
Begin! Reminder to ALWAYS respond with a valid json blob of a single action. Use tools if necessary. Respond directly if appropriate. Format is Action: $JSON_BLOB then Observation:.
63+
Begin! Use "Action:" only when calling tools. End with "FinalAnswer:".
6864
""" # noqa: E501
6965

7066

0 commit comments

Comments
 (0)