MCPcopy Create free account
hub / github.com/QodeXcli/QodeX / buildTextToolInstructions

Function buildTextToolInstructions

src/llm/text-tool-protocol.ts:59–93  ·  view source on GitHub ↗
(schemas: ToolSchema[])

Source from the content-addressed store, hash-verified

57 * Empty string if no schemas (the model just answers in prose, which is correct).
58 */
59export function buildTextToolInstructions(schemas: ToolSchema[]): string {
60 if (schemas.length === 0) return '';
61 const toolList = schemas.map(renderToolSpec).join('\n');
62 return `# HOW TO ACT — READ THIS FIRST (this overrides any other instinct)
63
64You have NO native tool channel, so you act by writing a special TEXT tag. This is the ONLY
65way anything actually happens. Writing a command in a \`\`\`code block\`\`\`, or as "shell: ..."
66or "I would run ...", does NOTHING — the file is never created, the command never runs.
67
68To DO something, write EXACTLY this and nothing else:
69
70<tool_call>{"name": "<EXACT_TOOL_NAME>", "arguments": { ...json... }}</tool_call>
71
72Hard rules:
731. Use the EXACT tool name from the list below. To run a shell command the tool is \`bash\`
74 (NOT "shell"). To create a file it is \`write_file\`. To edit it is \`edit_file\`.
752. Inside the tags: ONE valid JSON object with "name" and "arguments". "arguments" holds the
76 tool's parameters. Escape newlines inside strings as \\n — never a raw line break in JSON.
773. NEVER describe the command in prose or a markdown code block instead of calling it. If you
78 catch yourself writing "I would run \`echo ...\`" or "\`\`\`shell" — STOP and write the
79 <tool_call> tag instead.
804. After your tool calls, STOP. The results arrive next turn. Don't invent the output.
815. ONLY when the whole task is finished and you need no tool, reply in plain prose (no tag).
82
83Worked examples (copy this shape exactly):
84- Create a file:
85 <tool_call>{"name": "write_file", "arguments": {"path": "hello.txt", "content": "Hello, QodeX!\\n"}}</tool_call>
86- Run a shell command:
87 <tool_call>{"name": "bash", "arguments": {"command": "ls -la"}}</tool_call>
88- Read a file:
89 <tool_call>{"name": "read_file", "arguments": {"path": "src/index.ts"}}</tool_call>
90
91## Available tools (use these EXACT names)
92${toolList}`;
93}
94
95/**
96 * Return a copy of `messages` with the text-tool protocol block injected as its OWN system

Callers 2

runMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected