Repository navigation
feat(web): nginjen backend for web_search and web_fetch, and doctor web lines (#625 part 2) - #674
Merged
Merged
Conversation
🔍 Cora AI Code Review✅ No issues found. Code looks good! Review powered by cora-code · BYOK · MIT |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Part 2 of #625. With
NGINJEN_BASE_URLandNGINJEN_API_KEYboth set,web_searchandweb_fetchuse a full nginjen service:POST /searchandPOST /scrapewith a bearer key. Results the backend produced through its Jina Reader fallback are discarded.tole doctornow names the lane each web tool uses. This closes #625's scope together with parts 1a (#671) and 1b (#672).Depends on: #671 and #672, both merged. Based on
develop, with the latestdevelopmerged in.Why
#625's decision 2: two variables switch both tools to the full nginjen backend, the generic
TOLE_WEB_*settings keep working, and otherwise the built-in tools apply. Your ruling on Jina: never ask for it, and discard any result markedengine_used: "jina"with a note.Changes
tole_core::web:nginjen_backend(env):(base, key)only when both variables are non-blank. A base URL that is not http(s) is an error naming the variable, never the key.WebSearchTool::nginjen(base, key): the existing default contract (POST{query, limit}, answeringresultswith title, url and snippet) at{base}/searchwithAuthorization: Bearer <key>. The query is redacted as before, and no redirect is followed.NginjenFetchTool:{url, format}to{base}/scrapewith the bearer key. The formats aremarkdown(default),compact,text(sent ascontent),html(sent asrawHtml) andlinks;engine_used: "jina"with an error saying why;tole_cli::tool_roster:WebLane/web_lanes(env): one place picks each tool's lane. The order is aTOLE_WEB_*backend, then nginjen, then the built-in tools; withoutweb-builtin, the direct fetcher and no search.buildregisters from it.web_doctor_lines(env):web_search: …andweb_fetch: …(built-in, nginjen backend, generic backend, direct text fetch, or off). Names only, never a URL or the key.tole doctorprints those two lines.Dependencies: none added; tole-cli and tole-core crate counts are unchanged from #672.
Memory: none resident; one HTTP agent per call.
Testing
TDD:
crates/tole-core/tests/web_nginjen.rs(6 tests) went red against stubs (6 of 6 failed), then green.Those 6 tests run against a local stand-in for the backend on 127.0.0.1, with no DNS or external network. They cover:
{url, format}, with the format mapping;crates/tole-cli/tests/web_lanes.rs(3 tests) covers:web-builtin;tool_roster::buildwith the nginjen variables registering the nginjenweb_fetchand aweb_search, with no key in any spec.These were written after the code; the mutation breaks below show they pin it.
Gates on this head:
cargo fmt --allcargo clippy --workspace --all-targets --all-features -- -D warningscargo test --workspacecargo test -p tole-core --no-default-featuresweb-builtin)cargo test -p tole-cli --no-default-features --test web_lanesIn the workspace run,
tui_e2e::tui_streams_approves_cancels_and_leaves_an_ordinary_sessiontimed out once. It is the known flake, unrelated to this change, and passed 15 of 15 when re-run alone.cora review --no-llm --base origin/develop: no issues.Mutation breaks, each restored afterwards; the tests caught all 12:
textformat not mapped;