@adminforth/agent 1.2.2 → 1.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/agent/systemPrompt.ts +8 -0
- package/agent/tools/fetchToolSchema.ts +1 -1
- package/build.log +2 -2
- package/custom/skills/fetch_data/SKILL.md +1 -1
- package/custom/skills/mutate_data/SKILL.md +26 -3
- package/dist/agent/systemPrompt.js +8 -0
- package/dist/agent/tools/fetchToolSchema.js +1 -1
- package/dist/custom/skills/fetch_data/SKILL.md +1 -1
- package/dist/custom/skills/mutate_data/SKILL.md +26 -3
- package/package.json +1 -1
package/agent/systemPrompt.ts
CHANGED
|
@@ -26,6 +26,9 @@ export const DEFAULT_AGENT_SYSTEM_PROMPT = [
|
|
|
26
26
|
"Do not add extra explanations or suggestions unless the user asks.",
|
|
27
27
|
"Adapt to the user's tone and style of speaking, mirroring their vibe and wording.",
|
|
28
28
|
"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.",
|
|
29
32
|
|
|
30
33
|
|
|
31
34
|
].join(" ");
|
|
@@ -59,8 +62,13 @@ export async function buildAgentSystemPrompt(adminforth: IAdminForth) {
|
|
|
59
62
|
"You have next default skills which you can fallback to if primary skill set does not provide a good skill:\n" +
|
|
60
63
|
formatSkills(defaultSkills, "skill_name"),
|
|
61
64
|
"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.",
|
|
62
66
|
"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.",
|
|
63
69
|
"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.",
|
|
64
72
|
"When fetch_tool_schema succeeds, that tool becomes available on the next step.",
|
|
65
73
|
"Try to call as many tools as possible in parallel in one step.",
|
|
66
74
|
];
|
|
@@ -43,7 +43,7 @@ export async function createFetchToolSchemaTool(
|
|
|
43
43
|
{
|
|
44
44
|
name: "fetch_tool_schema",
|
|
45
45
|
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.",
|
|
47
47
|
schema: fetchToolSchemaSchema,
|
|
48
48
|
},
|
|
49
49
|
);
|
package/build.log
CHANGED
|
@@ -29,5 +29,5 @@ custom/skills/fetch_data/SKILL.md
|
|
|
29
29
|
custom/skills/mutate_data/
|
|
30
30
|
custom/skills/mutate_data/SKILL.md
|
|
31
31
|
|
|
32
|
-
sent
|
|
33
|
-
total size is
|
|
32
|
+
sent 169,707 bytes received 413 bytes 340,240.00 bytes/sec
|
|
33
|
+
total size is 168,033 speedup is 0.99
|
|
@@ -12,4 +12,4 @@ To find specific data record you should use filters. ILIKE filters are preferred
|
|
|
12
12
|
|
|
13
13
|
For long texts show only several first words and add "..." at the end (only if user did not request this field specifically).
|
|
14
14
|
|
|
15
|
-
Also when you communicate with user about record, add related link to this record. For example /{BASE_URL}/resource/{resourceId}/show/{primary key}. Use _label from `get_resource_data` as anchor text for link (use markdown link).
|
|
15
|
+
Also when you communicate with user about record, add related link to this record. For example /{BASE_URL}/resource/{resourceId}/show/{primary key}. Use _label from `get_resource_data` as anchor text for link (use markdown link). Links shoudl be always relative path, starting with slash.
|
|
@@ -2,6 +2,16 @@ name: mutate_data
|
|
|
2
2
|
description: Create/update/delete some record of resource or call actions on one or multiple records
|
|
3
3
|
---
|
|
4
4
|
|
|
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
|
+
|
|
5
15
|
# General rules
|
|
6
16
|
|
|
7
17
|
- 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)
|
|
@@ -11,12 +21,25 @@ description: Create/update/delete some record of resource or call actions on on
|
|
|
11
21
|
Before performing any state mutation including action calls edit/delete please fetch record which is going to be edited/deleted and show user record in format field → value (show several most important fields which can help user to understand what exactly record he is going to edit or delete).
|
|
12
22
|
|
|
13
23
|
For field values with long texts show only several first words and add "..." at the end.
|
|
14
|
-
Also please add related link to record with will be changed. For example /{BASE_URL}/resource/{resourceId}/show/{primary key}. Use _label from `get_resource_data` as anchor text for link (use markdown link).
|
|
24
|
+
Also please add related link to record with will be changed. For example /{BASE_URL}/resource/{resourceId}/show/{primary key}. Use _label from `get_resource_data` as anchor text for link (use markdown link). Links shoudl be always relative path, starting with slash.
|
|
25
|
+
|
|
15
26
|
And in the same message ask user for final confirmation.
|
|
16
27
|
|
|
17
28
|
When creating new record, show user all data which you gona create and in same message ask for confirmation.
|
|
18
29
|
|
|
19
|
-
Accept any positive confirmation from user like "yes", "sure", "+", anything non-negative call to action, can be considered as confirmation.
|
|
30
|
+
Accept any positive confirmation from user like "yes", "sure", "+", anything non-negative call to action, can be considered as confirmation.
|
|
31
|
+
|
|
32
|
+
A confirmation is valid only for the exact mutation plan from the immediately previous assistant message.
|
|
33
|
+
|
|
34
|
+
Never reuse an older confirmation for a later mutation.
|
|
35
|
+
|
|
36
|
+
After one mutation is executed, confirmation is consumed and reset.
|
|
37
|
+
|
|
38
|
+
If you want to perform another create/update/delete/action after that, ask for confirmation again even if the user previously said "yes".
|
|
39
|
+
|
|
40
|
+
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.
|
|
41
|
+
|
|
42
|
+
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.
|
|
20
43
|
|
|
21
44
|
# Calling actions
|
|
22
45
|
|
|
@@ -105,4 +128,4 @@ I am going to create user:
|
|
|
105
128
|
View [John Doe](/admin/resource/users/show/421) # 421 is id of new created record
|
|
106
129
|
|
|
107
130
|
Are you sure?
|
|
108
|
-
```
|
|
131
|
+
```
|
|
@@ -25,6 +25,9 @@ export const DEFAULT_AGENT_SYSTEM_PROMPT = [
|
|
|
25
25
|
"Do not add extra explanations or suggestions unless the user asks.",
|
|
26
26
|
"Adapt to the user's tone and style of speaking, mirroring their vibe and wording.",
|
|
27
27
|
"if the user speaks casually, you should respond casually too",
|
|
28
|
+
"Never mutate data without a fresh user confirmation for that exact mutation.",
|
|
29
|
+
"A previous confirmation does not carry over to later create, update, delete, or action calls.",
|
|
30
|
+
"Each separate mutation or explicitly described batch needs its own confirmation immediately before the tool call.",
|
|
28
31
|
].join(" ");
|
|
29
32
|
function formatResources(resources) {
|
|
30
33
|
return resources
|
|
@@ -54,8 +57,13 @@ export function buildAgentSystemPrompt(adminforth) {
|
|
|
54
57
|
"You have next default skills which you can fallback to if primary skill set does not provide a good skill:\n" +
|
|
55
58
|
formatSkills(defaultSkills, "skill_name"),
|
|
56
59
|
"Before using any skill, call fetch_skill to load its full instructions.",
|
|
60
|
+
"The fetched skill response starts with 'Tools mentioned in this skill'. Read that list first.",
|
|
57
61
|
"You can use get_resource immediately to inspect resource structure and column names.",
|
|
62
|
+
"If the user wants to create, update, delete, or run actions on records, load mutate_data first.",
|
|
63
|
+
"If the user wants to fetch records, load fetch_data first. If the user wants analytics or charts, load data-analytics first.",
|
|
58
64
|
"Only call fetch_tool_schema for tool names that are explicitly mentioned in a fetched skill and are not already available as base tools.",
|
|
65
|
+
"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.",
|
|
66
|
+
"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.",
|
|
59
67
|
"When fetch_tool_schema succeeds, that tool becomes available on the next step.",
|
|
60
68
|
"Try to call as many tools as possible in parallel in one step.",
|
|
61
69
|
];
|
|
@@ -29,7 +29,7 @@ export function createFetchToolSchemaTool(apiBasedTools) {
|
|
|
29
29
|
return JSON.stringify(Object.assign({ status: 200, name: toolName }, serializeApiBasedTool(toolDefinition)), null, 2);
|
|
30
30
|
}), {
|
|
31
31
|
name: "fetch_tool_schema",
|
|
32
|
-
description: "Fetch the schema for an API-based AdminForth tool by name and load it for later use.",
|
|
32
|
+
description: "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.",
|
|
33
33
|
schema: fetchToolSchemaSchema,
|
|
34
34
|
});
|
|
35
35
|
});
|
|
@@ -12,4 +12,4 @@ To find specific data record you should use filters. ILIKE filters are preferred
|
|
|
12
12
|
|
|
13
13
|
For long texts show only several first words and add "..." at the end (only if user did not request this field specifically).
|
|
14
14
|
|
|
15
|
-
Also when you communicate with user about record, add related link to this record. For example /{BASE_URL}/resource/{resourceId}/show/{primary key}. Use _label from `get_resource_data` as anchor text for link (use markdown link).
|
|
15
|
+
Also when you communicate with user about record, add related link to this record. For example /{BASE_URL}/resource/{resourceId}/show/{primary key}. Use _label from `get_resource_data` as anchor text for link (use markdown link). Links shoudl be always relative path, starting with slash.
|
|
@@ -2,6 +2,16 @@ name: mutate_data
|
|
|
2
2
|
description: Create/update/delete some record of resource or call actions on one or multiple records
|
|
3
3
|
---
|
|
4
4
|
|
|
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
|
+
|
|
5
15
|
# General rules
|
|
6
16
|
|
|
7
17
|
- 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)
|
|
@@ -11,12 +21,25 @@ description: Create/update/delete some record of resource or call actions on on
|
|
|
11
21
|
Before performing any state mutation including action calls edit/delete please fetch record which is going to be edited/deleted and show user record in format field → value (show several most important fields which can help user to understand what exactly record he is going to edit or delete).
|
|
12
22
|
|
|
13
23
|
For field values with long texts show only several first words and add "..." at the end.
|
|
14
|
-
Also please add related link to record with will be changed. For example /{BASE_URL}/resource/{resourceId}/show/{primary key}. Use _label from `get_resource_data` as anchor text for link (use markdown link).
|
|
24
|
+
Also please add related link to record with will be changed. For example /{BASE_URL}/resource/{resourceId}/show/{primary key}. Use _label from `get_resource_data` as anchor text for link (use markdown link). Links shoudl be always relative path, starting with slash.
|
|
25
|
+
|
|
15
26
|
And in the same message ask user for final confirmation.
|
|
16
27
|
|
|
17
28
|
When creating new record, show user all data which you gona create and in same message ask for confirmation.
|
|
18
29
|
|
|
19
|
-
Accept any positive confirmation from user like "yes", "sure", "+", anything non-negative call to action, can be considered as confirmation.
|
|
30
|
+
Accept any positive confirmation from user like "yes", "sure", "+", anything non-negative call to action, can be considered as confirmation.
|
|
31
|
+
|
|
32
|
+
A confirmation is valid only for the exact mutation plan from the immediately previous assistant message.
|
|
33
|
+
|
|
34
|
+
Never reuse an older confirmation for a later mutation.
|
|
35
|
+
|
|
36
|
+
After one mutation is executed, confirmation is consumed and reset.
|
|
37
|
+
|
|
38
|
+
If you want to perform another create/update/delete/action after that, ask for confirmation again even if the user previously said "yes".
|
|
39
|
+
|
|
40
|
+
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.
|
|
41
|
+
|
|
42
|
+
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.
|
|
20
43
|
|
|
21
44
|
# Calling actions
|
|
22
45
|
|
|
@@ -105,4 +128,4 @@ I am going to create user:
|
|
|
105
128
|
View [John Doe](/admin/resource/users/show/421) # 421 is id of new created record
|
|
106
129
|
|
|
107
130
|
Are you sure?
|
|
108
|
-
```
|
|
131
|
+
```
|