Implementation:1ay1 Agentty Web Search Policy Config
| Knowledge Sources | |
|---|---|
| Domains | Configuration, Web_Search |
| Last Updated | 2026-10-28 12:00 GMT |
Overview
Pure domain config type for the user's web search tool policy, controlling result counts, exclusions, service ordering, and per-service dials.
Description
The agentty::web_search_cfg module is the user's policy for the `web_search` tool. web_search is implemented in mcp-cpp; agentty owns the CHOICES and hands them over at three seams: advertisement, dispatch (rewriting the call's args), and the plan.
The mode is Auto (model decides count), On (user's counts apply), or Off (no web search). Exclusions are applied by rewriting the request (appending `-site:` tokens), not filtering results — so the engine never returns a blocked domain and fills the freed slots with other results. Per-service dials (freshness, region, etc.) are keyed `"<service>.<dial>"` and only non-default values are stored.
Pure: no IO, no globals. Constants define the bounds that both the settings registry rows and the dispatch seam clamp to, pinned together by compile-time proofs. API keys are NOT part of this type — they live in the keystore/sealed file.
Usage
Import this when you need to: access web search policy in the domain layer, rewrite a search request's args at dispatch, or define web search settings bounds.
Code Reference
Source Location
- Repository: 1ay1_Agentty
- File: include/agentty/domain/web_search_config.hpp
- Lines: 1-176
Signature
namespace agentty::web_search_cfg {
inline constexpr int kCountMin = 1, kCountMax = 20, kCountDefault = 10;
inline constexpr int kMaxCountMin = 1, kMaxCountMax = 50, kMaxCountDefault = 20;
enum class Mode : std::uint8_t { Auto, On, Off };
struct Config {
std::string mode_text = "auto";
int count = kCountDefault;
int max_count = kMaxCountDefault;
std::string exclude_sites;
std::string primary = "brave-free";
std::string secondary = "ddg-free";
std::string fallback = "tavily-free";
std::string language = "auto";
std::map<std::string, std::string> dials;
bool operator==(const Config&) const = default;
};
[[nodiscard]] Mode mode(const Config& c);
[[nodiscard]] std::vector<std::string> exclude_list(std::string_view text);
[[nodiscard]] int effective_count(const Config& c, const nlohmann::json& args);
[[nodiscard]] std::string apply_exclusions(std::string query, const std::vector<std::string>& sites);
[[nodiscard]] nlohmann::json rewrite_args(const Config& c, nlohmann::json args);
}
Import
#include "agentty/domain/web_search_config.hpp"
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| Config | struct | Yes | Web search policy (mode, counts, exclusions, services) |
| args | nlohmann::json | Yes (rewrite) | The model's search request args |
Outputs
| Name | Type | Description |
|---|---|---|
| rewrite_args() | nlohmann::json | Rewritten request with count clamped + exclusions appended |
| exclude_list() | std::vector<string> | Parsed, normalized exclusion domains |
| effective_count() | int | Model's count or default, clamped to [1, max_count] |
Usage Examples
Rewrite a Search Request at Dispatch
#include "agentty/domain/web_search_config.hpp"
auto& cfg = settings.web_search;
nlohmann::json args = model_call_args;
auto rewritten = agentty::web_search_cfg::rewrite_args(cfg, std::move(args));
// In On: count resolved and clamped. In Auto: count passes through.
// Both: exclusions appended as -site: tokens.
Parse Exclusions
auto sites = agentty::web_search_cfg::exclude_list("pinterest.com, w3schools.com");
// → {"pinterest.com", "w3schools.com"} — lowercased, deduped, validated