Overview
Tool calling lets AI models perform actions beyond text generation. Instead of saying “I don’t know the current weather,” the model can call a web search tool to find the answer. Off Grid includes built-in tools for web search, calculations, date/time, and device information — all running on-device except web search (which requires network).Available Tools
Web Search
Web Search
Web Search
Search the web for current information via Brave Search.Use cases:- “What’s the weather in New York?”
- “Latest news about AI”
- “Who won the Super Bowl in 2024?”
- Scrapes Brave Search for top 5 results
- Returns titles, snippets, and clickable URLs
- URLs open in your system browser when tapped
- Network connection (only tool that requires internet)
- Empty queries fall back to your last message
Calculator
Calculator
Calculator
Evaluate mathematical expressions safely.Supported operations:- Basic:
+,-,*,/,% - Exponentiation:
^(e.g.,2^8 = 256) - Parentheses:
(,) - Decimals:
3.14,0.5
- “What’s 15% of 230?”
- “Calculate (45 + 17) * 3”
- “2^10 equals what?”
- Recursive descent parser (no
eval()— 100% safe) - Supports nested parentheses and operator precedence
- Returns the expression and result:
(45 + 17) * 3 = 186
- Only basic math operations (no trigonometry, logarithms, etc.)
- No variables or functions
Date & Time
Date & Time
Date & Time
Get the current date and time with optional timezone support.Use cases:- “What time is it?”
- “What’s the date today?”
- “What time is it in Tokyo?”
- Uses IANA timezone database (e.g.,
America/New_York,Asia/Tokyo) - Defaults to device timezone if not specified
- Gracefully handles invalid timezones
Device Info
Device Info
Device Info
Retrieve device hardware information.Available info types:- Battery: Level and charging status
- Memory: Total, used, and available RAM
- Storage: Total and free disk space
- All: Device model, OS, and all of the above
- “How much battery do I have?”
- “Check available storage”
- “What’s my device info?”
- All data comes from
react-native-device-info(local queries only) - No network requests
- No data leaves your device
URL Reader
URL Reader
URL Reader
Fetch and read the content of a web page.Use cases:- “Summarize this article: https://example.com/article”
- “What does this page say? https://news.com/story”
- Fetches the URL via HTTP GET
- Strips HTML tags to extract readable text
- Truncates to 4000 characters to fit context window
- Blocks private/local URLs (localhost, 192.168.x.x, 10.x.x.x, cloud metadata endpoints)
- SSRF protection — Prevents access to internal network resources
- 15-second timeout — Prevents hanging on slow servers
- Only works with public HTTP/HTTPS URLs
- JavaScript-heavy sites may not render properly (fetches HTML source)
- Some sites block mobile user agents
Which Models Support Tool Calling?
Not all models support tool calling. Off Grid automatically detects tool calling capability at model load time by inspecting the model’s jinja chat template.Supported Models
- Qwen 3 (all sizes) ✅
- Gemma 3 ✅
- Llama 3.2 ✅
- Phi-4 ✅
- Command-R ✅
- Mistral (most recent versions) ✅
Unsupported Models
- Older Llama models (pre-3.2) ❌
- Small instruction models without tool schemas ❌
- Base models (non-instruct) ❌
How to Use
1. Load a Tool-Compatible Model
- Download a model that supports tool calling (e.g., Qwen 3 3B)
- Load it in a conversation
- Check if the Tools button appears in the chat input (next to the microphone)
- If the button is grayed out, the model doesn’t support tools
2. Enable Tools
Tap the Tools button to toggle tool calling on/off for the current conversation:- On (highlighted) — Model can call tools
- Off (gray) — Model only generates text
3. Configure Which Tools Are Available
- Go to Settings → Model Settings → Text Generation → Enabled Tools
- Toggle individual tools on/off:
- ✅ Web Search
- ✅ Calculator (enabled by default)
- ✅ Date & Time (enabled by default)
- ✅ Device Info
- ✅ URL Reader
Tool configuration is global — applies to all models and conversations. You can toggle tools on/off per conversation via the Tools button.
4. Ask Questions That Require Tools
Just ask naturally — the model decides when to use tools: Examples:- “What’s the weather in Tokyo?” → Web Search
- “Calculate 15% of 230” → Calculator
- “What time is it in London?” → Date & Time
- “How much RAM do I have?” → Device Info
- “Summarize this page: https://…” → URL Reader
- Tool call indicator — Shows which tool(s) the model is calling
- Tool results — The tool’s output (e.g., search results, calculation answer)
- Final response — The model synthesizes tool results into a natural answer
Tool Loop Behavior
To prevent runaway loops and excessive API calls, Off Grid enforces limits:- Max iterations: 3 per generation
- Max total tool calls: 5 across all iterations
How the Loop Works
Fallback XML Parsing
Some smaller models don’t support structured tool calls but can emit XML tags:Examples
Web Search Example
User: “What’s the latest iPhone?” Model (internal): Calls web_search tool with query “latest iPhone 2026” Tool Result:Calculator Example
User: “What’s 23% of 890?” Model (internal): Calls calculator tool with expression “890 * 0.23” Tool Result:890 * 0.23 = 204.7
Model (final response): “23% of 890 is 204.7.”
Multi-Tool Example
User: “What time is it in Tokyo and how much battery do I have?” Model (internal): Calls both get_current_datetime (timezone: Asia/Tokyo) and get_device_info (info_type: battery) Tool Results:- Date/Time:
Current date and time: Saturday, March 4, 2026, 2:42 AM Japan Standard Time... - Device Info:
Battery: 73% (charging)
Technical Details
Tool Definition Schema
Tools are defined insrc/services/tools/registry.ts:
OpenAI Schema Conversion
Tools are converted to OpenAI’s function calling schema and passed to llama.rn:Tool Execution
Tool calls are executed insrc/services/tools/handlers.ts:
ToolResult with:
toolCallId— Matches the model’s call IDname— Tool namecontent— Tool output (or empty if error)error— Error message (if tool failed)durationMs— Execution time
System Prompt Hint
When tools are enabled, Off Grid injects a hint into the system prompt:Tips
Getting the Best Results
- Use tool-compatible models — Qwen 3, Gemma 3, Llama 3.2 work best
- Enable only needed tools — Fewer tools = less confusion for the model
- Ask specific questions — “What’s 23% of 890?” vs. “Do some math”
- Disable tools when not needed — Tap the Tools button to toggle off
- Check network for web search — Web search requires internet, other tools work offline
Troubleshooting
Tools button is grayed out:- Your model doesn’t support tool calling
- Try loading a different model (Qwen 3, Gemma 3, Llama 3.2)
- Ensure tools are enabled (Tools button highlighted)
- Check that the tool is enabled in settings (Settings → Model Settings → Enabled Tools)
- Try rephrasing your question more explicitly
- Check your network connection
- Brave Search may be blocking requests (rare)
- Try a different search query
- Ensure the expression only uses supported operators (
+,-,*,/,%,^,(,)) - No variables or functions (e.g.,
sin(),log()) — use a more capable calculator app for advanced math
- The model is stuck in a loop
- Try disabling tools and asking the question again
- Or rephrase to be more specific
Privacy
Most tools run 100% on-device:- Calculator — No network, all local
- Date & Time — No network, all local
- Device Info — No network, all local
- Web Search — Sends queries to Brave Search (HTTPS)
- URL Reader — Fetches the specified URL (HTTPS)