test: cover the Ollama web tools, mark trimmed snippets, new icon #2

Merged
adrianbonpin merged 1 commits from feat/web-tools-coverage into prod 2026-10-03 20:36:38 +00:00
Owner

Context

Both Ollama web tools, web_search and web_fetch, were already implemented and wired in the initial PR — they are registered in TOOL_DEFINITIONS, routed in executeTool, filtered by the webEnabled preference, and hitting POST /api/web_search and POST /api/web_fetch.

What was actually missing was coverage. agent.test.ts exercised the loop end to end but only ever with get_datetime, so neither web tool had a single direct test.

Changes

  • src/__tests__/tools.test.ts (new) pins the contract for both tools:
    • web_search — endpoint, bearer token, request body, max_results clamped into 1..10, empty result sets, result rendering
    • web_fetch — endpoint, request body, page content, title fallback, truncation
    • failure paths for both, including a rejected API key
    • the webEnabled filter: local tools survive, web tools are removed
  • src/lib/tools.ts — a trimmed search snippet is now marked [truncated] instead of silently dropping the tail, matching what web_fetch already did. Silent caps read as complete output when they are not.
  • assets/extension-icon.png — white tile, black bubble, three dots punched out.

Verification

  • tsc --noEmit clean, eslint . clean, vici build succeeds
  • 96 tests passing across 8 files (was 77 across 7)
  • Endpoint paths checked against the live Ollama API:
Route Unauthenticated response Meaning
POST /api/chat 401 route exists, key required
POST /api/web_search 401 route exists, key required
POST /api/web_fetch 401 route exists, key required
POST /api/tags 405 route exists, GET only

Not verified

No authenticated call was made — there is no OLLAMA_API_KEY in the environment. The request and response shapes follow Ollama's documentation and are covered against mocks, but they have not been exercised against a real key.

## Context Both Ollama web tools, `web_search` and `web_fetch`, were already implemented and wired in the initial PR — they are registered in `TOOL_DEFINITIONS`, routed in `executeTool`, filtered by the `webEnabled` preference, and hitting `POST /api/web_search` and `POST /api/web_fetch`. What was actually missing was **coverage**. `agent.test.ts` exercised the loop end to end but only ever with `get_datetime`, so neither web tool had a single direct test. ## Changes - **`src/__tests__/tools.test.ts`** (new) pins the contract for both tools: - `web_search` — endpoint, bearer token, request body, `max_results` clamped into 1..10, empty result sets, result rendering - `web_fetch` — endpoint, request body, page content, title fallback, truncation - failure paths for both, including a rejected API key - the `webEnabled` filter: local tools survive, web tools are removed - **`src/lib/tools.ts`** — a trimmed search snippet is now marked `[truncated]` instead of silently dropping the tail, matching what `web_fetch` already did. Silent caps read as complete output when they are not. - **`assets/extension-icon.png`** — white tile, black bubble, three dots punched out. ## Verification - `tsc --noEmit` clean, `eslint .` clean, `vici build` succeeds - **96 tests passing** across 8 files (was 77 across 7) - Endpoint paths checked against the live Ollama API: | Route | Unauthenticated response | Meaning | | --- | --- | --- | | `POST /api/chat` | 401 | route exists, key required | | `POST /api/web_search` | 401 | route exists, key required | | `POST /api/web_fetch` | 401 | route exists, key required | | `POST /api/tags` | 405 | route exists, GET only | ## Not verified No authenticated call was made — there is no `OLLAMA_API_KEY` in the environment. The request and response shapes follow Ollama's documentation and are covered against mocks, but they have not been exercised against a real key.
adrianbonpin added 1 commit 2026-10-03 20:36:35 +00:00
Both web tools were already implemented and wired, but the suite only
exercised get_datetime, so neither had any direct coverage. Adds
tools.test.ts pinning the contract for both:

- web_search: request shape (endpoint, bearer token, body), max_results
  clamped into 1..10, empty result sets, and how results render
- web_fetch: request shape, page content, title fallback, truncation
- failure paths for both, including a rejected API key
- the webEnabled filter, so the local tools survive and the web tools go

Also marks a trimmed search snippet with "[truncated]" rather than
silently dropping the tail, which is what web_fetch already did.

Also replaces the extension icon with a white tile and a black bubble.

Endpoint paths were checked against the live Ollama API: /api/chat,
/api/web_search and /api/web_fetch all return 401 unauthenticated (so
the route exists and demands a key), and /api/tags returns 405 to a
POST, which also confirms the path. No authenticated call was made.

Test count: 77 -> 96.
adrianbonpin merged commit 7afafdaf32 into prod 2026-10-03 20:36:38 +00:00
Sign in to join this conversation.
No Reviewers
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: adrianbonpin/lam-agent-vicinae#2