feat: enhanced tool instructions for multi-step operations
- Add comprehensive examples for ls, find, grep, mkdir, npm init, etc. - Explain multi-step workflow (explore → read → write) - Tool system already supports chaining via conversation history - Bash tool supports: ls, find, grep, cat, mkdir, cd, npm, etc. - 30 second timeout on commands - Output limited to 3000 chars for readability
This commit is contained in:
+34
-6
@@ -67,19 +67,47 @@ def format_messages_with_tools(messages: list, tools: Optional[list] = None) ->
|
||||
if tools and not has_tool_results and not has_assistant_response:
|
||||
tool_instructions = """You have access to these tools:
|
||||
|
||||
read: Read a file (filePath)
|
||||
write: Write to a file (filePath, content)
|
||||
bash: Run a shell command (command)
|
||||
read: Read a file content
|
||||
- filePath: path to file
|
||||
|
||||
write: Create or overwrite a file
|
||||
- filePath: path to file
|
||||
- content: file content
|
||||
|
||||
bash: Execute shell commands
|
||||
- command: the shell command to run
|
||||
Use for: ls, find, grep, cat, mkdir, cd, etc.
|
||||
|
||||
When you need to use a tool, respond with ONLY this format:
|
||||
TOOL: tool_name
|
||||
ARGUMENTS: {"param": "value"}
|
||||
|
||||
Example:
|
||||
Examples:
|
||||
Read a file:
|
||||
TOOL: read
|
||||
ARGUMENTS: {"filePath": "hello.txt"}
|
||||
ARGUMENTS: {"filePath": "config.yaml"}
|
||||
|
||||
Do not explain - just output TOOL: and ARGUMENTS: when using tools."""
|
||||
List directory contents:
|
||||
TOOL: bash
|
||||
ARGUMENTS: {"command": "ls -la"}
|
||||
|
||||
Search for files:
|
||||
TOOL: bash
|
||||
ARGUMENTS: {"command": "find . -name '*.py'"}
|
||||
|
||||
Search in file contents:
|
||||
TOOL: bash
|
||||
ARGUMENTS: {"command": "grep -r 'port' ."}
|
||||
|
||||
Write a file:
|
||||
TOOL: write
|
||||
ARGUMENTS: {"filePath": "hello.txt", "content": "Hello World!"}
|
||||
|
||||
Create a project:
|
||||
TOOL: bash
|
||||
ARGUMENTS: {"command": "mkdir myproject && cd myproject && npm init -y"}
|
||||
|
||||
IMPORTANT: You can use multiple tools in sequence. If you need to explore first (ls, find), then read files, then write results - do it step by step. The system will execute each tool and return results before your next response."""
|
||||
|
||||
# Add to system message or create one
|
||||
has_system = False
|
||||
|
||||
Reference in New Issue
Block a user