AGENT_TOOLS = "[\n {\n \"type\": \"function\",\n \"function\": {\n \"name\": \"list_directory\",\n \"description\": \"
Return project directory structure up to max_depth.\",\n \"parameters\": {\n \"type\": \"object\",\n \"properties\": {\n \"path\": {\n \"type\": \"string\",\n \"default\": \".\"\n },\n \"max_depth\": {\n \"type\": \"integer\",\n \"minimum\": 1,\n \"maximum\": 6,\n \"default\": 3\n }\n },\n \"additional
Properties\": false\n }\n }\n },\n {\n \"type\": \"function\",\n \"function\": {\n \"name\": \"read_file\",\n \"description\": \"
Read file content for endpoint extraction.\",\n \"parameters\": {\n \"type\": \"object\",\n \"properties\": {\n \"path\": {\n \"type\": \"string\"\n }\n },\n \"required\": [\"path\"],\n \"additional
Properties\": false\n }\n }\n },\n {\n \"type\": \"function\",\n \"function\": {\n \"name\": \"grep\",\n \"description\": \"
Regex search in codebase.\",\n \"parameters\": {\n \"type\": \"object\",\n \"properties\": {\n \"pattern\": {\n \"type\": \"string\"\n },\n \"path\": {\n \"type\": \"string\",\n \"default\": \".\"\n },\n \"file_pattern\": {\n \"type\": \"string\",\n \"default\": \"*\"\n }\n },\n \"required\": [\"pattern\"],\n \"additional
Properties\": false\n }\n }\n },\n {\n \"type\": \"function\",\n \"function\": {\n \"name\": \"semantic_search\",\n \"description\": \"
Semantic-like search for code using natural language query.\",\n \"parameters\": {\n \"type\": \"object\",\n \"properties\": {\n \"query\": {\n \"type\": \"string\"\n }\n },\n \"required\": [\"query\"],\n \"additional
Properties\": false\n }\n }\n },\n {\n \"type\": \"function\",\n \"function\": {\n \"name\": \"finalize\",\n \"description\": \"
Finalize extraction and return endpoint list.\",\n \"parameters\": {\n \"type\": \"object\",\n \"properties\": {\n \"endpoints\": {\n \"type\": \"array\",\n \"items\": {\n \"type\": \"object\",\n \"properties\": {\n \"url\": { \"type\": \"string\" },\n \"path\": { \"type\": \"string\" },\n \"method\": { \"type\": \"string\" },\n \"file\": { \"type\": \"string\" },\n \"line\": { \"type\": \"integer\" },\n \"params\": {\n \"type\": \"array\",\n \"items\": {\n \"type\": \"object\",\n \"properties\": {\n \"name\": { \"type\": \"string\" },\n \"param_type\": { \"type\": \"string\" },\n \"value\": { \"type\": \"string\" }\n },\n \"required\": [\"name\"],\n \"additional
Properties\": true\n }\n }\n },\n \"required\": [\"method\"],\n \"additional
Properties\": true\n }\n },\n \"summary\": { \"type\": \"string\" },\n \"confidence\": { \"type\": \"integer\" }\n },\n \"required\": [\"endpoints\"],\n \"additional
Properties\": true\n }\n }\n }\n]"
MODEL_TOKEN_LIMITS = {"openai" => {"gpt-3.5-turbo" => 16385, "gpt-3.5-turbo-16k" => 16385, "gpt-4" => 8192, "gpt-4-32k" => 32768, "gpt-4-turbo" => 128000, "gpt-4-turbo-preview" => 128000, "gpt-4-vision-preview" => 128000, "gpt-4-1106-preview" => 128000, "gpt-4-0125-preview" => 128000, "gpt-4o" => 128000, "gpt-4o-mini" => 128000, "o1-preview" => 128000, "o1-mini" => 128000, "o3-mini" => 200000, "gpt-5" => 1000000, "gpt-5-pro" => 1000000, "gpt-5-mini" => 1000000, "gpt-5-nano" => 1000000, "gpt-5-codex" => 1000000, "gpt-5.1" => 1000000, "gpt-5.1-codex" => 1000000, "gpt-5.1-codex-max" => 1000000, "gpt-5.1-codex-mini" => 1000000, "gpt-5.2-codex" => 1000000, "gpt-5.3-codex" => 1000000, "gpt-5.4" => 1000000, "gpt-5.4-pro" => 1000000, "gpt-5.4-mini" => 1000000, "gpt-5.4-nano" => 1000000, "gpt-5.5" => 1000000, "gpt-5.5-pro" => 1000000, "gpt-5.5-mini" => 1000000, "gpt-5.5-nano" => 1000000, "gpt-5.6-sol" => 1000000, "gpt-5.6-terra" => 1000000, "gpt-5.6-luna" => 1000000, "default" => 8000}, "xai" => {"grok-1" => 8192, "grok-2" => 131072, "grok-2-mini" => 131072, "grok-beta" => 131072, "grok-3" => 1000000, "grok-4" => 2000000, "grok-4-fast-reasoning" => 2000000, "grok-4-fast-non-reasoning" => 2000000, "grok-4.1-fast" => 2000000, "grok-4.20" => 2000000, "grok-4.3" => 2000000, "grok-4.5" => 500000, "grok-4.5-latest" => 500000, "grok-code-fast" => 2000000, "grok-code-fast-1" => 2000000, "grok-build-0.1" => 256000, "default" => 8000}, "anthropic" => {"claude-3-opus" => 200000, "claude-3-sonnet" => 200000, "claude-3-haiku" => 200000, "claude-3-5-sonnet" => 200000, "claude-3-5-haiku" => 200000, "claude-2" => 100000, "claude-2.0" => 100000, "claude-2.1" => 200000, "claude-instant-1.2" => 100000, "claude-sonnet-4" => 1000000, "claude-sonnet-4-5" => 1000000, "claude-sonnet-4-6" => 1000000, "claude-sonnet-5" => 1000000, "claude-haiku-4-5" => 200000, "claude-opus-4" => 200000, "claude-opus-4-1" => 200000, "claude-opus-4.1" => 200000, "claude-opus-4-5" => 200000, "claude-opus-4-6" => 200000, "claude-opus-4-7" => 200000, "claude-opus-4-8" => 1000000, "claude-fable-5" => 1000000, "claude-mythos-5" => 1000000, "default" => 100000}, "azure" => {"gpt-3.5-turbo" => 16385, "gpt-3.5-turbo-16k" => 16385, "gpt-4" => 8192, "gpt-4-32k" => 32768, "gpt-4-turbo" => 128000, "gpt-4-turbo-preview" => 128000, "gpt-4-vision-preview" => 128000, "gpt-4o" => 128000, "gpt-4o-mini" => 128000, "o1-preview" => 128000, "o1-mini" => 128000, "gpt-4.1" => 1000000, "gpt-5" => 1000000, "gpt-5.1-codex-max" => 1000000, "gpt-5.4" => 1000000, "gpt-5.4-mini" => 1000000, "gpt-5.5" => 1000000, "gpt-5.5-pro" => 1000000, "gpt-5.5-mini" => 1000000, "gpt-5.6-sol" => 1000000, "gpt-5.6-terra" => 1000000, "gpt-5.6-luna" => 1000000, "default" => 8000}, "github" => {"gpt-4o" => 64000, "gpt-4o-mini" => 64000, "Phi-3.5-mini-instruct" => 128000, "Phi-3.5-MoE-instruct" => 128000, "Meta-Llama-3.1-405B-Instruct" => 128000, "Meta-Llama-3.1-70B-Instruct" => 128000, "Meta-Llama-3.1-8B-Instruct" => 128000, "Mistral-large" => 128000, "Mistral-large-2407" => 128000, "Mistral-Nemo" => 128000, "Mistral-small" => 32768, "AI21-Jamba-1.5-Large" => 256000, "AI21-Jamba-1.5-Mini" => 256000, "Cohere-command-r" => 128000, "Cohere-command-r-plus" => 128000, "default" => 8000}, "ollama" => {"llama3" => 128000, "llama3.1" => 128000, "llama3.2" => 128000, "llama3.3" => 128000, "llama4" => 512000, "llama4-maverick" => 256000, "phi2" => 2048, "phi3" => 128000, "phi3.5" => 128000, "phi4" => 16384, "phi4-mini" => 128000, "gemma" => 8192, "gemma2" => 8192, "gemma3" => 128000, "gemma4" => 128000, "mistral" => 32768, "mixtral" => 32768, "codellama" => 100000, "deepseek-coder" => 100000, "qwen2" => 128000, "qwen2.5" => 128000, "qwen3" => 256000, "qwen3-coder" => 256000, "deepseek-v3" => 128000, "deepseek-v3.1" => 128000, "deepseek-v3.2" => 128000, "deepseek-v4-pro" => 1000000, "deepseek-v4-flash" => 1000000, "deepseek-r1" => 128000, "gpt-oss" => 128000, "gpt-oss-120b" => 128000, "gpt-oss-20b" => 128000, "default" => 4000}, "google" => {"gemini-1.5-pro" => 2097152, "gemini-1.5-flash" => 1048576, "gemini-1.0-pro" => 32760, "gemini-pro" => 32760, "gemini-pro-vision" => 16384, "gemini-2.0-flash-exp" => 1048576, "gemini-2.5-pro" => 2000000, "gemini-2.5-flash" => 1048576, "gemini-2.5-flash-lite" => 1048576, "gemini-3-pro-preview" => 2000000, "gemini-3.1-pro-preview" => 2000000, "gemini-3-flash-preview" => 1048576, "gemini-3.1-flash-preview" => 1048576, "gemini-3.1-flash-lite-preview" => 1048576, "gemini-3.5-flash" => 1048576, "default" => 32760}, "cohere" => {"command-r" => 256000, "command-r-plus" => 256000, "command" => 4096, "command-light" => 4096, "command-nightly" => 8192, "command-light-nightly" => 8192, "default" => 4096}, "vllm" => {"default" => 4000}, "lmstudio" => {"gpt-oss" => 128000, "gpt-oss-120b" => 128000, "gpt-oss-20b" => 128000, "default" => 4000}, "openrouter" => {"default" => 128000}, "default" => 4000}
Map of LLM providers and their models to their max token limits
This helps determine how many files can be bundled together