Native Anthropic web_search — built-in (always-on, no toggle) #2

Merged
will.anderson merged 2 commits from feat/native-web-search into main 2026-06-10 22:37:51 +00:00
+12 -1
View File
@@ -259,6 +259,17 @@ fn agentic_tools_literal() -> String {
"]"
}
// agentic_tools_with_web the standard tool set, always plus Anthropic's NATIVE
// server-side web_search tool. Web search is BUILT IN: the model invokes it only when a
// query needs fresh info (max_uses caps it), so there is no user-facing toggle. 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() -> String {
let base: String = agentic_tools_literal()
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,7 @@ 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 tools_json: String = agentic_tools_with_web()
let safe_msg: String = json_safe(message)
let safe_sys: String = json_safe(system)
let messages: String = "[{\"role\":\"user\",\"content\":\"" + safe_msg + "\"}]"