Tools API Reference¶
tools.specs ¶
Tool Specifications — JSON Schema definitions para function-calling nativo. Reemplaza el antiguo sistema text-based de build_tool_instructions().
Functions¶
expand_allowed_tools ¶
Expand tool group names into individual tool names.
If an allowed_tools entry is NOT an exact match for any TOOL_DEFINITIONS key, treat it as a prefix and expand to all matching keys. This bridges the gap between agent profiles (e.g., tools: ["browser"]) and MCP-registered tool names (e.g., "mcp_browser_browser_navigate" sanitized for DeepSeek strict mode).
Example: ["browser", "file_manager"] → ["mcp_browser_browser_navigate", ..., "file_manager"]
Source code in tools/specs.py
build_tool_definitions ¶
Devuelve las definiciones de herramientas en formato OpenAI function-calling. Si allowed_tools es None, devuelve todas. Si es una lista, filtra por nombres.
Source code in tools/specs.py
build_tool_instructions ¶
build_tool_instructions(
allowed_tools: list[str] | None = None,
project_root: str | None = None,
plan_mode: bool = True,
) -> str
Instrucciones textuales para el LLM (fallback cuando no hay function-calling nativo). Mantenido por compatibilidad con el modo Ollama y el sistema legacy.
Source code in tools/specs.py
tool_matches_allowlist ¶
Check if a tool name matches the workflow allowlist.
Supports exact match, prefix match (mcp:browser. vs 'browser'), component match ('mcp:browser' in tool_name), and sanitized prefix match (mcp_browser_ for DeepSeek strict mode compat).
Source code in tools/specs.py
tools.registry ¶
Classes¶
ToolsRegistry ¶
Registro de herramientas — instanciable, no singleton.
La instancia global legacy 'tools_registry' se mantiene para backward compat. Para nuevos entry points o tests, crear ToolsRegistry() directamente.
Source code in tools/registry.py
tools.orchestrator ¶
Tool Orchestrator Avanzado - Versión Final Robusta (Prioridad 3) - Retries y backoff alineados con models_controller - Mejor manejo de errores y mensajes amigables - Token budget aislado por workflow vía contextvars (thread/async-safe)
Classes¶
ToolOrchestrator ¶
Source code in tools/orchestrator.py
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 | |
Functions¶
reset_token_budget
staticmethod
¶
Reinicia el presupuesto de tokens al inicio de cada workflow. El contextvar garantiza aislamiento entre workflows concurrentes.
Source code in tools/orchestrator.py
Functions¶
tools.wrapper ¶
Wrapper de alto nivel para tool calls (usado por workflow_orchestrator) Incluye instrumentación de métricas por herramienta (latencia + éxito/fallo).
Functions¶
safe_tool_call
async
¶
safe_tool_call(
tool_name: str,
parameters: dict,
role: str = "agent",
workspace: str = "main",
session_id: str | None = None,
)
Wrapper simple y seguro para usar en workflow_orchestrator. Routes MCP-prefixed tools to the appropriate MCP client. Records per-tool metrics (latency, success/failure).
Source code in tools/wrapper.py
tools.loader ¶
Functions¶
load_global_tools ¶
Carga las herramientas globales desde la carpeta 'tools/'.
Source code in tools/loader.py
load_workspace_tools ¶
Carga herramientas locales desde workspaces/
Source code in tools/loader.py
unload_workspace_tools ¶
Elimina del registro las herramientas del workspace anterior.
Source code in tools/loader.py
tools.file_manager ¶
File Manager - Versión Profesional y Robusta - Alias file_path / path - Normalización inteligente de rutas: 1. Elimina el prefijo completo project_root si ya está presente. 2. Elimina el nombre del proyecto como primer componente si coincide con el último segmento de project_root. - Validación sintáctica de archivos .py antes de escribir - I/O vía asyncio.to_thread() para no bloquear el event loop
tools.bash_manager ¶
Bash Manager — safe shell command execution.
Core CLI tool. Executes commands in the project workspace with timeout, sanitization, and dangerous pattern blocking.
Functions¶
tools.lsp_manager ¶
LSP Manager — Análisis de código con Jedi + Ruff diagnostics.
Classes¶
LspManager ¶
Source code in tools/lsp_manager.py
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 | |
Functions¶
diagnostics
async
¶
Analiza archivos Python en busca de problemas (vacíos, sintaxis, etc.).
Source code in tools/lsp_manager.py
ruff_check
async
¶
Ejecuta ruff como linter real con salida estructurada.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
file |
str | None
|
Archivo específico a analizar (None = todo el proyecto). |
None
|
fix |
bool
|
Si True, aplica auto-correcciones (ruff --fix). |
False
|
Returns:
| Type | Description |
|---|---|
str
|
Reporte estructurado de issues encontrados. |
Source code in tools/lsp_manager.py
references
async
¶
Busca todas las referencias a un símbolo en el proyecto.
Source code in tools/lsp_manager.py
Functions¶
lsp_manager_tool
async
¶
lsp_manager_tool(
action: str = "diagnostics",
file: str = "",
line: int = 0,
character: int = 0,
project_root: str | None = None,
workspace: str = "main",
**kwargs
) -> str
Herramienta LSP profesional - usa project_root si se proporciona.
Source code in tools/lsp_manager.py
tools.code_execution ¶
tools.pdf_reader ¶
Functions¶
pdf_read_tool
async
¶
pdf_read_tool(
path: str,
workspace: str = "main",
project_root: str | None = None,
**kwargs
) -> str
Extrae texto de archivos PDF con validación de path traversal.
Source code in tools/pdf_reader.py
tools.ask_clarification ¶
Clarification tool — allows agents to ask the user questions mid-workflow.