Skip to content

Commit 0efef3c

Browse files
committed
feat: enhance system prompt and skill documentation for data mutation confirmations
1 parent c5cd8a6 commit 0efef3c

3 files changed

Lines changed: 33 additions & 3 deletions

File tree

agent/systemPrompt.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ export const DEFAULT_AGENT_SYSTEM_PROMPT = [
2626
"Do not add extra explanations or suggestions unless the user asks.",
2727
"Adapt to the user's tone and style of speaking, mirroring their vibe and wording.",
2828
"if the user speaks casually, you should respond casually too",
29+
"Never mutate data without a fresh user confirmation for that exact mutation.",
30+
"A previous confirmation does not carry over to later create, update, delete, or action calls.",
31+
"Each separate mutation or explicitly described batch needs its own confirmation immediately before the tool call.",
2932

3033

3134
].join(" ");
@@ -59,8 +62,13 @@ export async function buildAgentSystemPrompt(adminforth: IAdminForth) {
5962
"You have next default skills which you can fallback to if primary skill set does not provide a good skill:\n" +
6063
formatSkills(defaultSkills, "skill_name"),
6164
"Before using any skill, call fetch_skill to load its full instructions.",
65+
"The fetched skill response starts with 'Tools mentioned in this skill'. Read that list first.",
6266
"You can use get_resource immediately to inspect resource structure and column names.",
67+
"If the user wants to create, update, delete, or run actions on records, load mutate_data first.",
68+
"If the user wants to fetch records, load fetch_data first. If the user wants analytics or charts, load data-analytics first.",
6369
"Only call fetch_tool_schema for tool names that are explicitly mentioned in a fetched skill and are not already available as base tools.",
70+
"If a fetched skill lists a non-base tool you need, call fetch_tool_schema for it immediately instead of telling the user the tool is unavailable.",
71+
"For example: for record creation load mutate_data, read its tool list, call fetch_tool_schema for create_record, and then use create_record after confirmation.",
6472
"When fetch_tool_schema succeeds, that tool becomes available on the next step.",
6573
"Try to call as many tools as possible in parallel in one step.",
6674
];

agent/tools/fetchToolSchema.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ export async function createFetchToolSchemaTool(
4343
{
4444
name: "fetch_tool_schema",
4545
description:
46-
"Fetch the schema for an API-based AdminForth tool by name and load it for later use.",
46+
"Fetch the schema for an API-based AdminForth tool by name and load it for later use. Use this right after fetch_skill when the skill mentions non-base tools.",
4747
schema: fetchToolSchemaSchema,
4848
},
4949
);

custom/skills/mutate_data/SKILL.md

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,16 @@ name: mutate_data
22
description: Create/update/delete some record of resource or call actions on one or multiple records
33
---
44

5+
# Involved tools
6+
7+
Use `create_record` for creating records.
8+
9+
Use `update_record` for editing records.
10+
11+
Use `delete_record` for deleting records.
12+
13+
Use `start_custom_action` and `start_custom_bulk_action` for resource actions.
14+
515
# General rules
616

717
- if there is a dedicated action for some routine (result of `get_resource` tool call, field actions), prefer this to manual updating of records, for example, if you want to approve some comment, prefer calling `approve` action instead of updating `approved` field of comment record (because in action there might be some additional logic like sending notification to user, updating some counters and so on)
@@ -16,7 +26,19 @@ And in the same message ask user for final confirmation.
1626

1727
When creating new record, show user all data which you gona create and in same message ask for confirmation.
1828

19-
Accept any positive confirmation from user like "yes", "sure", "+", anything non-negative call to action, can be considered as confirmation.
29+
Accept any positive confirmation from user like "yes", "sure", "+", anything non-negative call to action, can be considered as confirmation.
30+
31+
A confirmation is valid only for the exact mutation plan from the immediately previous assistant message.
32+
33+
Never reuse an older confirmation for a later mutation.
34+
35+
After one mutation is executed, confirmation is consumed and reset.
36+
37+
If you want to perform another create/update/delete/action after that, ask for confirmation again even if the user previously said "yes".
38+
39+
If the mutation plan changes in any way (different record, different fields, different values, different number of records, different action), the old confirmation is invalid and you must ask again.
40+
41+
If you are creating or deleting multiple records in one batch, you may ask once only for that exact batch, but you must list the whole batch explicitly in the confirmation message. Any extra record outside that described batch requires a new confirmation.
2042

2143
# Calling actions
2244

@@ -105,4 +127,4 @@ I am going to create user:
105127
View [John Doe](/admin/resource/users/show/421) # 421 is id of new created record
106128
107129
Are you sure?
108-
```
130+
```

0 commit comments

Comments
 (0)