Skip to content

feat: claude search#393

Open
joseph-mpo-yeti wants to merge 38 commits intoTHU-MAIC:mainfrom
joseph-mpo-yeti:feat/claude-search
Open

feat: claude search#393
joseph-mpo-yeti wants to merge 38 commits intoTHU-MAIC:mainfrom
joseph-mpo-yeti:feat/claude-search

Conversation

@joseph-mpo-yeti
Copy link
Copy Markdown

@joseph-mpo-yeti joseph-mpo-yeti commented Apr 10, 2026

Summary

Adds a new Claude-based web search provider (via Anthropic Messages + web_search_* tools) and upgrades the app to support multiple web search providers end-to-end (store, UI, API, and server generation), including SSRF protections for page/content fetching.

Related Issues

Closes #392

Changes

  • Introduces searchWithClaude (including page-content enrichment + SSRF guard) and adds Claude/Tavily to WEB_SEARCH_PROVIDERS.
  • Refactors web search settings/state to support provider selection, enable/disable toggle, Claude model/tool configuration, and server/env API key resolution.
  • Updates the web-search API + generation flows (toolbar, preview, classroom generation) to pass provider + providerConfig; adds tests and icons.

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update
  • Refactoring (no functional changes)
  • CI/CD or build changes

Verification

Steps to reproduce / test

  1. pnpm build
  2. pnpm start

Evidence

  • CI passes (pnpm check && pnpm lint && npx tsc --noEmit)
  • Manually tested locally
  • Screenshots / recordings attached (if UI changes)

Before

before-tavily-settings before-web-search

After

after-tavily-settings after-claude-settings after-web-search-tavily after-web-search-claude

Checklist

  • My code follows the project's coding style
  • I have performed a self-review of my code
  • I have added/updated documentation as needed
  • My changes do not introduce new warnings

joseph-mpo-yeti and others added 16 commits April 9, 2026 16:07
Agent-Logs-Url: https://github.com/joseph-mpo-yeti/OpenMAIC/sessions/099e53fb-e1db-49f4-af7f-4f17cb3d364a

Co-authored-by: joseph-mpo-yeti <55380155+joseph-mpo-yeti@users.noreply.github.com>
Agent-Logs-Url: https://github.com/joseph-mpo-yeti/OpenMAIC/sessions/09469d80-8e91-449b-8bc2-9c11f83555df

Co-authored-by: joseph-mpo-yeti <55380155+joseph-mpo-yeti@users.noreply.github.com>
Agent-Logs-Url: https://github.com/joseph-mpo-yeti/OpenMAIC/sessions/0aa49d19-df5b-4a08-a7e1-2295ae9cfc38

Co-authored-by: joseph-mpo-yeti <55380155+joseph-mpo-yeti@users.noreply.github.com>
Copilot AI review requested due to automatic review settings April 10, 2026 03:44
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a Claude (Anthropic Messages + web_search tool) web-search provider and refactors the app’s web search feature to support multiple providers across settings storage, UI selection, and server/API generation flows (with SSRF protections for URL fetching).

Changes:

  • Introduces searchWithClaude (including page-content enrichment + SSRF guard) and registers Claude/Tavily as web search providers.
  • Refactors web search settings/state/UI to support provider selection, enable/disable toggle, Claude model/tool configuration, and server/env API-key resolution.
  • Updates API + classroom generation + preview/toolbar flows to pass providerId and providerConfig, with added tests and provider icons.

Reviewed changes

Copilot reviewed 24 out of 25 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
tests/web-search/claude.test.ts Adds unit coverage for Claude search behavior (tools defaults, page enrichment, SSRF blocks, errors).
tests/store/settings-web-search.test.ts Tests web-search store defaults/rehydration and Claude tools persistence.
tests/server/provider-config.test.ts Extends provider-config tests for provider-specific web search API key resolution (Tavily + Claude).
public/logos/tavily.svg Adds Tavily logo asset for provider UI.
lib/web-search/types.ts Extends web-search provider typing (adds claude, model metadata).
lib/web-search/tavily.ts Refactors Tavily search to accept configurable baseUrl.
lib/web-search/constants.ts Registers Tavily/Claude providers, icons, and Claude model list.
lib/web-search/claude.ts Implements Claude web-search provider (Messages API + SSRF-guarded page fetching).
lib/types/web-search.ts Makes WebSearchSource.score optional to support providers without scoring.
lib/store/settings.ts Adds multi-provider web search settings (enabled toggle, provider selection, model/tools/models config, rehydrate helpers).
lib/server/provider-config.ts Adds web-search provider/env mapping and provider-aware API key resolution.
lib/server/classroom-generation.ts Wires provider selection/config into classroom generation web-search step (with SSRF baseUrl validation).
lib/server/api-response.ts Adds MISSING_PROVIDER error code for API responses.
lib/i18n/locales/en-US.json Updates web-search strings and adds new Claude/model/tool configuration labels.
lib/i18n/locales/ja-JP.json Same as above for Japanese locale.
lib/i18n/locales/ru-RU.json Same as above for Russian locale.
lib/i18n/locales/zh-CN.json Same as above for Simplified Chinese locale.
components/settings/web-search-settings.tsx Expands settings UI for per-provider keys/baseUrl plus Claude tools/models management and connection testing.
components/settings/web-search-model-dialog.tsx Adds dialog to create/edit/test Claude models.
components/settings/tool-edit-dialog.tsx Adds dialog to create/edit Claude tool definitions.
components/settings/index.tsx Updates settings dialog state/selection to support nullable web search provider selection.
components/generation/generation-toolbar.tsx Adds web-search toggle + provider/model selection popover (multi-provider aware).
app/page.tsx Migrates old localStorage web-search toggle into Zustand store and routes toolbar toggle through store.
app/generation-preview/page.tsx Sends providerId + providerConfig when calling /api/web-search.
app/api/web-search/route.ts Updates web-search API to require providerId, validate baseUrl via SSRF guard, and route to Tavily/Claude.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread components/settings/web-search-settings.tsx Outdated
Comment thread components/settings/web-search-model-dialog.tsx Outdated
Comment thread components/settings/web-search-settings.tsx Outdated
Comment thread components/settings/web-search-settings.tsx
Copy link
Copy Markdown
Contributor

@wyuc wyuc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rebase onto current main to resolve conflicts.

Two things to fix:

  1. handleSaveModel doesn't check for duplicate model IDs. Add a uniqueness check before saving to avoid React key collisions.

  2. i18n: ar-SA.json was just merged and several new keys were added recently (#418, #430, #435). Make sure all 4 locale files have the new web search keys after rebasing.

@wyuc
Copy link
Copy Markdown
Contributor

wyuc commented Apr 16, 2026

Bug: searchWithClaude manually constructs the API URL (${baseUrl}/v1/messages) via proxyFetch, but test connection goes through the Anthropic SDK. These two paths handle base URLs differently, so test connection can pass while actual search 404s (e.g. when the base URL ends with /v1).

Fix: use the Anthropic SDK (messages.create) for the search call too, same as test connection. This aligns URL handling and avoids the manual endpoint construction entirely.

@wyuc
Copy link
Copy Markdown
Contributor

wyuc commented Apr 16, 2026

The web_search tool needs allowed_callers: ["direct"] in the tool definition. Without it, models like Haiku that don't support programmatic tool calling will 400. Since the search call is always user-initiated (not model-to-model), "direct" is the correct caller type here.

@joseph-mpo-yeti joseph-mpo-yeti requested a review from wyuc April 18, 2026 12:23
joseph-mpo-yeti and others added 8 commits April 19, 2026 16:18
Keep webSearch in Zustand store (feat/claude-search approach) and
interactiveMode in local form state with localStorage persistence (from main).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
… instead of adding Anthropic SDK as a direct dependency
Cast mock.calls through unknown to avoid tuple-index type errors on
Vitest mock objects whose parameter types are inferred as empty tuples.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: Adding Claude for Web Search

4 participants