[PR #13635] [MERGED] x: agent loop ux improvements #45553

Closed
opened 2026-04-25 01:14:15 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

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

Base: mainHead: parth/agent-loop-improvements


📝 Commits (10+)

  • 3aaa8d5 readline: add Ctrl+O support for expanding tool output
  • 064c6a9 x/tools: add environment variables to disable tools
  • aed714a x/tools: use Ollama key signing for web search authentication
  • aa9a147 x/agent: improve approval UX with hierarchical matching and signin prompt
  • 85e48af x/cmd: add tool output toggle and interactive signin flow
  • 9383082 x: add tests for tool disabling, auth error, and helper functions
  • 0b48508 x/agent: fix hierarchical prefix matching for Windows paths
  • 59928c5 x/cmd: add context-aware tool output truncation for LLM
  • c8b599b x/agent: fix path traversal vulnerability in hierarchical prefix matching
  • 8470c25 x/cmd: handle 401 from Chat API with sign-in prompt

📊 Changes

12 files changed (+921 additions, -46 deletions)

View changed files

📝 cmd/cmd.go (+4 -2)
📝 readline/errors.go (+3 -0)
📝 readline/readline.go (+3 -0)
📝 readline/types.go (+1 -0)
📝 x/agent/approval.go (+169 -16)
📝 x/agent/approval_test.go (+162 -0)
📝 x/cmd/run.go (+245 -18)
x/cmd/run_test.go (+180 -0)
📝 x/tools/registry.go (+10 -2)
📝 x/tools/registry_test.go (+51 -0)
📝 x/tools/websearch.go (+35 -8)
x/tools/websearch_test.go (+58 -0)

📄 Description

Web Search Authentication

  • Replaced OLLAMA_API_KEY env var with native Ollama key signing (~/.ollama/id_ed25519)
  • Added interactive sign-in flow when web search gets 401: prompts user, shows URL, polls until auth completes
  • Shows "Uses internet via ollama.com" notice in approval popup

Tool Output UX

  • Ctrl+O toggle: Expand/collapse tool output inline (instead of separate bordered view)
  • Tool output truncated to 300 chars with hint to press Ctrl+O
  • Local model output capped to prevent context overflow

Tool Configuration

  • OLLAMA_AGENT_DISABLE_WEBSEARCH=1 - disable web search tool
  • OLLAMA_AGENT_DISABLE_BASH=1 - disable bash tool
  • Grey "Tools available: ..." banner at startup

Approval System

  • Hierarchical prefix matching: approving cat tools/file.go also allows cat tools/subdir/file.go
  • Cross-platform path normalization (Windows backslash support)
  • Added PromptYesNo for interactive yes/no prompts

Context Managment

  • Cap tool outputs to 4k for local models, 10k for cloud. This is a bit lossy right now, will update to have local vs. cloud detection

Tests

  • Registry env var disabling
  • Web search auth error handling
  • Helper functions (isLocalModel, isLocalServer, truncateToolOutputForLocalModel)
  • Cross-platform hierarchical prefix matching

🔄 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/13635 **Author:** [@ParthSareen](https://github.com/ParthSareen) **Created:** 1/6/2026 **Status:** ✅ Merged **Merged:** 1/7/2026 **Merged by:** [@ParthSareen](https://github.com/ParthSareen) **Base:** `main` ← **Head:** `parth/agent-loop-improvements` --- ### 📝 Commits (10+) - [`3aaa8d5`](https://github.com/ollama/ollama/commit/3aaa8d556499e56b54cdbfdad1bbdc0b1c665117) readline: add Ctrl+O support for expanding tool output - [`064c6a9`](https://github.com/ollama/ollama/commit/064c6a984ef3077e4d429064c9cde025d942d518) x/tools: add environment variables to disable tools - [`aed714a`](https://github.com/ollama/ollama/commit/aed714a6768ccb4f3c8d1c7f0d0f594f4f08fd0c) x/tools: use Ollama key signing for web search authentication - [`aa9a147`](https://github.com/ollama/ollama/commit/aa9a1477b3cb0e4d8f85cf707bbb9a4b2439a2b2) x/agent: improve approval UX with hierarchical matching and signin prompt - [`85e48af`](https://github.com/ollama/ollama/commit/85e48af46a792d4013e35ca63eb9dfc9321b3f86) x/cmd: add tool output toggle and interactive signin flow - [`9383082`](https://github.com/ollama/ollama/commit/93830820701ddb41b3fbbe4cf1ccf72b0b00ee99) x: add tests for tool disabling, auth error, and helper functions - [`0b48508`](https://github.com/ollama/ollama/commit/0b4850812fe7207c6f99322069c8d75102356d3a) x/agent: fix hierarchical prefix matching for Windows paths - [`59928c5`](https://github.com/ollama/ollama/commit/59928c536b0a4af6f5a5f2a0089a7204aaef0ad3) x/cmd: add context-aware tool output truncation for LLM - [`c8b599b`](https://github.com/ollama/ollama/commit/c8b599bd442926f5f07f6f407ab09188cddc8f73) x/agent: fix path traversal vulnerability in hierarchical prefix matching - [`8470c25`](https://github.com/ollama/ollama/commit/8470c25fa96062b4fe76dfcb3ae82517eb3f42c9) x/cmd: handle 401 from Chat API with sign-in prompt ### 📊 Changes **12 files changed** (+921 additions, -46 deletions) <details> <summary>View changed files</summary> 📝 `cmd/cmd.go` (+4 -2) 📝 `readline/errors.go` (+3 -0) 📝 `readline/readline.go` (+3 -0) 📝 `readline/types.go` (+1 -0) 📝 `x/agent/approval.go` (+169 -16) 📝 `x/agent/approval_test.go` (+162 -0) 📝 `x/cmd/run.go` (+245 -18) ➕ `x/cmd/run_test.go` (+180 -0) 📝 `x/tools/registry.go` (+10 -2) 📝 `x/tools/registry_test.go` (+51 -0) 📝 `x/tools/websearch.go` (+35 -8) ➕ `x/tools/websearch_test.go` (+58 -0) </details> ### 📄 Description ## Web Search Authentication - Replaced OLLAMA_API_KEY env var with native Ollama key signing (~/.ollama/id_ed25519) - Added interactive sign-in flow when web search gets 401: prompts user, shows URL, polls until auth completes - Shows "Uses internet via ollama.com" notice in approval popup ## Tool Output UX - Ctrl+O toggle: Expand/collapse tool output inline (instead of separate bordered view) - Tool output truncated to 300 chars with hint to press Ctrl+O - Local model output capped to prevent context overflow ## Tool Configuration - OLLAMA_AGENT_DISABLE_WEBSEARCH=1 - disable web search tool - OLLAMA_AGENT_DISABLE_BASH=1 - disable bash tool - Grey "Tools available: ..." banner at startup ## Approval System - Hierarchical prefix matching: approving cat tools/file.go also allows cat tools/subdir/file.go - Cross-platform path normalization (Windows backslash support) - Added PromptYesNo for interactive yes/no prompts ## Context Managment - Cap tool outputs to 4k for local models, 10k for cloud. This is a bit lossy right now, will update to have local vs. cloud detection ## Tests - Registry env var disabling - Web search auth error handling - Helper functions (isLocalModel, isLocalServer, truncateToolOutputForLocalModel) - Cross-platform hierarchical prefix matching --- <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-25 01:14:15 -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#45553