Skip to content

Linger is An Open-Source Personal Agent That Runs Fully on Your PC. We aim to break Big Tech’s grip on AI by bringing powerful local AI to everyday computers through efficient model–harness co-design, so everyone can run their own.

feat(computer): steer web search by the model's link

LeoXing2013234029b6
diff --git a/apps/computer/local-daemon/README.md b/apps/computer/local-daemon/README.md
index bcd3dea8..357160e2 100644
--- a/apps/computer/local-daemon/README.md
+++ b/apps/computer/local-daemon/README.md
@@ -503,20 +503,24 @@ On macOS, `click` takes `delivery_mode: "foreground"` and `action`: the first fo
The macOS and Linux developer instructions identify the public entry. Codex
0.163.0 and later calls the public tools directly, outside code mode and
deferred tool search. Earlier versions use their standard tool discovery.
-Web tools depend on where the Runtime's model is served. On a subscription,
-Claude Code keeps `WebSearch` and `WebFetch`, deferred behind `ToolSearch`, so
-its developer instructions name them and how to load them; Codex keeps its own
-`web_search`. Both are also told that `teamhub web search` and `teamhub web open`
-search and read through the search providers the user set up, or DuckDuckGo
-without a key. A Runtime whose
-profile is a localmodels-managed gateway profile (local models or BYOK, see
-`localmodels.GatewayRuntime`) cannot run provider-hosted search: Codex launches
-with `web_search="disabled"` after every user override, Claude's `--tools` leaves
-out `WebSearch` and `WebFetch`, and the instructions name only `teamhub web
-search`, `open` and `list`. Pi has no web tools of its own and always gets that
-`teamhub web` line. Without a TeamHub CLI for the Agent, only Claude's own tools
-are named. A parked Codex process launched with the other web setting is not
-reused.
+Web tools depend on the link the Runtime reaches its model through
+(`RuntimeModel.Link`). On a vendor subscription, Claude Code keeps `WebSearch`
+and `WebFetch`, deferred behind `ToolSearch`, so its developer instructions name
+them and how to load them; Codex keeps its own `web_search`. Both are told to
+use their own tools first and, when those fail, `teamhub web search` and
+`teamhub web open`, which search and read through the search providers the user
+set up, or DuckDuckGo without a key. On an API link, an endpoint and key set up
+in the Runtime's own configuration, provider-hosted search may not run, so the
+instructions name `teamhub web search`, `open` and `list` and tell the model to
+use them instead of its own web tools. A Runtime whose profile is a
+localmodels-managed gateway profile (local models or BYOK, see
+`localmodels.GatewayRuntime`) is on an API link that cannot run provider-hosted
+search at all: Codex launches with `web_search="disabled"` after every user
+override, Claude's `--tools` leaves out `WebSearch` and `WebFetch`, and the
+instructions name only the `teamhub web` commands. Pi has no web tools of its
+own and always gets that `teamhub web` line. Without a TeamHub CLI for the
+Agent, only Claude's own tools are named. A parked Codex process launched with
+the other web setting is not reused.
On macOS these tools show only the fields the Computer routes. They hide Cua's `scope` and `capture_id`; only `click` takes `delivery_mode`, as described above.
Within `ui_exec`, scripts can call individual input methods. An input to a
diff --git a/apps/computer/local-daemon/cmd/linger-computer-daemon/main.go b/apps/computer/local-daemon/cmd/linger-computer-daemon/main.go
index 7f9ab605..d3eb6b4f 100644
--- a/apps/computer/local-daemon/cmd/linger-computer-daemon/main.go
+++ b/apps/computer/local-daemon/cmd/linger-computer-daemon/main.go
@@ -745,10 +745,12 @@ func providerInstallations(discovered provider.DiscoveryResult, environment map[
contextWindows[model.ID] = model.ContextWindow
}
}
+ gateway := localmodels.GatewayRuntime(environment, localModelsStateDir, runtimeType)
providers[runtimeType] = lingercontext.ProviderInstallation{
Type: runtimeType, ExecutablePath: diagnostic.ExecutablePath, EntryPath: diagnostic.EntryPath,
Environment: runtimeEnvironment, Version: diagnostic.Version, ContextWindows: contextWindows,
- ModelGateway: localmodels.GatewayRuntime(environment, localModelsStateDir, runtimeType),
+ ModelGateway: gateway,
+ APILink: gateway || slices.ContainsFunc(diagnostic.Models, provider.RuntimeModel.OnAPILink),
}
runtimes = append(runtimes, runtimeType)
}
diff --git a/apps/computer/local-daemon/cmd/linger-computer-daemon/main_test.go b/apps/computer/local-daemon/cmd/linger-computer-daemon/main_test.go
index c3bf9eb6..af05a965 100644
--- a/apps/computer/local-daemon/cmd/linger-computer-daemon/main_test.go
+++ b/apps/computer/local-daemon/cmd/linger-computer-daemon/main_test.go
@@ -236,6 +236,23 @@ func TestProviderInstallationsKeepDiscoveredContextWindows(t *testing.T) {
}
}
+func TestProviderInstallationsMarkTheAPILink(t *testing.T) {
+ discovered := provider.DiscoveryResult{Installations: map[string]provider.RuntimeDiagnostic{
+ "codex": {Type: "codex", ExecutablePath: "/bin/codex", Models: []provider.RuntimeModel{{ID: "gpt", Link: "api"}}},
+ "claude": {Type: "claude", ExecutablePath: "/bin/claude", Models: []provider.RuntimeModel{{ID: "opus", Link: "subscription"}}},
+ }}
+ installations, _ := providerInstallations(discovered, nil, "")
+ if !installations["codex"].APILink || installations["claude"].APILink {
+ t.Fatalf("API links = codex %v, claude %v", installations["codex"].APILink, installations["claude"].APILink)
+ }
+ state := t.TempDir()
+ gateway := map[string]string{"CLAUDE_CONFIG_DIR": filepath.Join(state, "byok-home", ".claude")}
+ installations, _ = providerInstallations(discovered, gateway, state)
+ if claude := installations["claude"]; !claude.ModelGateway || !claude.APILink {
+ t.Fatalf("gateway Claude = %+v", claude)
+ }
+}
+
func TestByokRuntimeCatalogsShowTheEnteredModel(t *testing.T) {
diagnostics := []provider.RuntimeDiagnostic{
{Type: "claude", Models: []provider.RuntimeModel{
diff --git a/apps/computer/local-daemon/internal/linger/context/resolver.go b/apps/computer/local-daemon/internal/linger/context/resolver.go
index 12cfcdf4..ed9aee9b 100644
--- a/apps/computer/local-daemon/internal/linger/context/resolver.go
+++ b/apps/computer/local-daemon/internal/linger/context/resolver.go
@@ -32,6 +32,12 @@ type ProviderInstallation struct {
// provider-hosted web search, so the Runtime's own web tools stay off and
// the Agent searches with the TeamHub CLI.
ModelGateway bool
+ // APILink marks a Runtime that reaches its models through an API gateway
+ // and key rather than a vendor subscription: the localmodels gateway or
+ // one the user set up in the Runtime's own configuration. Provider-hosted
+ // web search may not run there, so its Agents are told to search with the
+ // TeamHub CLI. Codex and Claude reach every model through one link.
+ APILink bool
}
type WorkspaceGrant struct {
@@ -48,33 +54,42 @@ type RegistrationBinding struct {
Status registration.Status
}
-// claudeWebToolGuide names Claude's web tools for every Operation. Claude Code
+// claudeWebToolGuide names Claude's own web tools when it uses them. Claude Code
// defers their definitions behind ToolSearch, so without it the model often
// does not think to search the web, as with the Computer tools in ToolGuide.
const claudeWebToolGuide = `Web tools: WebSearch searches the web and WebFetch reads one page. They are loaded on demand: before the first call, load them with ToolSearch (query "select:WebSearch,WebFetch").`
-// teamHubWebSupplement follows a subscription Runtime's own web tools.
-const teamHubWebSupplement = "`teamhub web search <query>` and `teamhub web open <url>` also search the web and read pages, through the search providers the user set up, or DuckDuckGo without a key."
+// teamHubWebFallback follows a subscription Runtime's own web tools, which it
+// is told to use first.
+const teamHubWebFallback = "If that fails, `teamhub web search <query>` and `teamhub web open <url>` search the web and read pages through the search providers the user set up, or DuckDuckGo without a key."
-// teamHubWebToolGuide is the only web access of Pi and of a Runtime on local
-// models or BYOK.
+// teamHubWebToolGuide is the web access of Pi and of a Runtime on an API link.
const teamHubWebToolGuide = "Web tools: search the web with `teamhub web search <query>` and read one page as Markdown with `teamhub web open <url>`; `teamhub web list` shows the search backends and which are ready. Run `teamhub web search --help` for filters."
-// webToolGuide describes the web tools an Operation has. Without the TeamHub
-// CLI only Claude's own tools are named.
-func webToolGuide(runtimeType string, modelGateway, teamHubCLI bool) string {
- native := !modelGateway && (runtimeType == "claude" || runtimeType == "codex")
+// teamHubWebOverOwnTools follows teamHubWebToolGuide for a Runtime on an API
+// link that still has its own web tools.
+const teamHubWebOverOwnTools = "Use them instead of your built-in web search and fetch tools, which may not work through the API this model is served by."
+
+// webToolGuide describes the web tools an Operation has. A Runtime on a
+// vendor subscription uses its own web tools first and the TeamHub CLI when
+// they fail; one on an API link uses the TeamHub CLI, and on the localmodels
+// gateway it has no web tools of its own. Without the TeamHub CLI only
+// Claude's own tools are named.
+func webToolGuide(runtimeType string, apiLink, modelGateway, teamHubCLI bool) string {
+ ownTools := !modelGateway && (runtimeType == "claude" || runtimeType == "codex")
switch {
- case !teamHubCLI && native && runtimeType == "claude":
+ case !teamHubCLI && ownTools && runtimeType == "claude":
return claudeWebToolGuide
case !teamHubCLI:
return ""
- case native && runtimeType == "claude":
- return claudeWebToolGuide + " " + teamHubWebSupplement
- case native:
- return "Web tools: besides your built-in web search, " + teamHubWebSupplement
- default:
+ case !ownTools:
return teamHubWebToolGuide
+ case apiLink:
+ return teamHubWebToolGuide + " " + teamHubWebOverOwnTools
+ case runtimeType == "claude":
+ return claudeWebToolGuide + " Use them first. " + teamHubWebFallback
+ default:
+ return "Web tools: use your built-in web search first. " + teamHubWebFallback
}
}
@@ -178,7 +193,8 @@ func (r ExecutionResolver) Resolve(ctx context.Context, command protocol.Command
if err != nil {
return provider.OperationSpec{}, err
}
- webGuide := webToolGuide(command.RuntimeType, installation.ModelGateway, cliInstalled && r.TeamHubCLIBin != "")
+ webGuide := webToolGuide(command.RuntimeType, installation.APILink, installation.ModelGateway,
+ cliInstalled && r.TeamHubCLIBin != "")
if webGuide != "" {
developerInstructions = strings.TrimSpace(developerInstructions + "\n\n" + webGuide)
}
diff --git a/apps/computer/local-daemon/internal/linger/context/resolver_test.go b/apps/computer/local-daemon/internal/linger/context/resolver_test.go
index eaa2908d..11f2a336 100644
--- a/apps/computer/local-daemon/internal/linger/context/resolver_test.go
+++ b/apps/computer/local-daemon/internal/linger/context/resolver_test.go
@@ -297,34 +297,38 @@ func TestExecutionResolverNamesClaudeWebTools(t *testing.T) {
}
}
-func TestWebToolGuideFollowsTheModelSource(t *testing.T) {
+func TestWebToolGuideFollowsTheModelLink(t *testing.T) {
cases := []struct {
- runtimeType string
- gateway, cli bool
- want, notWant string
+ runtimeType string
+ apiLink, gateway, cli bool
+ want, notWant string
}{
- {"claude", false, true, "select:WebSearch,WebFetch", ""},
- {"claude", false, true, "also search the web", ""},
- {"codex", false, true, "besides your built-in web search", "select:WebSearch"},
- {"claude", true, true, "Web tools: search the web with `teamhub web search <query>`", "WebFetch"},
- {"codex", true, true, "`teamhub web list`", "built-in"},
- {"pi", false, true, "`teamhub web open <url>`", "built-in"},
- {"claude", false, false, "select:WebSearch,WebFetch", "teamhub"},
+ {"claude", false, false, true, "select:WebSearch,WebFetch", ""},
+ {"claude", false, false, true, "Use them first. If that fails, `teamhub web search <query>`", ""},
+ {"codex", false, false, true, "use your built-in web search first. If that fails, `teamhub web search", "select:WebSearch"},
+ {"claude", true, false, true, "instead of your built-in web search and fetch tools", "select:WebSearch"},
+ {"codex", true, false, true, "Web tools: search the web with `teamhub web search <query>`", "first"},
+ {"claude", true, true, true, "Web tools: search the web with `teamhub web search <query>`", "built-in"},
+ {"codex", true, true, true, "`teamhub web list`", "built-in"},
+ {"pi", false, false, true, "`teamhub web open <url>`", "built-in"},
+ {"pi", true, false, true, "`teamhub web open <url>`", "built-in"},
+ {"claude", false, false, false, "select:WebSearch,WebFetch", "teamhub"},
+ {"claude", true, false, false, "select:WebSearch,WebFetch", "teamhub"},
}
for _, c := range cases {
- guide := webToolGuide(c.runtimeType, c.gateway, c.cli)
+ guide := webToolGuide(c.runtimeType, c.apiLink, c.gateway, c.cli)
if !strings.Contains(guide, c.want) || (c.notWant != "" && strings.Contains(guide, c.notWant)) {
- t.Fatalf("webToolGuide(%s, gateway=%v, cli=%v) = %q", c.runtimeType, c.gateway, c.cli, guide)
+ t.Fatalf("webToolGuide(%s, api=%v, gateway=%v, cli=%v) = %q", c.runtimeType, c.apiLink, c.gateway, c.cli, guide)
}
}
- if webToolGuide("codex", true, false) != "" || webToolGuide("pi", false, false) != "" {
+ if webToolGuide("codex", true, true, false) != "" || webToolGuide("pi", false, false, false) != "" {
t.Fatal("a guide named teamhub without the TeamHub CLI")
}
}
func TestExecutionResolverTurnsOffNativeWebToolsOnTheGateway(t *testing.T) {
resolver := ExecutionResolver{
- Providers: map[string]ProviderInstallation{"claude": {Type: "claude", ExecutablePath: "/local/bin/claude", ModelGateway: true}},
+ Providers: map[string]ProviderInstallation{"claude": {Type: "claude", ExecutablePath: "/local/bin/claude", ModelGateway: true, APILink: true}},
WorkspaceGrants: map[string]WorkspaceGrant{"grant-local": {GrantID: "grant-local", TenantID: "tenant-acme", Path: "/local/workspace"}},
Views: testContextViews{root: "/local/workspace"},
Registrations: map[string]RegistrationBinding{
diff --git a/apps/computer/local-daemon/internal/provider/discovery.go b/apps/computer/local-daemon/internal/provider/discovery.go
index 19135c6a..d5929d13 100644
--- a/apps/computer/local-daemon/internal/provider/discovery.go
+++ b/apps/computer/local-daemon/internal/provider/discovery.go
@@ -52,6 +52,10 @@ type RuntimeModel struct {
resolved string
}
+// OnAPILink reports whether the Runtime reaches the model through an API
+// gateway and key in its own configuration rather than a vendor subscription.
+func (m RuntimeModel) OnAPILink() bool { return m.Link == linkAPI }
+
type DiagnosticError struct {
Code string `json:"code"`
Message string `json:"message"`
diff --git a/apps/teamhub-cli/README.md b/apps/teamhub-cli/README.md
index deb62129..07a3e6cd 100644
--- a/apps/teamhub-cli/README.md
+++ b/apps/teamhub-cli/README.md
@@ -85,7 +85,7 @@ teamhub web list
teamhub web connect tavily
```
-- `web search <query>` runs on Tavily, Brave Search, Firecrawl or You.com (`--backend`), with `--limit 1-20`, `--recency day|week|month|year` and repeatable `--site <domain>`. Without `--backend` it uses the default backend the user chose, else the first ready backend in that order, else You.com's free trial, which is limited and lower quality. Results carry title, URL, snippet and an optional date, never the backend.
-- `web open <url>` fetches the page from this computer by default (`--backend direct`) and converts its main content to Markdown; `--backend tavily|firecrawl|you` reads it through the provider instead, which helps with pages that need JavaScript or block plain requests. The Markdown is cut at 20,000 characters with `truncated: true`, and `--output <file>` saves it to a new file and never overwrites one.
+- `web search <query>` runs on Tavily, Brave Search, Firecrawl, Exa, You.com or DuckDuckGo (`--backend`), with `--limit 1-20`, `--recency day|week|month|year` and repeatable `--site <domain>`; DuckDuckGo takes at most 10 results and one site. Without `--backend` it uses the default backend the user chose, else the first backend with a key in that order, else DuckDuckGo, which needs no key and blocks searches that come too often. You.com also works without a key when named, with limited, lower quality results. Results carry title, URL, snippet and an optional date, never the backend.
+- `web open <url>` fetches the page from this computer by default (`--backend direct`) and converts its main content to Markdown; `--backend tavily|firecrawl|exa|you` reads it through the provider instead, which helps with pages that need JavaScript or block plain requests. The Markdown is cut at 20,000 characters with `truncated: true`, and `--output <file>` saves it to a new file and never overwrites one.
- `web list` shows each backend's commands, filters, readiness and live quota; `web connect <backend>` posts a key card unless that backend is ready.
-- A backend never falls back to another one. When the requested backend, or the default one, has no key, a rejected key or a used-up free trial, TeamHub posts a key card in the chat and the command exits 4 with `search_key_requested`, the backend and the card in `details`. The Agent ends its turn: a key saved from the card reruns the request and wakes the Agent with its results. A used-up quota (`search_quota_exhausted`) or rate limit (`provider_rate_limited`) lists `ready_backends` to choose from.
+- A backend never falls back to another one. When the requested backend, or the default one, has no key, a rejected key or no keyless searches left, TeamHub posts a key card in the chat and the command exits 4 with `search_key_requested`, the backend and the card in `details`. The Agent ends its turn: a key saved from the card reruns the request and wakes the Agent with its results. A used-up quota (`search_quota_exhausted`) or rate limit (`provider_rate_limited`) lists `ready_backends` to choose from.
diff --git a/docs/local-inference.md b/docs/local-inference.md
index 8ea92e90..2ff2cd7f 100644
--- a/docs/local-inference.md
+++ b/docs/local-inference.md
@@ -44,12 +44,16 @@ confirm.
## Web search
-On Subscription, Claude Code and Codex keep their own web search. On Local
-model and BYOK the gateway cannot run that provider-hosted search, so the
-computer turns it off and agents search and read pages with `teamhub web search`
-and `teamhub web open`, as Pi always does. Those commands use the web search
-providers set up on the server (Tavily, Brave Search, Firecrawl, Exa or
-You.com).
+On Subscription, Claude Code and Codex keep their own web search, and agents
+are told to use it first and `teamhub web search` and `teamhub web open` when it
+fails. On Local model and BYOK the gateway cannot run that provider-hosted
+search, so the computer turns it off and agents search and read pages only with
+`teamhub web search` and `teamhub web open`, as Pi always does. A Claude Code
+or Codex that reaches its model through an API endpoint set up in its own
+configuration keeps its web tools, but agents are told to use the `teamhub web`
+commands instead, since those tools may not work through that API. The
+commands use the web search providers set up on the server (Tavily, Brave
+Search, Firecrawl, Exa or You.com).
Without any key they search DuckDuckGo, which is free but blocks searches that
come too often; You.com also works without a key, with lower quality. Pages are
read from this computer by default. When a provider needs a key, a card in the