Skip to content

feat: add optional you.com search integration - #1106

Merged
ericcurtin merged 2 commits into
docker:mainfrom
brainsparker:feat/youcom-search
Nov 13, 2026
Merged

ericcurtin merged 2 commits into
docker:mainfrom
brainsparker:feat/youcom-search

Conversation

@brainsparker

Copy link
Copy Markdown
Contributor

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/smollm2

What changed

  • New --websearch-provider flag on docker model run (exa default, or youcom). An unknown value is an error.
  • youcom calls You.com's hosted MCP server with the same JSON-RPC tools/call shape the Exa path uses (you-search, 8 results). With no key it uses the free keyless endpoint, https://api.you.com/mcp?profile=free. If YDC_API_KEY is set, it uses https://api.you.com/mcp with the key as a bearer token, for higher limits.
  • You.com requests send User-Agent: youdotcom-integration/docker-model-runner so we can see traffic from this integration. It's only set on You.com requests; Exa requests are unchanged.
  • The response parser now reads SSE event by event and uses the one carrying the JSON-RPC result. You.com sends a notifications/message event before the result, and joining all data: 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).
  • Regenerated cmd/cli/docs/reference with the docs generator, plus a short example in model_run.md.

Testing

  • cmd/cli/tools/websearch_test.go (new, with testmain_test.go for 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.
  • TestRunCmdWebSearchProviderFlag in run_test.go.
  • golangci-lint run ./... (v2.15.0): 0 issues. go mod tidy: no diff. go test -race ./...: all packages pass.
  • Live: keyless You.com returned 8 results for "docker model runner websearch", and Exa still returned results through the new parser.

No new dependencies. If a second provider isn't something you want to maintain, say so and I'll close it without fuss.

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]>

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨

Comment thread cmd/cli/tools/websearch.go Resolved
Comment thread cmd/cli/tools/websearch.go Resolved
Comment thread cmd/cli/commands/run.go Resolved
Comment thread cmd/cli/commands/run_test.go Resolved
Comment thread cmd/cli/tools/websearch_test.go Resolved

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 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-provider with You.com support for keyless access or authentication through YDC_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 ericcurtin left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@ericcurtin
ericcurtin merged commit f8f0ee4 into docker:main Nov 13, 2026
11 checks passed
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.

3 participants