~10 min read
Beta

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:

1
Message sent — your request enters the conversation
2
LLM reasons — outputs a Thought: block explaining its plan
3
Selects tool — outputs Action: and Action Input: with JSON args
4
Permission check — if requires_confirmation, you approve or deny
5
Tool executes — runs with timeout, returns ToolResult
6
Observation returned — result feeds back into LLM context. Loop repeats or agent gives Final Answer.

Example ReAct Trace

text
Thought: The user wants to install a chatbot. I should check what's available.
Action: list_apps
Action 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_app
Action 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:

rust
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:

FactoryToolsSource
Filesystem (Base Adapter)file_read, file_write, file_edit, list_files, search_files, search_code, run_command, web_searchtr-adapters
Launcherlist_apps, app_status, install_app, launch_app, stop_app, app_logstr-services
GPU & Manifest Diagnosticgpu_diagnose, gpu_test_pytorch, manifest_validate, manifest_generate, manifest_fix, install_debug, model_managetr-services
Model Intelligencemodel_list, model_info, model_download, workflow_analyze, hardware_statustr-services
Model Manifest v2model_manifest_validate, model_manifest_generate, model_cache_diagnosetr-services
Log & Diagnosticcrash_log_debug, app_manifest_debug, app_diagnosetr-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.

BackendProtocolLocationModelsCost
LlamaCppNative C++ FFILocalAny .gguf fileFree
OllamaREST localhost:11434LocalOllama model libraryFree
OpenAI CompatibleREST APICloudProvider-dependentPer token
AnthropicREST APICloudClaude familyPer token
Docker vLLMREST to containerLocalAny HF modelFree

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.

PriorityLayerContent
10Tool DefinitionsJSON schemas for all 32 tools + ReAct format instructions
9User InstructionsCustom system_prompt override (if configured)
8Platform Knowledge"You are the AI assistant embedded in Thumper-Run..." — app concepts, manifest schema
7Launcher KnowledgeTool-by-tool guidance (when launcher tools are available)
6Templatecode-helper or research-agent specialization
5Session Contextworking_directory, apps_directory, models_directory, platform
3External 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:

text
- 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:

FileLinesPurpose
orchestrator.rs~1,300Session lifecycle, message routing, tool execution coordination
executor.rs~1,300ReAct loop, step_with_retry, context management, output parsing
tool_dispatcher.rs~250HashMap registration, factory builder pattern
prompt_builder.rs~370Priority-based prompt assembly, template injection
config.rs~100Executor defaults: max_iterations=25, timeout=300s, context_size=4096
agent.rs (IPC)~77015 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)