@xaidenlabs/uso 1.2.0 → 1.2.2
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/bin/index.js +1 -1
- package/package.json +1 -1
- package/packages/uso-core/dist/cjs/agent/brain.d.ts.map +1 -1
- package/packages/uso-core/dist/cjs/agent/brain.js +25 -30
- package/packages/uso-core/dist/cjs/agent/brain.js.map +1 -1
- package/packages/uso-core/dist/cjs/agent/prompts.d.ts +1 -1
- package/packages/uso-core/dist/cjs/agent/prompts.d.ts.map +1 -1
- package/packages/uso-core/dist/cjs/agent/prompts.js +27 -21
- package/packages/uso-core/dist/cjs/agent/prompts.js.map +1 -1
- package/packages/uso-core/dist/esm/agent/brain.d.ts.map +1 -1
- package/packages/uso-core/dist/esm/agent/brain.js +25 -30
- package/packages/uso-core/dist/esm/agent/brain.js.map +1 -1
- package/packages/uso-core/dist/esm/agent/prompts.d.ts +1 -1
- package/packages/uso-core/dist/esm/agent/prompts.d.ts.map +1 -1
- package/packages/uso-core/dist/esm/agent/prompts.js +27 -21
- package/packages/uso-core/dist/esm/agent/prompts.js.map +1 -1
- package/packages/uso-core/src/agent/brain.ts +30 -32
- package/packages/uso-core/src/agent/prompts.ts +28 -20
package/bin/index.js
CHANGED
|
@@ -107,7 +107,7 @@ program
|
|
|
107
107
|
.description('Start the AI Agent to accomplish a goal autonomously')
|
|
108
108
|
.option('--model <model>', 'LLM model to use (e.g., llama3.1:8b, gemini-2.0-flash, openai/gpt-4o)')
|
|
109
109
|
.option('--provider <provider>', 'Force a specific LLM provider (ollama, gemini, openai, github)')
|
|
110
|
-
.option('--max-loops <n>', 'Maximum reasoning iterations', '
|
|
110
|
+
.option('--max-loops <n>', 'Maximum reasoning iterations', '10')
|
|
111
111
|
.option('--verbose', 'Show full reasoning traces')
|
|
112
112
|
.action(agent);
|
|
113
113
|
|
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"brain.d.ts","sourceRoot":"","sources":["../../../src/agent/brain.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAA2B,MAAM,aAAa,CAAC;AACvE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAU1C,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,WAAW,GAAG,eAAe,GAAG,aAAa,CAAC;IACpD,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACrC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED;;;;;;;;;;GAUG;AACH,qBAAa,UAAU;IAEnB,OAAO,CAAC,GAAG;IACX,OAAO,CAAC,KAAK;gBADL,GAAG,EAAE,UAAU,EACf,KAAK,EAAE,YAAY;IAG7B;;OAEG;IACG,KAAK,CAAC,KAAK,EAAE,UAAU,GAAG,OAAO,CAAC;QAAE,MAAM,EAAE,WAAW,CAAC;QAAC,KAAK,EAAE,UAAU,CAAA;KAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"brain.d.ts","sourceRoot":"","sources":["../../../src/agent/brain.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAA2B,MAAM,aAAa,CAAC;AACvE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAU1C,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,WAAW,GAAG,eAAe,GAAG,aAAa,CAAC;IACpD,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACrC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED;;;;;;;;;;GAUG;AACH,qBAAa,UAAU;IAEnB,OAAO,CAAC,GAAG;IACX,OAAO,CAAC,KAAK;gBADL,GAAG,EAAE,UAAU,EACf,KAAK,EAAE,YAAY;IAG7B;;OAEG;IACG,KAAK,CAAC,KAAK,EAAE,UAAU,GAAG,OAAO,CAAC;QAAE,MAAM,EAAE,WAAW,CAAC;QAAC,KAAK,EAAE,UAAU,CAAA;KAAE,CAAC;IA0CnF;;OAEG;IACG,GAAG,CACP,MAAM,EAAE,WAAW,EACnB,KAAK,EAAE,UAAU,GAChB,OAAO,CAAC;QAAE,WAAW,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,OAAO,CAAC;QAAC,KAAK,EAAE,UAAU,CAAA;KAAE,CAAC;IA6DxE;;OAEG;IACH,OAAO,CAAC,aAAa;IAoDrB;;OAEG;IACH,OAAO,CAAC,iBAAiB;IAgDzB,OAAO,CAAC,cAAc;CA6BvB"}
|
|
@@ -30,13 +30,8 @@ class AgentBrain {
|
|
|
30
30
|
temperature: 0.1,
|
|
31
31
|
maxTokens: 2048,
|
|
32
32
|
};
|
|
33
|
-
//
|
|
34
|
-
|
|
35
|
-
if (this.llm.provider === "openai" ||
|
|
36
|
-
this.llm.provider === "github" ||
|
|
37
|
-
this.llm.provider === "gemini") {
|
|
38
|
-
options.tools = toolDefs;
|
|
39
|
-
}
|
|
33
|
+
// Removed native tool calling logic because GitHub Models' gpt-4o-mini often omits tool calls.
|
|
34
|
+
// We will rely entirely on the text-based THOUGHT/ACTION JSON format.
|
|
40
35
|
let response;
|
|
41
36
|
try {
|
|
42
37
|
response = await this.llm.chat(messages, options);
|
|
@@ -56,24 +51,6 @@ class AgentBrain {
|
|
|
56
51
|
state: newState,
|
|
57
52
|
};
|
|
58
53
|
}
|
|
59
|
-
// Handle native function calling responses
|
|
60
|
-
if (response.toolCalls && response.toolCalls.length > 0) {
|
|
61
|
-
const tc = response.toolCalls[0]; // Process one tool call at a time
|
|
62
|
-
const thought = response.content || `Calling ${tc.name}`;
|
|
63
|
-
const newState = (0, state_1.appendHistory)(state, {
|
|
64
|
-
role: "thought",
|
|
65
|
-
content: thought,
|
|
66
|
-
});
|
|
67
|
-
return {
|
|
68
|
-
action: {
|
|
69
|
-
type: "tool_call",
|
|
70
|
-
thought,
|
|
71
|
-
toolName: tc.name,
|
|
72
|
-
toolParams: tc.arguments,
|
|
73
|
-
},
|
|
74
|
-
state: newState,
|
|
75
|
-
};
|
|
76
|
-
}
|
|
77
54
|
// Parse text-based THOUGHT + ACTION format (for Ollama and fallback)
|
|
78
55
|
const action = this.parseTextResponse(response.content);
|
|
79
56
|
const newState = (0, state_1.appendHistory)(state, {
|
|
@@ -93,6 +70,22 @@ class AgentBrain {
|
|
|
93
70
|
state,
|
|
94
71
|
};
|
|
95
72
|
}
|
|
73
|
+
if (action.toolName === "INVALID_ACTION") {
|
|
74
|
+
const observation = (0, prompts_1.buildObservationMessage)("INVALID_ACTION", false, "You did not provide a valid JSON action block or native tool call. You MUST provide exactly ONE action.");
|
|
75
|
+
const newState = (0, state_1.appendHistory)(state, {
|
|
76
|
+
role: "observation",
|
|
77
|
+
content: observation,
|
|
78
|
+
toolName: "INVALID_ACTION",
|
|
79
|
+
});
|
|
80
|
+
return {
|
|
81
|
+
observation,
|
|
82
|
+
success: false,
|
|
83
|
+
state: (0, state_1.appendError)(newState, {
|
|
84
|
+
message: "Invalid action format",
|
|
85
|
+
stepId: "parse",
|
|
86
|
+
}),
|
|
87
|
+
};
|
|
88
|
+
}
|
|
96
89
|
const result = await this.tools.execute(action.toolName, action.toolParams ?? {}, state);
|
|
97
90
|
const observation = (0, prompts_1.buildObservationMessage)(action.toolName, result.success, result.output || result.error || "No output");
|
|
98
91
|
const newState = (0, state_1.appendHistory)(state, {
|
|
@@ -120,7 +113,7 @@ class AgentBrain {
|
|
|
120
113
|
// System prompt
|
|
121
114
|
messages.push({
|
|
122
115
|
role: "system",
|
|
123
|
-
content: (0, prompts_1.buildSystemPrompt)(this.tools, state.environment.os, state.environment.route),
|
|
116
|
+
content: (0, prompts_1.buildSystemPrompt)(this.tools, state.environment.os, state.environment.route, false),
|
|
124
117
|
});
|
|
125
118
|
// User's goal
|
|
126
119
|
messages.push({
|
|
@@ -179,9 +172,10 @@ class AgentBrain {
|
|
|
179
172
|
}
|
|
180
173
|
// No parseable action — treat as thinking aloud
|
|
181
174
|
return {
|
|
182
|
-
type: "
|
|
175
|
+
type: "tool_call",
|
|
183
176
|
thought,
|
|
184
|
-
|
|
177
|
+
toolName: "INVALID_ACTION",
|
|
178
|
+
toolParams: {},
|
|
185
179
|
};
|
|
186
180
|
}
|
|
187
181
|
try {
|
|
@@ -190,9 +184,10 @@ class AgentBrain {
|
|
|
190
184
|
}
|
|
191
185
|
catch {
|
|
192
186
|
return {
|
|
193
|
-
type: "
|
|
187
|
+
type: "tool_call",
|
|
194
188
|
thought,
|
|
195
|
-
|
|
189
|
+
toolName: "INVALID_ACTION",
|
|
190
|
+
toolParams: { error: `Invalid JSON in ACTION block: ${actionMatch[1]}` },
|
|
196
191
|
};
|
|
197
192
|
}
|
|
198
193
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"brain.js","sourceRoot":"","sources":["../../../src/agent/brain.ts"],"names":[],"mappings":";;;AAGA,uCAKmB;AACnB,mCAAqD;AAYrD;;;;;;;;;;GAUG;AACH,MAAa,UAAU;IAEX;IACA;IAFV,YACU,GAAe,EACf,KAAmB;QADnB,QAAG,GAAH,GAAG,CAAY;QACf,UAAK,GAAL,KAAK,CAAc;IAC1B,CAAC;IAEJ;;OAEG;IACH,KAAK,CAAC,KAAK,CAAC,KAAiB;QAC3B,MAAM,QAAQ,GAAG,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;QAE3C,MAAM,OAAO,GAAe;YAC1B,WAAW,EAAE,GAAG;YACh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AW;YACjB,OAAO;YACP,QAAQ,EAAE,MAAM,CAAC,MAAM;YACvB,UAAU,EAAE,MAAM,CAAC,MAAM,IAAI,EAAE;SAChC,CAAC;IACJ,CAAC;CACF;AA7PD,gCA6PC"}
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* format, and guardrails.
|
|
7
7
|
*/
|
|
8
8
|
import type { ToolRegistry } from "./tool-registry";
|
|
9
|
-
export declare function buildSystemPrompt(toolRegistry: ToolRegistry, os: string, route: string): string;
|
|
9
|
+
export declare function buildSystemPrompt(toolRegistry: ToolRegistry, os: string, route: string, useNativeToolCalling: boolean): string;
|
|
10
10
|
export declare function buildPlanningPrompt(userGoal: string): string;
|
|
11
11
|
export declare function buildReflectionPrompt(failedStep: string, errorOutput: string, attemptCount: number): string;
|
|
12
12
|
export declare function buildObservationMessage(toolName: string, success: boolean, output: string): string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prompts.d.ts","sourceRoot":"","sources":["../../../src/agent/prompts.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAGpD,wBAAgB,iBAAiB,CAC/B,YAAY,EAAE,YAAY,EAC1B,EAAE,EAAE,MAAM,EACV,KAAK,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"prompts.d.ts","sourceRoot":"","sources":["../../../src/agent/prompts.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAGpD,wBAAgB,iBAAiB,CAC/B,YAAY,EAAE,YAAY,EAC1B,EAAE,EAAE,MAAM,EACV,KAAK,EAAE,MAAM,EACb,oBAAoB,EAAE,OAAO,GAC5B,MAAM,CA6DR;AAGD,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAY5D;AAGD,wBAAgB,qBAAqB,CACnC,UAAU,EAAE,MAAM,EAClB,WAAW,EAAE,MAAM,EACnB,YAAY,EAAE,MAAM,GACnB,MAAM,CAiBR;AAGD,wBAAgB,uBAAuB,CACrC,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,OAAO,EAChB,MAAM,EAAE,MAAM,GACb,MAAM,CAGR"}
|
|
@@ -12,8 +12,28 @@ exports.buildPlanningPrompt = buildPlanningPrompt;
|
|
|
12
12
|
exports.buildReflectionPrompt = buildReflectionPrompt;
|
|
13
13
|
exports.buildObservationMessage = buildObservationMessage;
|
|
14
14
|
// ─── System Identity Prompt ────────────────────────────────────────
|
|
15
|
-
function buildSystemPrompt(toolRegistry, os, route) {
|
|
15
|
+
function buildSystemPrompt(toolRegistry, os, route, useNativeToolCalling) {
|
|
16
16
|
const toolSummary = toolRegistry.getToolSummary();
|
|
17
|
+
const responseInstructions = useNativeToolCalling
|
|
18
|
+
? `Since you have native tool calling enabled, you MUST invoke exactly ONE tool for EVERY response.
|
|
19
|
+
Do not output raw JSON text blocks for actions; simply call the tool natively.
|
|
20
|
+
If you need to talk to the user or indicate completion/failure, use the TASK_COMPLETE or TASK_FAILED tools.`
|
|
21
|
+
: `For EVERY turn, output EXACTLY this format:
|
|
22
|
+
|
|
23
|
+
THOUGHT: <your reasoning about what to do next>
|
|
24
|
+
ACTION: <a single JSON object with "action" and "params" keys>
|
|
25
|
+
|
|
26
|
+
Example:
|
|
27
|
+
THOUGHT: I need to check if Anchor is installed before trying to build.
|
|
28
|
+
ACTION: {"action": "check_environment", "params": {}}
|
|
29
|
+
|
|
30
|
+
When you have completed the user's goal, output:
|
|
31
|
+
THOUGHT: <summary of what was accomplished>
|
|
32
|
+
ACTION: {"action": "TASK_COMPLETE", "params": {"summary": "<final summary>"}}
|
|
33
|
+
|
|
34
|
+
If you cannot accomplish the goal, output:
|
|
35
|
+
THOUGHT: <explanation of why>
|
|
36
|
+
ACTION: {"action": "TASK_FAILED", "params": {"reason": "<reason>"}}`;
|
|
17
37
|
return `You are the USO Agent — an autonomous AI assistant built into the Universal Solana Orchestrator CLI.
|
|
18
38
|
|
|
19
39
|
## Your Identity
|
|
@@ -25,39 +45,25 @@ You are an expert Solana developer and DevOps engineer. You help developers buil
|
|
|
25
45
|
- Current Directory: ${process.cwd()}
|
|
26
46
|
|
|
27
47
|
## Available Tools
|
|
28
|
-
You have access to
|
|
48
|
+
You have access to a set of tools to interact with the environment.
|
|
29
49
|
|
|
30
50
|
${toolSummary}
|
|
31
51
|
|
|
32
52
|
## How to Respond
|
|
33
53
|
You operate in a Thought → Action → Observation loop.
|
|
34
54
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
THOUGHT: <your reasoning about what to do next>
|
|
38
|
-
ACTION: <a single JSON object with "action" and "params" keys>
|
|
39
|
-
|
|
40
|
-
Example:
|
|
41
|
-
THOUGHT: I need to check if Anchor is installed before trying to build.
|
|
42
|
-
ACTION: {"action": "check_environment", "params": {}}
|
|
43
|
-
|
|
44
|
-
When you have completed the user's goal, output:
|
|
45
|
-
THOUGHT: <summary of what was accomplished>
|
|
46
|
-
ACTION: {"action": "TASK_COMPLETE", "params": {"summary": "<final summary>"}}
|
|
47
|
-
|
|
48
|
-
If you cannot accomplish the goal, output:
|
|
49
|
-
THOUGHT: <explanation of why>
|
|
50
|
-
ACTION: {"action": "TASK_FAILED", "params": {"reason": "<reason>"}}
|
|
55
|
+
${responseInstructions}
|
|
51
56
|
|
|
52
57
|
## Rules
|
|
53
|
-
1. ALWAYS output exactly ONE action per turn. Never output
|
|
54
|
-
2. ALWAYS
|
|
58
|
+
1. ALWAYS output exactly ONE action per turn. You MUST use a tool call or ACTION block for EVERY single response. Never just output plain text.
|
|
59
|
+
2. ALWAYS provide your reasoning before or during your tool call.
|
|
55
60
|
3. Use check_environment FIRST before attempting any build/test/deploy.
|
|
56
|
-
4. NEVER deploy to mainnet-beta without explicitly confirming with the user.
|
|
61
|
+
4. NEVER deploy to mainnet-beta without explicitly confirming with the user. If the user asked to deploy to devnet or testnet, proceed without asking for confirmation.
|
|
57
62
|
5. If a command fails, analyze the error and try a different approach. Don't repeat the same failing command.
|
|
58
63
|
6. Cap your terminal commands to reasonable timeouts.
|
|
59
64
|
7. When reading files, only read what's necessary. Don't dump entire codebases.
|
|
60
65
|
8. If you need to install missing tools, use the appropriate uso/solana/anchor commands.
|
|
66
|
+
9. If you need to talk to the user, use TASK_COMPLETE with your message as the summary, or TASK_FAILED if you are stuck.
|
|
61
67
|
|
|
62
68
|
## Error Recovery
|
|
63
69
|
When a tool returns an error:
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prompts.js","sourceRoot":"","sources":["../../../src/agent/prompts.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;AAKH,
|
|
1
|
+
{"version":3,"file":"prompts.js","sourceRoot":"","sources":["../../../src/agent/prompts.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;AAKH,8CAkEC;AAGD,kDAYC;AAGD,sDAqBC;AAGD,0DAOC;AApHD,sEAAsE;AACtE,SAAgB,iBAAiB,CAC/B,YAA0B,EAC1B,EAAU,EACV,KAAa,EACb,oBAA6B;IAE7B,MAAM,WAAW,GAAG,YAAY,CAAC,cAAc,EAAE,CAAC;IAElD,MAAM,oBAAoB,GAAG,oBAAoB;QAC/C,CAAC,CAAC;;4GAEsG;QACxG,CAAC,CAAC;;;;;;;;;;;;;;;oEAe8D,CAAC;IAEnE,OAAO;;;;;;sBAMa,EAAE;mBACL,KAAK;uBACD,OAAO,CAAC,GAAG,EAAE;;;;;EAKlC,WAAW;;;;;EAKX,oBAAoB;;;;;;;;;;;;;;;;;;iFAkB2D,CAAC;AAClF,CAAC;AAED,sEAAsE;AACtE,SAAgB,mBAAmB,CAAC,QAAgB;IAClD,OAAO;;GAEN,QAAQ;;;;;;;;gEAQqD,CAAC;AACjE,CAAC;AAED,sEAAsE;AACtE,SAAgB,qBAAqB,CACnC,UAAkB,EAClB,WAAmB,EACnB,YAAoB;IAEpB,OAAO;;eAEM,UAAU;;;EAGvB,WAAW,CAAC,KAAK,CAAC,CAAC,EAAE,IAAI,CAAC;;;mBAGT,YAAY;;;;;;;gDAOiB,CAAC;AACjD,CAAC;AAED,sEAAsE;AACtE,SAAgB,uBAAuB,CACrC,QAAgB,EAChB,OAAgB,EAChB,MAAc;IAEd,MAAM,MAAM,GAAG,OAAO,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,UAAU,CAAC;IAClD,OAAO,gBAAgB,QAAQ,KAAK,MAAM,MAAM,MAAM,EAAE,CAAC;AAC3D,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"brain.d.ts","sourceRoot":"","sources":["../../../src/agent/brain.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAA2B,MAAM,aAAa,CAAC;AACvE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAU1C,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,WAAW,GAAG,eAAe,GAAG,aAAa,CAAC;IACpD,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACrC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED;;;;;;;;;;GAUG;AACH,qBAAa,UAAU;IAEnB,OAAO,CAAC,GAAG;IACX,OAAO,CAAC,KAAK;gBADL,GAAG,EAAE,UAAU,EACf,KAAK,EAAE,YAAY;IAG7B;;OAEG;IACG,KAAK,CAAC,KAAK,EAAE,UAAU,GAAG,OAAO,CAAC;QAAE,MAAM,EAAE,WAAW,CAAC;QAAC,KAAK,EAAE,UAAU,CAAA;KAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"brain.d.ts","sourceRoot":"","sources":["../../../src/agent/br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|
-
this.llm.provider === "github" ||
|
|
34
|
-
this.llm.provider === "gemini") {
|
|
35
|
-
options.tools = toolDefs;
|
|
36
|
-
}
|
|
30
|
+
// Removed native tool calling logic because GitHub Models' gpt-4o-mini often omits tool calls.
|
|
31
|
+
// We will rely entirely on the text-based THOUGHT/ACTION JSON format.
|
|
37
32
|
let response;
|
|
38
33
|
try {
|
|
39
34
|
response = await this.llm.chat(messages, options);
|
|
@@ -53,24 +48,6 @@ export class AgentBrain {
|
|
|
53
48
|
state: newState,
|
|
54
49
|
};
|
|
55
50
|
}
|
|
56
|
-
// Handle native function calling responses
|
|
57
|
-
if (response.toolCalls && response.toolCalls.length > 0) {
|
|
58
|
-
const tc = response.toolCalls[0]; // Process one tool call at a time
|
|
59
|
-
const thought = response.content || `Calling ${tc.name}`;
|
|
60
|
-
const newState = appendHistory(state, {
|
|
61
|
-
role: "thought",
|
|
62
|
-
content: thought,
|
|
63
|
-
});
|
|
64
|
-
return {
|
|
65
|
-
action: {
|
|
66
|
-
type: "tool_call",
|
|
67
|
-
thought,
|
|
68
|
-
toolName: tc.name,
|
|
69
|
-
toolParams: tc.arguments,
|
|
70
|
-
},
|
|
71
|
-
state: newState,
|
|
72
|
-
};
|
|
73
|
-
}
|
|
74
51
|
// Parse text-based THOUGHT + ACTION format (for Ollama and fallback)
|
|
75
52
|
const action = this.parseTextResponse(response.content);
|
|
76
53
|
const newState = appendHistory(state, {
|
|
@@ -90,6 +67,22 @@ export class AgentBrain {
|
|
|
90
67
|
state,
|
|
91
68
|
};
|
|
92
69
|
}
|
|
70
|
+
if (action.toolName === "INVALID_ACTION") {
|
|
71
|
+
const observation = buildObservationMessage("INVALID_ACTION", false, "You did not provide a valid JSON action block or native tool call. You MUST provide exactly ONE action.");
|
|
72
|
+
const newState = appendHistory(state, {
|
|
73
|
+
role: "observation",
|
|
74
|
+
content: observation,
|
|
75
|
+
toolName: "INVALID_ACTION",
|
|
76
|
+
});
|
|
77
|
+
return {
|
|
78
|
+
observation,
|
|
79
|
+
success: false,
|
|
80
|
+
state: appendError(newState, {
|
|
81
|
+
message: "Invalid action format",
|
|
82
|
+
stepId: "parse",
|
|
83
|
+
}),
|
|
84
|
+
};
|
|
85
|
+
}
|
|
93
86
|
const result = await this.tools.execute(action.toolName, action.toolParams ?? {}, state);
|
|
94
87
|
const observation = buildObservationMessage(action.toolName, result.success, result.output || result.error || "No output");
|
|
95
88
|
const newState = appendHistory(state, {
|
|
@@ -117,7 +110,7 @@ export class AgentBrain {
|
|
|
117
110
|
// System prompt
|
|
118
111
|
messages.push({
|
|
119
112
|
role: "system",
|
|
120
|
-
content: buildSystemPrompt(this.tools, state.environment.os, state.environment.route),
|
|
113
|
+
content: buildSystemPrompt(this.tools, state.environment.os, state.environment.route, false),
|
|
121
114
|
});
|
|
122
115
|
// User's goal
|
|
123
116
|
messages.push({
|
|
@@ -176,9 +169,10 @@ export class AgentBrain {
|
|
|
176
169
|
}
|
|
177
170
|
// No parseable action — treat as thinking aloud
|
|
178
171
|
return {
|
|
179
|
-
type: "
|
|
172
|
+
type: "tool_call",
|
|
180
173
|
thought,
|
|
181
|
-
|
|
174
|
+
toolName: "INVALID_ACTION",
|
|
175
|
+
toolParams: {},
|
|
182
176
|
};
|
|
183
177
|
}
|
|
184
178
|
try {
|
|
@@ -187,9 +181,10 @@ export class AgentBrain {
|
|
|
187
181
|
}
|
|
188
182
|
catch {
|
|
189
183
|
return {
|
|
190
|
-
type: "
|
|
184
|
+
type: "tool_call",
|
|
191
185
|
thought,
|
|
192
|
-
|
|
186
|
+
toolName: "INVALID_ACTION",
|
|
187
|
+
toolParams: { error: `Invalid JSON in ACTION block: ${actionMatch[1]}` },
|
|
193
188
|
};
|
|
194
189
|
}
|
|
195
190
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"brain.js","sourceRoot":"","sources":["../../../src/agent/brain.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,iBAAiB,EACjB,mBAAmB,EACnB,uBAAuB,EAC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OAAe,EACf,MAA4D;QAE5D,IAAI,MAAM,CAAC,MAAM,KAAK,eAAe,EAAE,CAAC;YACtC,OAAO;gBACL,IAAI,EAAE,eAAe;gBACrB,OAAO;gBACP,OAAO,EACL,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,IAAI,EAAE,CAAC,IAAI,OAAO;aAClD,CAAC;QACJ,CAAC;QAED,IAAI,MAAM,CAAC,MAAM,KAAK,aAAa,EAAE,CAAC;YACpC,OAAO;gBACL,IAAI,EAAE,aAAa;gBACnB,OAAO;gBACP,MAAM,EACJ,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,IAAI,EAAE,CAAC,IAAI,OAAO;aACjD,CAAC;QACJ,CAAC;QAED,OAAO;YACL,IAAI,EAAE,WAAW;YACjB,OAAO;YACP,QAAQ,EAAE,MAAM,CAAC,MAAM;YACvB,UAAU,EAAE,MAAM,CAAC,MAAM,IAAI,EAAE;SAChC,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* format, and guardrails.
|
|
7
7
|
*/
|
|
8
8
|
import type { ToolRegistry } from "./tool-registry";
|
|
9
|
-
export declare function buildSystemPrompt(toolRegistry: ToolRegistry, os: string, route: string): string;
|
|
9
|
+
export declare function buildSystemPrompt(toolRegistry: ToolRegistry, os: string, route: string, useNativeToolCalling: boolean): string;
|
|
10
10
|
export declare function buildPlanningPrompt(userGoal: string): string;
|
|
11
11
|
export declare function buildReflectionPrompt(failedStep: string, errorOutput: string, attemptCount: number): string;
|
|
12
12
|
export declare function buildObservationMessage(toolName: string, success: boolean, output: string): string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prompts.d.ts","sourceRoot":"","sources":["../../../src/agent/prompts.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAGpD,wBAAgB,iBAAiB,CAC/B,YAAY,EAAE,YAAY,EAC1B,EAAE,EAAE,MAAM,EACV,KAAK,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"prompts.d.ts","sourceRoot":"","sources":["../../../src/agent/prompts.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAGpD,wBAAgB,iBAAiB,CAC/B,YAAY,EAAE,YAAY,EAC1B,EAAE,EAAE,MAAM,EACV,KAAK,EAAE,MAAM,EACb,oBAAoB,EAAE,OAAO,GAC5B,MAAM,CA6DR;AAGD,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAY5D;AAGD,wBAAgB,qBAAqB,CACnC,UAAU,EAAE,MAAM,EAClB,WAAW,EAAE,MAAM,EACnB,YAAY,EAAE,MAAM,GACnB,MAAM,CAiBR;AAGD,wBAAgB,uBAAuB,CACrC,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,OAAO,EAChB,MAAM,EAAE,MAAM,GACb,MAAM,CAGR"}
|
|
@@ -6,8 +6,28 @@
|
|
|
6
6
|
* format, and guardrails.
|
|
7
7
|
*/
|
|
8
8
|
// ─── System Identity Prompt ────────────────────────────────────────
|
|
9
|
-
export function buildSystemPrompt(toolRegistry, os, route) {
|
|
9
|
+
export function buildSystemPrompt(toolRegistry, os, route, useNativeToolCalling) {
|
|
10
10
|
const toolSummary = toolRegistry.getToolSummary();
|
|
11
|
+
const responseInstructions = useNativeToolCalling
|
|
12
|
+
? `Since you have native tool calling enabled, you MUST invoke exactly ONE tool for EVERY response.
|
|
13
|
+
Do not output raw JSON text blocks for actions; simply call the tool natively.
|
|
14
|
+
If you need to talk to the user or indicate completion/failure, use the TASK_COMPLETE or TASK_FAILED tools.`
|
|
15
|
+
: `For EVERY turn, output EXACTLY this format:
|
|
16
|
+
|
|
17
|
+
THOUGHT: <your reasoning about what to do next>
|
|
18
|
+
ACTION: <a single JSON object with "action" and "params" keys>
|
|
19
|
+
|
|
20
|
+
Example:
|
|
21
|
+
THOUGHT: I need to check if Anchor is installed before trying to build.
|
|
22
|
+
ACTION: {"action": "check_environment", "params": {}}
|
|
23
|
+
|
|
24
|
+
When you have completed the user's goal, output:
|
|
25
|
+
THOUGHT: <summary of what was accomplished>
|
|
26
|
+
ACTION: {"action": "TASK_COMPLETE", "params": {"summary": "<final summary>"}}
|
|
27
|
+
|
|
28
|
+
If you cannot accomplish the goal, output:
|
|
29
|
+
THOUGHT: <explanation of why>
|
|
30
|
+
ACTION: {"action": "TASK_FAILED", "params": {"reason": "<reason>"}}`;
|
|
11
31
|
return `You are the USO Agent — an autonomous AI assistant built into the Universal Solana Orchestrator CLI.
|
|
12
32
|
|
|
13
33
|
## Your Identity
|
|
@@ -19,39 +39,25 @@ You are an expert Solana developer and DevOps engineer. You help developers buil
|
|
|
19
39
|
- Current Directory: ${process.cwd()}
|
|
20
40
|
|
|
21
41
|
## Available Tools
|
|
22
|
-
You have access to
|
|
42
|
+
You have access to a set of tools to interact with the environment.
|
|
23
43
|
|
|
24
44
|
${toolSummary}
|
|
25
45
|
|
|
26
46
|
## How to Respond
|
|
27
47
|
You operate in a Thought → Action → Observation loop.
|
|
28
48
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
THOUGHT: <your reasoning about what to do next>
|
|
32
|
-
ACTION: <a single JSON object with "action" and "params" keys>
|
|
33
|
-
|
|
34
|
-
Example:
|
|
35
|
-
THOUGHT: I need to check if Anchor is installed before trying to build.
|
|
36
|
-
ACTION: {"action": "check_environment", "params": {}}
|
|
37
|
-
|
|
38
|
-
When you have completed the user's goal, output:
|
|
39
|
-
THOUGHT: <summary of what was accomplished>
|
|
40
|
-
ACTION: {"action": "TASK_COMPLETE", "params": {"summary": "<final summary>"}}
|
|
41
|
-
|
|
42
|
-
If you cannot accomplish the goal, output:
|
|
43
|
-
THOUGHT: <explanation of why>
|
|
44
|
-
ACTION: {"action": "TASK_FAILED", "params": {"reason": "<reason>"}}
|
|
49
|
+
${responseInstructions}
|
|
45
50
|
|
|
46
51
|
## Rules
|
|
47
|
-
1. ALWAYS output exactly ONE action per turn. Never output
|
|
48
|
-
2. ALWAYS
|
|
52
|
+
1. ALWAYS output exactly ONE action per turn. You MUST use a tool call or ACTION block for EVERY single response. Never just output plain text.
|
|
53
|
+
2. ALWAYS provide your reasoning before or during your tool call.
|
|
49
54
|
3. Use check_environment FIRST before attempting any build/test/deploy.
|
|
50
|
-
4. NEVER deploy to mainnet-beta without explicitly confirming with the user.
|
|
55
|
+
4. NEVER deploy to mainnet-beta without explicitly confirming with the user. If the user asked to deploy to devnet or testnet, proceed without asking for confirmation.
|
|
51
56
|
5. If a command fails, analyze the error and try a different approach. Don't repeat the same failing command.
|
|
52
57
|
6. Cap your terminal commands to reasonable timeouts.
|
|
53
58
|
7. When reading files, only read what's necessary. Don't dump entire codebases.
|
|
54
59
|
8. If you need to install missing tools, use the appropriate uso/solana/anchor commands.
|
|
60
|
+
9. If you need to talk to the user, use TASK_COMPLETE with your message as the summary, or TASK_FAILED if you are stuck.
|
|
55
61
|
|
|
56
62
|
## Error Recovery
|
|
57
63
|
When a tool returns an error:
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prompts.js","sourceRoot":"","sources":["../../../src/agent/prompts.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH,sEAAsE;AACtE,MAAM,UAAU,iBAAiB,CAC/B,YAA0B,EAC1B,EAAU,EACV,KAAa;
|
|
1
|
+
{"version":3,"file":"prompts.js","sourceRoot":"","sources":["../../../src/agent/prompts.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH,sEAAsE;AACtE,MAAM,UAAU,iBAAiB,CAC/B,YAA0B,EAC1B,EAAU,EACV,KAAa,EACb,oBAA6B;IAE7B,MAAM,WAAW,GAAG,YAAY,CAAC,cAAc,EAAE,CAAC;IAElD,MAAM,oBAAoB,GAAG,oBAAoB;QAC/C,CAAC,CAAC;;4GAEsG;QACxG,CAAC,CAAC;;;;;;;;;;;;;;;oEAe8D,CAAC;IAEnE,OAAO;;;;;;sBAMa,EAAE;mBACL,KAAK;uBACD,OAAO,CAAC,GAAG,EAAE;;;;;EAKlC,WAAW;;;;;EAKX,oBAAoB;;;;;;;;;;;;;;;;;;iFAkB2D,CAAC;AAClF,CAAC;AAED,sEAAsE;AACtE,MAAM,UAAU,mBAAmB,CAAC,QAAgB;IAClD,OAAO;;GAEN,QAAQ;;;;;;;;gEAQqD,CAAC;AACjE,CAAC;AAED,sEAAsE;AACtE,MAAM,UAAU,qBAAqB,CACnC,UAAkB,EAClB,WAAmB,EACnB,YAAoB;IAEpB,OAAO;;eAEM,UAAU;;;EAGvB,WAAW,CAAC,KAAK,CAAC,CAAC,EAAE,IAAI,CAAC;;;mBAGT,YAAY;;;;;;;gDAOiB,CAAC;AACjD,CAAC;AAED,sEAAsE;AACtE,MAAM,UAAU,uBAAuB,CACrC,QAAgB,EAChB,OAAgB,EAChB,MAAc;IAEd,MAAM,MAAM,GAAG,OAAO,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,UAAU,CAAC;IAClD,OAAO,gBAAgB,QAAQ,KAAK,MAAM,MAAM,MAAM,EAAE,CAAC;AAC3D,CAAC"}
|
|
@@ -47,15 +47,8 @@ export class AgentBrain {
|
|
|
47
47
|
maxTokens: 2048,
|
|
48
48
|
};
|
|
49
49
|
|
|
50
|
-
//
|
|
51
|
-
|
|
52
|
-
if (
|
|
53
|
-
this.llm.provider === "openai" ||
|
|
54
|
-
this.llm.provider === "github" ||
|
|
55
|
-
this.llm.provider === "gemini"
|
|
56
|
-
) {
|
|
57
|
-
options.tools = toolDefs;
|
|
58
|
-
}
|
|
50
|
+
// Removed native tool calling logic because GitHub Models' gpt-4o-mini often omits tool calls.
|
|
51
|
+
// We will rely entirely on the text-based THOUGHT/ACTION JSON format.
|
|
59
52
|
|
|
60
53
|
let response;
|
|
61
54
|
try {
|
|
@@ -76,26 +69,7 @@ export class AgentBrain {
|
|
|
76
69
|
};
|
|
77
70
|
}
|
|
78
71
|
|
|
79
|
-
// Handle native function calling responses
|
|
80
|
-
if (response.toolCalls && response.toolCalls.length > 0) {
|
|
81
|
-
const tc = response.toolCalls[0]; // Process one tool call at a time
|
|
82
|
-
const thought = response.content || `Calling ${tc.name}`;
|
|
83
72
|
|
|
84
|
-
const newState = appendHistory(state, {
|
|
85
|
-
role: "thought",
|
|
86
|
-
content: thought,
|
|
87
|
-
});
|
|
88
|
-
|
|
89
|
-
return {
|
|
90
|
-
action: {
|
|
91
|
-
type: "tool_call",
|
|
92
|
-
thought,
|
|
93
|
-
toolName: tc.name,
|
|
94
|
-
toolParams: tc.arguments,
|
|
95
|
-
},
|
|
96
|
-
state: newState,
|
|
97
|
-
};
|
|
98
|
-
}
|
|
99
73
|
|
|
100
74
|
// Parse text-based THOUGHT + ACTION format (for Ollama and fallback)
|
|
101
75
|
const action = this.parseTextResponse(response.content);
|
|
@@ -122,6 +96,27 @@ export class AgentBrain {
|
|
|
122
96
|
};
|
|
123
97
|
}
|
|
124
98
|
|
|
99
|
+
if (action.toolName === "INVALID_ACTION") {
|
|
100
|
+
const observation = buildObservationMessage(
|
|
101
|
+
"INVALID_ACTION",
|
|
102
|
+
false,
|
|
103
|
+
"You did not provide a valid JSON action block or native tool call. You MUST provide exactly ONE action."
|
|
104
|
+
);
|
|
105
|
+
const newState = appendHistory(state, {
|
|
106
|
+
role: "observation",
|
|
107
|
+
content: observation,
|
|
108
|
+
toolName: "INVALID_ACTION",
|
|
109
|
+
});
|
|
110
|
+
return {
|
|
111
|
+
observation,
|
|
112
|
+
success: false,
|
|
113
|
+
state: appendError(newState, {
|
|
114
|
+
message: "Invalid action format",
|
|
115
|
+
stepId: "parse",
|
|
116
|
+
}),
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
|
|
125
120
|
const result = await this.tools.execute(
|
|
126
121
|
action.toolName,
|
|
127
122
|
action.toolParams ?? {},
|
|
@@ -166,6 +161,7 @@ export class AgentBrain {
|
|
|
166
161
|
this.tools,
|
|
167
162
|
state.environment.os,
|
|
168
163
|
state.environment.route,
|
|
164
|
+
false, // Force useNativeToolCalling = false
|
|
169
165
|
),
|
|
170
166
|
});
|
|
171
167
|
|
|
@@ -235,9 +231,10 @@ export class AgentBrain {
|
|
|
235
231
|
|
|
236
232
|
// No parseable action — treat as thinking aloud
|
|
237
233
|
return {
|
|
238
|
-
type: "
|
|
234
|
+
type: "tool_call",
|
|
239
235
|
thought,
|
|
240
|
-
|
|
236
|
+
toolName: "INVALID_ACTION",
|
|
237
|
+
toolParams: {},
|
|
241
238
|
};
|
|
242
239
|
}
|
|
243
240
|
|
|
@@ -249,9 +246,10 @@ export class AgentBrain {
|
|
|
249
246
|
return this.classifyAction(thought, parsed);
|
|
250
247
|
} catch {
|
|
251
248
|
return {
|
|
252
|
-
type: "
|
|
249
|
+
type: "tool_call",
|
|
253
250
|
thought,
|
|
254
|
-
|
|
251
|
+
toolName: "INVALID_ACTION",
|
|
252
|
+
toolParams: { error: `Invalid JSON in ACTION block: ${actionMatch[1]}` },
|
|
255
253
|
};
|
|
256
254
|
}
|
|
257
255
|
}
|
|
@@ -13,9 +13,31 @@ export function buildSystemPrompt(
|
|
|
13
13
|
toolRegistry: ToolRegistry,
|
|
14
14
|
os: string,
|
|
15
15
|
route: string,
|
|
16
|
+
useNativeToolCalling: boolean,
|
|
16
17
|
): string {
|
|
17
18
|
const toolSummary = toolRegistry.getToolSummary();
|
|
18
19
|
|
|
20
|
+
const responseInstructions = useNativeToolCalling
|
|
21
|
+
? `Since you have native tool calling enabled, you MUST invoke exactly ONE tool for EVERY response.
|
|
22
|
+
Do not output raw JSON text blocks for actions; simply call the tool natively.
|
|
23
|
+
If you need to talk to the user or indicate completion/failure, use the TASK_COMPLETE or TASK_FAILED tools.`
|
|
24
|
+
: `For EVERY turn, output EXACTLY this format:
|
|
25
|
+
|
|
26
|
+
THOUGHT: <your reasoning about what to do next>
|
|
27
|
+
ACTION: <a single JSON object with "action" and "params" keys>
|
|
28
|
+
|
|
29
|
+
Example:
|
|
30
|
+
THOUGHT: I need to check if Anchor is installed before trying to build.
|
|
31
|
+
ACTION: {"action": "check_environment", "params": {}}
|
|
32
|
+
|
|
33
|
+
When you have completed the user's goal, output:
|
|
34
|
+
THOUGHT: <summary of what was accomplished>
|
|
35
|
+
ACTION: {"action": "TASK_COMPLETE", "params": {"summary": "<final summary>"}}
|
|
36
|
+
|
|
37
|
+
If you cannot accomplish the goal, output:
|
|
38
|
+
THOUGHT: <explanation of why>
|
|
39
|
+
ACTION: {"action": "TASK_FAILED", "params": {"reason": "<reason>"}}`;
|
|
40
|
+
|
|
19
41
|
return `You are the USO Agent — an autonomous AI assistant built into the Universal Solana Orchestrator CLI.
|
|
20
42
|
|
|
21
43
|
## Your Identity
|
|
@@ -27,39 +49,25 @@ You are an expert Solana developer and DevOps engineer. You help developers buil
|
|
|
27
49
|
- Current Directory: ${process.cwd()}
|
|
28
50
|
|
|
29
51
|
## Available Tools
|
|
30
|
-
You have access to
|
|
52
|
+
You have access to a set of tools to interact with the environment.
|
|
31
53
|
|
|
32
54
|
${toolSummary}
|
|
33
55
|
|
|
34
56
|
## How to Respond
|
|
35
57
|
You operate in a Thought → Action → Observation loop.
|
|
36
58
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
THOUGHT: <your reasoning about what to do next>
|
|
40
|
-
ACTION: <a single JSON object with "action" and "params" keys>
|
|
41
|
-
|
|
42
|
-
Example:
|
|
43
|
-
THOUGHT: I need to check if Anchor is installed before trying to build.
|
|
44
|
-
ACTION: {"action": "check_environment", "params": {}}
|
|
45
|
-
|
|
46
|
-
When you have completed the user's goal, output:
|
|
47
|
-
THOUGHT: <summary of what was accomplished>
|
|
48
|
-
ACTION: {"action": "TASK_COMPLETE", "params": {"summary": "<final summary>"}}
|
|
49
|
-
|
|
50
|
-
If you cannot accomplish the goal, output:
|
|
51
|
-
THOUGHT: <explanation of why>
|
|
52
|
-
ACTION: {"action": "TASK_FAILED", "params": {"reason": "<reason>"}}
|
|
59
|
+
${responseInstructions}
|
|
53
60
|
|
|
54
61
|
## Rules
|
|
55
|
-
1. ALWAYS output exactly ONE action per turn. Never output
|
|
56
|
-
2. ALWAYS
|
|
62
|
+
1. ALWAYS output exactly ONE action per turn. You MUST use a tool call or ACTION block for EVERY single response. Never just output plain text.
|
|
63
|
+
2. ALWAYS provide your reasoning before or during your tool call.
|
|
57
64
|
3. Use check_environment FIRST before attempting any build/test/deploy.
|
|
58
|
-
4. NEVER deploy to mainnet-beta without explicitly confirming with the user.
|
|
65
|
+
4. NEVER deploy to mainnet-beta without explicitly confirming with the user. If the user asked to deploy to devnet or testnet, proceed without asking for confirmation.
|
|
59
66
|
5. If a command fails, analyze the error and try a different approach. Don't repeat the same failing command.
|
|
60
67
|
6. Cap your terminal commands to reasonable timeouts.
|
|
61
68
|
7. When reading files, only read what's necessary. Don't dump entire codebases.
|
|
62
69
|
8. If you need to install missing tools, use the appropriate uso/solana/anchor commands.
|
|
70
|
+
9. If you need to talk to the user, use TASK_COMPLETE with your message as the summary, or TASK_FAILED if you are stuck.
|
|
63
71
|
|
|
64
72
|
## Error Recovery
|
|
65
73
|
When a tool returns an error:
|