(schemas: ToolSchema[])
| 57 | * Empty string if no schemas (the model just answers in prose, which is correct). |
| 58 | */ |
| 59 | export 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 | |
| 64 | You have NO native tool channel, so you act by writing a special TEXT tag. This is the ONLY |
| 65 | way anything actually happens. Writing a command in a \`\`\`code block\`\`\`, or as "shell: ..." |
| 66 | or "I would run ...", does NOTHING — the file is never created, the command never runs. |
| 67 | |
| 68 | To DO something, write EXACTLY this and nothing else: |
| 69 | |
| 70 | <tool_call>{"name": "<EXACT_TOOL_NAME>", "arguments": { ...json... }}</tool_call> |
| 71 | |
| 72 | Hard rules: |
| 73 | 1. 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\`. |
| 75 | 2. 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. |
| 77 | 3. 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. |
| 80 | 4. After your tool calls, STOP. The results arrive next turn. Don't invent the output. |
| 81 | 5. ONLY when the whole task is finished and you need no tool, reply in plain prose (no tag). |
| 82 | |
| 83 | Worked 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 |
no outgoing calls
no test coverage detected