Implement broker-side web search tools (Serper / Exa) for all providers #154
Labels
No labels
prio_critical
prio_low
type_bug
type_contact
type_issue
type_lead
type_question
type_story
type_task
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
lhumina_code/hero_aibroker#154
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
The broker supports many providers: OpenRouter, Kimi (direct), Groq, SambaNova, OpenAI, and Alibaba. Only OpenRouter has built-in server tools like
openrouter:web_searchandopenrouter:web_fetch. When a request routes to any direct provider, clients cannot use web search or fetch.Goal
Add broker-side tool execution so that web search and web fetch work uniformly with every configured chat provider.
Backend fallback order for tool execution:
Scope
hero_aibroker_server.web_searchweb_fetchProposed design
1. Configuration
Add new config keys / secrets:
HERO_AIBROKER_EXA_API_KEYSHERO_AIBROKER_SERPER_API_KEYSUpdate
crates/hero_aibroker_server/src/config/mod.rs.2. Tool definitions
Add
crates/hero_aibroker_server/src/tools/:ToolBackendenum:Exa,Serper,DirectFetchToolExecutortraitfunctiondefinition for upstream injection.3. Request lifecycle changes
In
crates/hero_aibroker_server/src/service/router.rs:tool_callingcapability and broker tools are enabled:__hero_web_search,__hero_web_fetch) torequest.tools.tool/functionresult message.4. Direct HTTP fetch fallback
If Exa and Serper are not configured:
web_fetch: fetch the URL directly via HTTP and return extracted text/Markdown.web_search: this may not be possible with direct HTTP fetch; consider returning an error or requiring at least one search backend.5. Observability
Non-goals
Acceptance criteria
web_fetchworks withkimi-latest,kimi-k2,groq,sambanova,openai, andopenrouter.web_searchworks with the same providers when Exa or Serper is configured.Implemented broker-side web search/fetch tools. Summary:
crates/hero_aibroker_server/src/tools/with:ToolRegistry,ToolExecutortrait,ToolErrorExaExecutor(__hero_web_search,__hero_web_fetch)SerperExecutor(__hero_web_search)DirectFetchExecutorusingreqwest+html_to_markdownservice/router.rs:__hero_web_search/__hero_web_fetchwhen a search backend is configuredexa_api_keys/serper_api_keystoConfig, loaded fromEXA_API_KEYS/SERPER_API_KEYSsecrets in hero_proccoreToolRegistryfrom live config, so keys can be added without restartmodelsconfig.ymlto keep onlykimi-latestandkimi-k2Verification:
cargo clippy -p hero_aibroker_server -- -D warnings— cleancargo test -p hero_aibroker_server— 115 passedWill open the PR and do live testing tomorrow.