Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.
TypeScript agentaiai-agentsall-in-onecrmcrm-systememaillinearmcpmessagingnotesnotionofficerustslackslack-alternativestartupstartup-toolstypescriptworkspace
web_search
What it is
Part of AI tools: web search and page fetch for every agent and the SDK. One
SearchProvider port with a Tavily adapter backs the WebSearch/WebFetch
agent tools (any model, any host) and cognition's POST /web/search and
POST /web/fetch, which macro.web.search()/macro.web.fetch() call.
Start here
src/domain/service.rs:WebSearchService— validation, AI admission (AiFeature::WebSearch), the provider call, and metering the vendor's credits to the user (UsageAmount::ProviderCredits, pricing idtavily).src/domain/models.rs: the request/response DTOs, shared by the HTTP routes and the tools (their schemars titles are the tool names).src/outbound/tavily.rs: typed reqwest client for/searchand/extract.src/inbound/axum_router.rs: routes,ActingUserauth, per-user hourly limit.src/inbound/toolset.rs: the agent tools;ai_toolsbuilds their context.
Scope
- Owns: web search/fetch request policy, the vendor adapter, routes and tools.
- Not here: pricing rows and quota counting →
crates/ai_usage,crates/ai_billing.
Recipes
- Swap or add a vendor: implement
SearchProviderinsrc/outbound/<vendor>.rs→ seed itsai_pricingrow (a migration) → construct it inai_tools::build_web_search_provider_from_env.
Checks
cargo test -p web_search --features axum(no network: Tavily is mocked with the fixtures insrc/outbound/tavily/fixtures/).
Gotchas
TAVILY_API_KEYis optional at startup so a missing secret cannot stop a host; every call then fails withweb_search_not_configured. Never log it.- Only the HTTP routes are rate limited; tool calls are bounded by agent turns.
- Usage is recorded only when Tavily reports
usage.credits; the service warns otherwise. - Code mode hides the tools (
agent_code_mode::domain::covered_by_code_sdk); agents there use the SDK.
Related
- Rules:
.agents/rules/rust/architecture.md