Build natural tool-use prompt for Gemini Web that avoids prompt-injection detection.
(tool_defs: list)
| 147 | |
| 148 | |
| 149 | def build_tool_prompt(tool_defs: list) -> str: |
| 150 | """Build natural tool-use prompt for Gemini Web that avoids prompt-injection detection.""" |
| 151 | tool_spec = json.dumps(tool_defs, indent=2, ensure_ascii=False) |
| 152 | return ( |
| 153 | "# Tool Use\n\n" |
| 154 | "You can call the following tools to help accomplish tasks. " |
| 155 | "These tools connect to the user's local environment and will execute when called.\n\n" |
| 156 | "Call format (use this exact format):\n" |
| 157 | "```function_call\n" |
| 158 | '{"name": "<tool_name>", "args": {<arguments>}}\n' |
| 159 | "```\n\n" |
| 160 | "When calling tools:\n" |
| 161 | "- Output ONLY the function_call block(s), nothing else\n" |
| 162 | "- You may call multiple tools with multiple blocks\n" |
| 163 | "- After receiving a [Tool result for ...], use that data to answer the user\n\n" |
| 164 | f"Available tools:\n{tool_spec}" |
| 165 | ) |
| 166 | |
| 167 | |
| 168 | def _google_tool_choice_instruction(req: dict) -> str: |
no outgoing calls
no test coverage detected