Repository navigation
feat: add optional you.com search integration - #1106
Merged
Merged
Conversation
Adds --websearch-provider (exa|youcom) to docker model run. Exa stays the default. youcom uses You.com's keyless MCP server; YDC_API_KEY switches to the keyed server. Also parses SSE responses event by event so a notification before the result doesn't break parsing. Signed-off-by: Brian Sparker <[email protected]>
2 of 4 tasks
Contributor
There was a problem hiding this comment.
Hey - I've found 5 issues
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="cmd/cli/tools/websearch.go" line_range="213" />
<code_context>
- dataLines = append(dataLines, strings.TrimPrefix(line, "data: "))
+ line = strings.TrimRight(line, "\r")
+ if strings.HasPrefix(line, "data:") {
+ payloads = append(payloads, strings.TrimSpace(strings.TrimPrefix(line, "data:")))
}
}
</code_context>
<issue_to_address>
**Split events fail to parse**
When an SSE event contains JSON across multiple `data:` fields, `parseMCPToolResponse` unmarshals each field separately instead of joining the fields for the event, so valid JSON-RPC payloads fail parsing and the search returns an error.
Join the event’s `data:` fields before unmarshaling the payload.
</issue_to_address>
### Comment 2
<location path="cmd/cli/tools/websearch.go" line_range="249" />
<code_context>
+ if parseErr != nil {
+ return "", fmt.Errorf("parsing response: %w", parseErr)
}
return "No search results found.", nil
}
</code_context>
<issue_to_address>
**Incomplete responses appear successful**
When the stream ends after notifications without a JSON-RPC result, `parseMCPToolResponse` skips messages without a result and returns “No search results found.”, so the model sees an incomplete response as a successful empty search.
Return an error when the stream ends without a JSON-RPC result.
Also at `cmd/cli/tools/websearch.go:250`.
</issue_to_address>
### Comment 3
<location path="cmd/cli/commands/run.go" line_range="39" />
<code_context>
+ if err != nil {
+ return nil, fmt.Errorf("could not get websearch-provider flag: %w", err)
+ }
+ if err := tools.ValidateWebSearchProvider(provider); err != nil {
+ return nil, err
+ }
</code_context>
<issue_to_address>
**Invalid provider triggers model download**
When `--websearch` is enabled, the provider is unknown, and the model is not already local, `getActiveTools` validates the provider only when chat starts, after `RunE` initializes the runner and inspects or pulls the model. With an invalid provider and a model not already local, the command downloads the model before rejecting the option.
Validate the provider in `PreRunE` when web search is enabled, before `RunE` can initialize the runner or pull a model.
</issue_to_address>
### Comment 4
<location path="cmd/cli/commands/run_test.go" line_range="195-196" />
<code_context>
+ if err != nil {
+ t.Fatalf("getActiveTools: %v", err)
+ }
+ if len(activeTools) != 1 || activeTools[0].Name() != "web_search" {
+ t.Fatalf("Expected one web_search tool, got %v", activeTools)
+ }
+
</code_context>
<issue_to_address>
**Wrong provider passes flag test**
When `getActiveTools` constructs a tool with the wrong provider while still returning one web-search tool, `TestRunCmdWebSearchProviderFlag` checks only the tool count and name at line 195, so it passes if `getActiveTools` ignores `youcom` and creates an Exa tool instead. `WebSearchTool.Name()` returns `web_search` for every provider, so the assertion does not verify the selected backend.
Assert that the returned `WebSearchTool` has `ProviderYouCom` when the flag is set to `youcom`.
</issue_to_address>
### Comment 5
<location path="cmd/cli/tools/websearch_test.go" line_range="120-121" />
<code_context>
+ if name, _ := toolCall(t, captured.body); name != "web_search_exa" {
+ t.Errorf("tool name = %q, want web_search_exa", name)
+ }
+ if got := captured.header.Get("User-Agent"); got == youcomUserAgent {
+ t.Error("Exa requests must not send the You.com User-Agent")
+ }
+ url, _, _, err := (&WebSearchTool{}).buildRequest("q")
</code_context>
<issue_to_address>
**Exa User-Agent regressions pass**
When exa requests start sending a custom User-Agent other than `youcomUserAgent`, `TestWebSearchExaDefault` only fails at line 120 when the header equals `youcomUserAgent`, so Exa can send any other unintended custom User-Agent and the test still passes.
Assert that Exa sends the expected unchanged User-Agent value.
</issue_to_address>…e provider early Signed-off-by: Brian Sparker <[email protected]>
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues are reported for the optional You.com web search integration.
No open issues 🎉
What changed in this PR
Adds You.com as an optional web search provider for docker model run, while keeping Exa as the default.
Changes:
- Adds
--websearch-providerwith You.com support for keyless access or authentication throughYDC_API_KEY. - Updates shared response parsing to handle separate SSE events and report tool and JSON-RPC errors.
- Adds provider and parser tests, goroutine leak detection, and CLI documentation.
| File | Description |
|---|---|
cmd/cli/tools/websearch.go |
Implements provider selection, You.com requests, and shared response parsing. |
cmd/cli/tools/websearch_test.go |
Tests provider requests, authentication, defaults, and response parsing. |
cmd/cli/tools/testmain_test.go |
Enables goroutine leak detection for tool tests. |
cmd/cli/docs/reference/model_run.md |
Documents provider selection and web search examples. |
cmd/cli/docs/reference/docker_model_run.yaml |
Updates generated CLI reference options and examples. |
cmd/cli/commands/run.go |
Registers and validates the provider flag and configures the search tool. |
cmd/cli/commands/run_test.go |
Tests flag defaults, tool selection, and provider validation. |
Review effort: Balanced
ericcurtin
approved these changes
Nov 13, 2026
ericcurtin
left a comment
Contributor
There was a problem hiding this comment.
LGTM. Follow-ups: dedupe the JSON-RPC request body in buildRequest, and warn when --websearch-provider is set without --websearch. Please open future PRs against https://github.com/llmmanorg/llmman instead, as model-runner is being deprecated in favour of it.
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.
I work at You.com. This adds You.com as a second keyless choice for
docker model run --websearch, next to Exa. Exa stays the default, so nothing changes unless you ask for it:docker model run --websearch --websearch-provider youcom ai/smollm2What changed
--websearch-providerflag ondocker model run(exadefault, oryoucom). An unknown value is an error.youcomcalls You.com's hosted MCP server with the same JSON-RPCtools/callshape the Exa path uses (you-search, 8 results). With no key it uses the free keyless endpoint,https://api.you.com/mcp?profile=free. IfYDC_API_KEYis set, it useshttps://api.you.com/mcpwith the key as a bearer token, for higher limits.User-Agent: youdotcom-integration/docker-model-runnerso we can see traffic from this integration. It's only set on You.com requests; Exa requests are unchanged.notifications/messageevent before the result, and joining alldata:lines into one JSON document failed on that. It also returns tool errors (isError) and JSON-RPC errors as errors instead of passing them to the model as results. The Exa path goes through the same parser and still works (checked live).cmd/cli/docs/referencewith the docs generator, plus a short example inmodel_run.md.Testing
cmd/cli/tools/websearch_test.go(new, withtestmain_test.gofor goleak): keyless vs keyed URL and headers, request body, User-Agent only on You.com, Exa default unchanged, SSE with a notification first,isError, JSON-RPC errors.TestRunCmdWebSearchProviderFlaginrun_test.go.golangci-lint run ./...(v2.15.0): 0 issues.go mod tidy: no diff.go test -race ./...: all packages pass.No new dependencies. If a second provider isn't something you want to maintain, say so and I'll close it without fuss.