Add native Anthropic web_search tool to the agentic chat path
Neuron Soul CI / build (pull_request) Successful in 5m8s

When a chat request carries web_search=true, handle_chat_agentic now attaches Anthropic's
NATIVE server-side web_search tool (web_search_20250305) to the request. The native tool is
executed by Anthropic (not by the soul), so it returns real results with citations and needs
no local runtime — it sidesteps the soul's lack of executable tools entirely.

- new agentic_tools_with_web(web_search) helper (appends the native tool to the standard set)
- handle_chat_agentic reads json_get_bool(body,"web_search") and uses it

Pairs with neuron-ui: ChatRequest.web_search + the chat-input Web search toggle.
Note: built/verified by reviewer — no elc on the authoring machine.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Tim Lingo
2026-06-08 23:32:23 -05:00
parent cc07648ae1
commit c594cec8f7
+13 -1
View File
@@ -259,6 +259,17 @@ fn agentic_tools_literal() -> String {
"]"
}
// agentic_tools_with_web the standard tool set, plus Anthropic's NATIVE server-side
// web_search tool when web_search is requested. The native tool is executed by Anthropic
// (not by the soul), so it returns real results with citations and needs no local runtime
// it sidesteps the soul's lack of executable tools entirely.
fn agentic_tools_with_web(web_search: Bool) -> String {
let base: String = agentic_tools_literal()
if !web_search { return base }
let inner: String = str_slice(base, 1, str_len(base) - 1)
return "[" + inner + ",{\"type\":\"web_search_20250305\",\"name\":\"web_search\",\"max_uses\":5}]"
}
fn dispatch_tool(tool_name: String, tool_input: String) -> String {
if str_eq(tool_name, "read_file") {
let path: String = json_get(tool_input, "path")
@@ -303,7 +314,8 @@ fn handle_chat_agentic(body: String) -> String {
let system: String = identity + " You have access to tools: read files, write files, browse the web, search your memory, run commands. Use them when they add genuine value. Be direct.\n\n" + ctx
let api_key: String = agentic_api_key()
let tools_json: String = agentic_tools_literal()
let web_search: Bool = json_get_bool(body, "web_search")
let tools_json: String = agentic_tools_with_web(web_search)
let safe_msg: String = json_safe(message)
let safe_sys: String = json_safe(system)
let messages: String = "[{\"role\":\"user\",\"content\":\"" + safe_msg + "\"}]"