Skip to content

feat(tools): web_search method, auth headers and field mapping - #451

Merged
ajianaz merged 1 commit into
developfrom
feat/web-search-backend-config
Oct 27, 2026
Merged

ajianaz merged 1 commit into
developfrom
feat/web-search-backend-config

Conversation

@ajianaz

@ajianaz ajianaz commented Oct 27, 2026

Copy link
Copy Markdown
Contributor

What

web_search can talk to backends beyond the fleet contract: TOLE_WEB_SEARCH_METHOD, TOLE_WEB_SEARCH_HEADERS and TOLE_WEB_SEARCH_FIELDS.

Closes #436.

Why

nginjen (the fleet's own search backend) answers only POST /search with {"query","limit"}, needs Authorization: Bearer <key>, and returns description instead of snippet; it could not be plugged in without a shim.

Changes

  • tole-core/src/web.rs:
    • SearchMethod (GET ?q= default; POST with JSON {"query", "limit": 8}, the nginjen request shape).
    • TOLE_WEB_SEARCH_HEADERS: Name=Value pairs separated by commas; ${VAR} expanded from the environment (unset/blank is an error naming the variable); names must be RFC 9110 tokens; Host, Content-Length, Transfer-Encoding, Connection, Content-Type refused; CR/LF/NUL in a value refused; no error or description ever contains a value. Headers go only to the backend (the search agent follows no redirects).
    • TOLE_WEB_SEARCH_FIELDS: wire=backend for results, title, url, snippet; unknown wire fields are errors. The default contract is unchanged.
    • API: WebSearchTool::from_env() returns Result<Option<Self>, String>; new WebSearchTool::new(url) and from_lookup(env).
  • tole-cli/src/tool_roster.rs: a malformed search config fails startup instead of silently dropping the tool.
  • Docs: README tool table, CHANGELOG (incl. the API change), docs/epics.md, docs/threat-model.md (credential scope).

Testing

  • Unit: absent/blank backend, default contract, header parsing and ${VAR} expansion, every rejection path asserts the secret is not echoed (incl. a line break smuggled through a variable), method and field parsing.
  • Mock round trip (nginjen shape): POST body {"query","limit"}, Authorization: Bearer received, description mapped to snippet, results=items.
  • E2E (real binary): an unset ${VAR} and a reserved header fail tole run naming the variable/header, never the value.
  • cargo fmt, clippy (workspace all-targets, bare, shell-tools, mcp, tole-core bare), cargo test --workspace: green. Cora agent review (prepare + finalize): 0 findings, should_block: false.

TOLE_WEB_SEARCH_METHOD (GET default, POST with {"query","limit"}),
TOLE_WEB_SEARCH_HEADERS (Name=Value pairs, ${VAR} expanded from the
environment, sent only to the backend; transport headers and line
breaks refused; errors never echo a value) and TOLE_WEB_SEARCH_FIELDS
(wire=backend, e.g. snippet=description,results=items) let backends
such as nginjen plug in without an adapter. A malformed value fails
startup. WebSearchTool::from_env now returns Result<Option<Self>, String>.
@ajianaz ajianaz added this to the 0.10.0 milestone Oct 27, 2026
@github-actions

Copy link
Copy Markdown

🔍 Cora AI Code Review

⚠️ Review could not complete. LLM API error after retries: LLM API returned status 400: {"error":{"code":"invalid_request_error","message":"temperature is deprecated for this model.","type":"invalid_request_error","param":null}}


Review powered by cora-code · BYOK · MIT

@ajianaz

ajianaz commented Oct 27, 2026

Copy link
Copy Markdown
Contributor Author

Merged on the Cora agent-as-reviewer verdict (cora.review_prepare + cora.review_finalize: 0 findings, should_block: false) as an owner-approved substitute: the Cora LLM review cannot complete while codecoradev/cora-code#701 (temperature rejected by the model) is open.

@ajianaz
ajianaz merged commit c03f245 into develop Oct 27, 2026
17 checks passed
@ajianaz
ajianaz deleted the feat/web-search-backend-config branch October 27, 2026 09:34
@ajianaz ajianaz modified the milestones: 0.10.0, 0.9.0 Oct 28, 2026
@ajianaz ajianaz mentioned this pull request Oct 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(tools): TOLE_WEB_SEARCH_URL — auth headers + response field mapping

1 participant