[PR #13628] [MERGED] x: add experimental agent loop #24841

Closed
opened 2026-04-19 17:50:22 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ollama/ollama/pull/13628
Author: @ParthSareen
Created: 1/6/2026
Status: Merged
Merged: 1/6/2026
Merged by: @ParthSareen

Base: mainHead: agent-loop


📝 Commits (5)

  • dd74829 x: add experimental agent loop with tool approval
  • 35d10ba address comments
  • c3a534c fix windows/mac separation
  • cb72dbc use flag instead of goto
  • 301b854 update windows pathing

📊 Changes

12 files changed (+2482 additions, -23 deletions)

View changed files

📝 cmd/cmd.go (+10 -0)
📝 cmd/interactive.go (+1 -0)
📝 readline/readline.go (+8 -23)
x/agent/approval.go (+953 -0)
x/agent/approval_test.go (+379 -0)
x/agent/approval_unix.go (+27 -0)
x/agent/approval_windows.go (+15 -0)
x/cmd/run.go (+588 -0)
x/tools/bash.go (+114 -0)
x/tools/registry.go (+96 -0)
x/tools/registry_test.go (+143 -0)
x/tools/websearch.go (+148 -0)

📄 Description

Add --experimental flag to enable an agent loop that allows LLMs to use tools (bash, web_search) with interactive user approval.

Features:

  • Built-in tools: bash command execution, web search via Ollama API
  • Interactive approval UI with arrow key navigation
  • Auto-allowlist for safe commands (pwd, git status, npm run, etc.)
  • Denylist for dangerous patterns (rm -rf, sudo, credential access)
  • Prefix-based allowlist for approved directories (cat src/ approves cat src/*)
  • Warning box for commands targeting paths outside project directory

Architecture:

  • x/tools/: Tool registry, bash executor, web search client
  • x/agent/: Approval manager with TUI selector
  • x/cmd/: Agent loop orchestration

There's still work to be done to make the web search more seamless vs. having to have the env var - will pickup some of my previous auth + web search work


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ollama/ollama/pull/13628 **Author:** [@ParthSareen](https://github.com/ParthSareen) **Created:** 1/6/2026 **Status:** ✅ Merged **Merged:** 1/6/2026 **Merged by:** [@ParthSareen](https://github.com/ParthSareen) **Base:** `main` ← **Head:** `agent-loop` --- ### 📝 Commits (5) - [`dd74829`](https://github.com/ollama/ollama/commit/dd74829c277b28e164a33ea5045297240b485360) x: add experimental agent loop with tool approval - [`35d10ba`](https://github.com/ollama/ollama/commit/35d10ba88a36934c274590d7ae8b386dbab3dc29) address comments - [`c3a534c`](https://github.com/ollama/ollama/commit/c3a534c13c56181f68a748b1a71230c44da8dfbe) fix windows/mac separation - [`cb72dbc`](https://github.com/ollama/ollama/commit/cb72dbce9367cc1200945ff8deb3b9633f188bad) use flag instead of goto - [`301b854`](https://github.com/ollama/ollama/commit/301b8547da42d17255ed0257e96b57f00da6de05) update windows pathing ### 📊 Changes **12 files changed** (+2482 additions, -23 deletions) <details> <summary>View changed files</summary> 📝 `cmd/cmd.go` (+10 -0) 📝 `cmd/interactive.go` (+1 -0) 📝 `readline/readline.go` (+8 -23) ➕ `x/agent/approval.go` (+953 -0) ➕ `x/agent/approval_test.go` (+379 -0) ➕ `x/agent/approval_unix.go` (+27 -0) ➕ `x/agent/approval_windows.go` (+15 -0) ➕ `x/cmd/run.go` (+588 -0) ➕ `x/tools/bash.go` (+114 -0) ➕ `x/tools/registry.go` (+96 -0) ➕ `x/tools/registry_test.go` (+143 -0) ➕ `x/tools/websearch.go` (+148 -0) </details> ### 📄 Description Add `--experimental` flag to enable an agent loop that allows LLMs to use tools (bash, web_search) with interactive user approval. Features: - Built-in tools: bash command execution, web search via Ollama API - Interactive approval UI with arrow key navigation - Auto-allowlist for safe commands (pwd, git status, npm run, etc.) - Denylist for dangerous patterns (rm -rf, sudo, credential access) - Prefix-based allowlist for approved directories (cat src/ approves cat src/*) - Warning box for commands targeting paths outside project directory Architecture: - x/tools/: Tool registry, bash executor, web search client - x/agent/: Approval manager with TUI selector - x/cmd/: Agent loop orchestration There's still work to be done to make the web search more seamless vs. having to have the env var - will pickup some of my previous auth + web search work --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-04-19 17:50:22 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/ollama#24841