How the Agent Works
The Thumper-Run AI agent is a reasoning engine that reads, thinks, and acts on your behalf.
Think of the agent as a junior developer with a specific set of tools. It can read files, search code, install apps, check GPU status, and edit configurations — but it always asks before making changes. It reasons step-by-step, showing its thought process so you can follow along.
Local by Default
Runs on your hardware with Ollama or llama.cpp. No data leaves your device unless you choose a cloud API.
32 Specialized Tools
Filesystem, app launcher, GPU diagnostics, model management, manifest authoring, and log analysis.
25-Step Reasoning
Up to 25 iterations of think → act → observe before delivering a final answer.
The ReAct Loop
The agent uses the ReAct (Reason + Act) framework. Each turn follows a 6-step handshake:
Example ReAct Trace
Thought: The user wants to install a chatbot. I should check what's available.Action: list_appsAction Input: {"query": "chatbot", "tag": "llm"}Observation: Found 3 apps: open-webui (4.5/5), sillytavern (4.3/5)Thought: Open WebUI is highest rated. I'll install it.Action: install_appAction Input: {"source_url": "https://github.com/open-webui/open-webui"}[Waiting for user confirmation...][User approved]Observation: Installation complete. App registered as "open-webui".Thought: Installation successful. I should tell the user.Final Answer: I've installed Open WebUI. You can launch it from the dashboard.
Safety rails: each reasoning step has a 60-second timeout. If the LLM produces malformed output, the executor retries once via step_with_retry with format hints. Context is trimmed at 80% utilization to prevent overflow.
Tool Dispatch
Tools are registered in a HashMap<String, Arc<dyn Tool>> by the ToolDispatcher. Each tool implements the Tool trait:
pub trait Tool: Send + Sync {fn name(&self) -> &str;fn description(&self) -> &str;fn parameters_schema(&self) -> serde_json::Value;fn requires_confirmation(&self) -> bool;async fn execute(&self, args: Value, ctx: ToolContext) -> ToolResult;}
6 Tool Factories
The dispatcher is built with a chain of factory methods, each adding a group of related tools:
| Factory | Tools | Source |
|---|---|---|
| Filesystem (Base Adapter) | file_read, file_write, file_edit, list_files, search_files, search_code, run_command, web_search | tr-adapters |
| Launcher | list_apps, app_status, install_app, launch_app, stop_app, app_logs | tr-services |
| GPU & Manifest Diagnostic | gpu_diagnose, gpu_test_pytorch, manifest_validate, manifest_generate, manifest_fix, install_debug, model_manage | tr-services |
| Model Intelligence | model_list, model_info, model_download, workflow_analyze, hardware_status | tr-services |
| Model Manifest v2 | model_manifest_validate, model_manifest_generate, model_cache_diagnose | tr-services |
| Log & Diagnostic | crash_log_debug, app_manifest_debug, app_diagnose | tr-services |
ToolResult
Every tool returns a ToolResult with: success (bool), output (string), artifacts (optional files/data), duration_ms, and error (optional). The result becomes the Observation in the ReAct trace.
ToolContext
Each tool execution receives a ToolContext with: session_id, project_root, working_directory, sandboxed: true, and max_execution_seconds. This scopes the tool's access to the project directory.
LLM Backends
The agent supports 5 LLM backends via the BackendKind enum. All support streaming responses.
| Backend | Protocol | Location | Models | Cost |
|---|---|---|---|---|
| LlamaCpp | Native C++ FFI | Local | Any .gguf file | Free |
| Ollama | REST localhost:11434 | Local | Ollama model library | Free |
| OpenAI Compatible | REST API | Cloud | Provider-dependent | Per token |
| Anthropic | REST API | Cloud | Claude family | Per token |
| Docker vLLM | REST to container | Local | Any HF model | Free |
Local backends (LlamaCpp, Ollama, Docker vLLM) keep all data on your device. Cloud backends (OpenAI Compatible, Anthropic) send conversation text to the API provider — tool results stay local.
Prompt Assembly
The system prompt is assembled from multiple sources, each with a priority level. Higher priority sections are placed first and are more resistant to context trimming.
| Priority | Layer | Content |
|---|---|---|
| 10 | Tool Definitions | JSON schemas for all 32 tools + ReAct format instructions |
| 9 | User Instructions | Custom system_prompt override (if configured) |
| 8 | Platform Knowledge | "You are the AI assistant embedded in Thumper-Run..." — app concepts, manifest schema |
| 7 | Launcher Knowledge | Tool-by-tool guidance (when launcher tools are available) |
| 6 | Template | code-helper or research-agent specialization |
| 5 | Session Context | working_directory, apps_directory, models_directory, platform |
| 3 | External Knowledge | ~/.local/share/tr-desktop/agent_knowledge.md (max ~2000 chars) |
Tool Guidelines
The platform knowledge section includes these core guidelines that shape agent behavior:
- If the user asks about a file, READ it first (don't guess contents)- If the user asks to change something, READ current state THEN EDIT- If the user asks about apps or models, LIST the relevant directory first- NEVER claim you can't access files — use file_read and search_code tools- ALWAYS show the user what you found before giving advice
Deep Dive
For implementation details, these are the key source files:
| File | Lines | Purpose |
|---|---|---|
| orchestrator.rs | ~1,300 | Session lifecycle, message routing, tool execution coordination |
| executor.rs | ~1,300 | ReAct loop, step_with_retry, context management, output parsing |
| tool_dispatcher.rs | ~250 | HashMap registration, factory builder pattern |
| prompt_builder.rs | ~370 | Priority-based prompt assembly, template injection |
| config.rs | ~100 | Executor defaults: max_iterations=25, timeout=300s, context_size=4096 |
| agent.rs (IPC) | ~770 | 15 Tauri IPC commands for frontend integration |
Key Takeaways
- ReAct = Reason + Act — the agent thinks before each tool call
- 32 tools across 6 factories (filesystem, launcher, GPU, model, manifest, logs)
- 25 tools are safe (auto-run), 7 require your confirmation
- 60-second timeout per reasoning step, 300 seconds per session
- Fully local by default — nothing leaves your device with Ollama or llama.cpp
- System prompt assembled from 7 priority levels (10 = critical, 3 = low)