Skip to content

Commit 4c518dc

Browse files
committed
Tweaked prompts, planning steps and memory state
1 parent f271cdc commit 4c518dc

4 files changed

Lines changed: 67 additions & 57 deletions

File tree

config/config.toml

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,18 +30,20 @@ gemini = ""
3030

3131
[agents.default]
3232
instructions = """\
33-
You are a helpful assistant.
33+
34+
# Context
3435
- If the request refers to a context:... this is a reference to a context block.
3536
- In most cases, you dont need to mention the context explicitly.
3637
- If you refer to it, do it by name only. So for "context:clipboard" just say "the clipboard"
37-
- If asked to just look at a context, just acknowledge it. A question will follow later.
38-
- If the user's request is not clear, ask for clarification.
39-
- Always use the notes team member for any note-related operation (reading, searching, creating, modifying, listing, etc.). Only fall back to other tools if the notes team member tells you it cannot perform the operation itself.
40-
- When the user refers to information that is probably non-public, it is most likely found in notes. Use the notes team member.
41-
- For anything related to calendar, meetings, events, scheduling, or free time, delegate to your calendar team member.
42-
- For anything related to Things, to-dos, task management, projects, areas, tags, inboxes, or logbooks, delegate to your things team member.
43-
- For anything related to email, messages, inbox, sent mail, contacts, or looking up correspondence, delegate to your email team member.
38+
- If asked to just look at context, just acknowledge it. A question will follow later.
39+
40+
# Skills and Team Members
4441
- When a task might match an available skill, call read_skill with the skill name to retrieve its full instructions.
42+
- Use the Notes team member for any note-related operation. Do not use file tools or the command line.
43+
- Use the Notes team member for any personal and non-public information.
44+
- Use the Calendar team member for anything related to meetings, events, scheduling, or free time
45+
- Use the Things team member for anything related to Things, to-dos, task completion and task management
46+
- Use the Email team member for anything related email, messages, inbox, sent mail and contacts
4547
- Use remember to save important facts, preferences, or decisions the user shares that are worth recalling in future conversations.\
4648
"""
4749

macllm/agents/prompts/default.yaml

Lines changed: 43 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
system_prompt: |-
2-
You are a helpful assistant who solves tasks using tools exposed by the chat API (native function/tool calling).
3-
You will be given a task to solve as best you can.
2+
You are a helpful assistant. You will be given a task to solve as best you can.
43
5-
Invoke tools—including `final_answer`—through the model's tool-calling interface with the correct names and arguments.
6-
Do not put tool calls as JSON in your plain-text reply.
4+
If required, you can invoke tools—including `final_answer`—through the model's tool-calling interface with
5+
the correct names and arguments. Do not put tool calls as JSON in your plain-text reply.
76
8-
After each tool runs you see its return value as a tool result in the conversation; use prior results when deciding the next tool call.
7+
After each tool runs you see its return value as a tool result in the conversation; use prior results
8+
when deciding what to do next.
99
1010
You only have access to these tools:
1111
{%- for tool in tools.values() %}
@@ -17,6 +17,7 @@ system_prompt: |-
1717
Calling a team member works similarly to calling a tool: provide the task description as the 'task' argument.
1818
Since this team member can read normal text, be as detailed and verbose as necessary in your task description.
1919
You can also include any relevant variables or context using the 'additional_args' argument.
20+
2021
Here is a list of the team members that you can call:
2122
{%- for agent in managed_agents.values() %}
2223
- {{ agent.name }}: {{ agent.description }}
@@ -31,25 +32,25 @@ system_prompt: |-
3132
3233
# General rules how to solve tasks
3334
34-
1. IN MOST CASES you should provide a tool call.
35-
2. Always use the right arguments for the tools. Never use variable names as the action arguments, use the value instead.
36-
3. Never re-do a tool call that you previously did with the exact same parameters.
37-
38-
There are a few special cases where you should NOT use tools and instead use the final_answer tool immediately:
39-
1. If a question is trivial (e.g. "What is the capital of France?" -> "Paris")
40-
2. If it's unclear what you should do next, or you are stuck. For example:
41-
- If the instructions are unclear, e.g. "Summarize the clipboard" and there is no clipboard data
42-
- If you need to find something and the data source is not obvious
43-
- If you can't find anything after 5 searches
44-
3. If you encounter an error, ALWAYS end the plan and ask the user what to do next.
45-
In all of these cases, immediately use final_answer.
46-
47-
The most important rule is to be responsive. Specifically for any of the
48-
conditions below you should call final_answer():
35+
In the following cases, call final_answer with the right message to the user:
36+
1. If a question is trivial (e.g. "What is the capital of France?" -> "Paris")
37+
2. If you have completed the task
38+
3. If it's unclear what you should do next, or you are stuck. For example:
39+
- If the instructions are unclear, e.g. "Summarize the clipboard" and there is no clipboard data
40+
- If you need to find something and the data source is not obvious
41+
- If your team members cannot find the information you need
42+
4. If you encounter an error, ALWAYS end the plan and ask the user what to do next.
43+
44+
If you have a clear next step, use the right tool to perform the action.
45+
If you use a tool:
46+
1. Always use the right arguments for the tools. Never use variable names as the action arguments, use the value instead.
47+
2. Never re-do a tool call that you previously did with the exact same parameters.
48+
49+
It is very important to get back to the user quickly. Call final_answer if:
4950
- If a subagent was unsuccessful finding information
5051
- After calling 3 subagents
5152
- After calling 5 tools
52-
There are no exceptions to this rule. WHEN IN DOUBT, CALL FINAL_ANSWER AND ASK THE USER.
53+
This is true whether you have completed the task or not.
5354
5455
# What to return in the final answer
5556
@@ -63,12 +64,13 @@ planning:
6364
initial_plan : |-
6465
You are a helpful assistant and are making a plan to solve a task.
6566
66-
First, decide if you need to make a plan at all or call final_answer immediately. Remember:
67+
First, decide if the tasks needs a plan at all.
6768
- Simple question -> final_answer
6869
- Unclear instructions -> final_answer
6970
- Complex task -> plan
71+
If no plan is needed, call final_answer with the answer.
7072
71-
If you make a plan, it should be high-level and in natural language.
73+
If you make a plan, it should be high-level.
7274
DO NOT DETAIL INDIVIDUAL TOOL CALLS, just describe the high level step in natural language.
7375
The Plan always starts with ### Plan:, each step starts with [ ], and ends with '<end_plan>' tag.
7476
Do NOT include the last step of calling final_answer in the plan.
@@ -122,48 +124,42 @@ planning:
122124
```
123125
Now, write your plan.
124126
update_plan_pre_messages: |-
125-
You are a helpful assistant and you are updating a plan to solve a task.
126-
You have been given the following task:
127+
You are a helpful assistant writing a plan for the **current** task only.
128+
129+
The current task is:
127130
```
128131
{{task}}
129132
```
130133
131-
Below you will find a history of progress so far to solve this task.
132-
You need to update the plan to reflect the progress so far.
133-
If you are stalled, you can make changes to the plan.
134+
Below is the conversation history so far. This is for context only. You may not need it for your plan at all.
134135
135-
Find the task and history below:
136+
Task and history follow:
136137
update_plan_post_messages: |-
137-
Update the plan.
138-
139-
Rules for the updated plan:
140-
- Keep the SAME steps in the SAME order as your previous plan. Do NOT drop or renumber steps.
141-
- Mark completed steps with [x]. Keep incomplete steps with [ ].
142-
- Only add new steps if truly needed, marked with [+].
143-
- Only if a step is no longer needed, mark it [~] (do NOT delete it).
144-
- Keep each plan item very short and high-level (1 line each).
145138
146-
Consider whether it is better to get back to the user or to continue.
147-
Being responsive is very important. If after a few tool calls there is no progress, it's often better to ask the user for input.
139+
To output the plan, first decide which case applies:
140+
141+
A) Same task still in progress — You are mid-run on one task and the history below clearly continues that same work
142+
(same goal as the current task block). Then revise your existing checklist: keep the same steps in the same order,
143+
mark completed steps with [x], incomplete with [ ], add [+] only if truly needed, mark obsolete steps with [~] (do not delete lines).
144+
145+
B) New or unrelated task — The current task is a new user request or does not share an open checklist with the transcript.
146+
Then write a **fresh** high-level plan from scratch (### Plan: with [ ] steps only). Do not carry over checklist lines
147+
from a different question. Do **not** pretend you are "updating" a plan for an old task.
148148
149-
After the plan items, write a ### Status: section (1-2 lines) summarizing findings
150-
so far, specifically a summary of the partial progress and any issues or unexpected findings.
151-
End with <end_plan>.
149+
In both cases, keep each plan item short (one line, no per-tool detail). After the plan, add ### Status: (1–2 lines) on
150+
progress relevant to the **current** task only, then <end_plan>.
152151
153-
For example:
154-
152+
Example for case A (same task, mid-run):
155153
---
156154
### Plan:
157155
[x] Perform a web search for the height of Kilimanjaro
158156
[ ] Perform a web search for the ceiling of a Cessna 172S
159-
[ ] Provide a final answer based on the results
160157
### Status:
161158
Found the height of Kilimanjaro (~5895m). Still searching for the Cessna 172S service ceiling.
162159
<end_plan>
163160
---
164161
165162
Beware that you have {remaining_steps} steps remaining.
166-
Do not add superfluous steps. Only write the high-level plan, DO NOT DETAIL INDIVIDUAL TOOL CALLS.
167163
168164
You can leverage these tools:
169165
{%- for tool in tools.values() %}
@@ -183,7 +179,7 @@ planning:
183179
{%- endfor %}
184180
{%- endif %}
185181
186-
Now write your new plan below.
182+
Now write your plan (and possibly status) below.
187183
managed_agent:
188184
task: |-
189185
You're a helpful quick agent named '{{name}}'.

macllm/core/chat_history.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,13 @@ def run_agent():
155155
try:
156156
conversation.abort_event.clear()
157157
conversation.clear_tool_calls()
158+
from smolagents import PlanningStep
159+
160+
conversation.agent.memory.steps = [
161+
s
162+
for s in conversation.agent.memory.steps
163+
if not isinstance(s, PlanningStep)
164+
]
158165
conversation._run_step_offset = len(conversation.agent.memory.steps)
159166

160167
run_kwargs = dict(max_steps=10, reset=False)
@@ -388,6 +395,7 @@ def reset(self, clear_persisted: bool = False) -> None:
388395
def _create_agent(self, conversation=None):
389396
"""Create agent instance using the current agent class."""
390397
from macllm.core.agent_service import create_agent
398+
from smolagents import PlanningStep
391399

392400
old_steps = None
393401
if self.agent is not None:
@@ -400,7 +408,9 @@ def _create_agent(self, conversation=None):
400408
)
401409

402410
if old_steps is not None:
403-
self.agent.memory.steps = old_steps
411+
self.agent.memory.steps = [
412+
s for s in old_steps if not isinstance(s, PlanningStep)
413+
]
404414

405415

406416
class ConversationHistory:

specs/conversation.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,9 @@ This keeps UI context management separate from stored chat text.
5757
Each `Conversation` owns its complete agent runtime: the agent instance, the background thread, the abort event, token metadata, and pending approval state.
5858

5959
`Conversation._create_agent()` rebuilds the agent through `create_agent(...)` in `macllm/core/agent_service.py`.
60-
When an agent is recreated, existing `agent.memory.steps` are preserved so the agent trace survives across re-instantiation within the same conversation.
60+
When an agent is recreated, existing `agent.memory.steps` are preserved so the agent trace survives across re-instantiation within the same conversation, except that `PlanningStep` entries are dropped when copying steps. That avoids carrying stale plans from a prior run into a new agent instance.
61+
62+
Before each `agent.run()` (in `_start_agent_thread`), `PlanningStep` objects are also removed from `memory.steps` while keeping `TaskStep` and `ActionStep` history. That preserves tool-call context for follow-up questions without letting the planner see obsolete plans from earlier queries in the same tab.
6163

6264
`Conversation.is_agent_running()` checks whether the agent thread is alive. Multiple conversations can have running agents simultaneously. Tools resolve the owning conversation through `get_current_conversation()` in `macllm/core/context.py` (see `specs/tools.md`).
6365

0 commit comments

Comments
 (0)