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.
fix(computer): run Pi background calls on Pi's default model
whitef8813385c9eb
diff --git a/apps/computer/AGENTS.md b/apps/computer/AGENTS.mdindex 1a084c83..2d6c6cc9 100644--- a/apps/computer/AGENTS.md+++ b/apps/computer/AGENTS.md@@ -61,9 +61,9 @@## Runtime And Safety-- A Pi background model call uses one ephemeral RPC turn with no tools. It- checks the Runtime's actual default against the local library's loaded- models and a loopback endpoint before submitting the prompt.+- A Pi background model call uses one ephemeral RPC turn with no tools on+ whatever model Pi's profile selects by default, local or remote; the Daemon+ does not check which.- Default tests use deterministic providers and real fixture child processes;they never call a live model.diff --git a/apps/computer/local-daemon/cmd/linger-computer-daemon/main.go b/apps/computer/local-daemon/cmd/linger-computer-daemon/main.goindex 41d82c99..276dd413 100644--- a/apps/computer/local-daemon/cmd/linger-computer-daemon/main.go+++ b/apps/computer/local-daemon/cmd/linger-computer-daemon/main.go@@ -409,13 +409,9 @@ func run(args []string) (resultErr error) {RuntimeHomeRoot: filepath.Join(computer.StateDirectory, "runtime-homes"),Lookup: func(ctx context.Context, runtimeType string) (provider.ModelInvokeRuntime, bool, error) {installed, ok, err := providerCatalog.Lookup(ctx, runtimeType)- runtime := provider.ModelInvokeRuntime{+ return provider.ModelInvokeRuntime{ExecutablePath: installed.ExecutablePath, Environment: installed.Environment, Version: installed.Version,- }- if runtimeType == "pi" {- runtime.LoadedPiModels = localModels.LoadedPiModels()- }- return runtime, ok, err+ }, ok, err},},})diff --git a/apps/computer/local-daemon/internal/localmodels/library.go b/apps/computer/local-daemon/internal/localmodels/library.goindex 2b1b065e..27c943db 100644--- a/apps/computer/local-daemon/internal/localmodels/library.go+++ b/apps/computer/local-daemon/internal/localmodels/library.go@@ -338,21 +338,6 @@ func (l *Library) commit(snapshot wire.LocalModelsSnapshot) {l.publish(cloneSnapshot(snapshot))}-// LoadedPiModels returns the Pi names of models loaded in the last library report.-func (l *Library) LoadedPiModels() []string {- l.mu.Lock()- defer l.mu.Unlock()- var models []string- if l.current != nil && l.current.Available {- for _, model := range l.current.Models {- if model.State == "loaded" && model.PiModel != "" {- models = append(models, model.PiModel)- }- }- }- return models-}-// Act starts one action and returns the tool's answer: accepted (nil) or// its refusal. deadline is when the requester stops waiting. When it passes// before the tool has decided, answered is false: the Daemon does not guessdiff --git a/apps/computer/local-daemon/internal/provider/model_invoke.go b/apps/computer/local-daemon/internal/provider/model_invoke.goindex 9123e6b3..8b5b6d2e 100644--- a/apps/computer/local-daemon/internal/provider/model_invoke.go+++ b/apps/computer/local-daemon/internal/provider/model_invoke.go@@ -106,7 +106,6 @@ type ModelInvokeRuntime struct {ExecutablePath stringEnvironment map[string]stringVersion string- LoadedPiModels []string}// ModelInvokeFile is one workspace file, relative to the working directory.diff --git a/apps/computer/local-daemon/internal/provider/native/pi_catalog.go b/apps/computer/local-daemon/internal/provider/native/pi_catalog.goindex 55f4d8cc..ef4a9973 100644--- a/apps/computer/local-daemon/internal/provider/native/pi_catalog.go+++ b/apps/computer/local-daemon/internal/provider/native/pi_catalog.go@@ -24,7 +24,6 @@ type piCatalogState struct {Model struct {ID string `json:"id"`Provider string `json:"provider"`- BaseURL string `json:"baseUrl"`} `json:"model"`ThinkingLevel string `json:"thinkingLevel"`}diff --git a/apps/computer/local-daemon/internal/provider/native/pi_model_invoke.go b/apps/computer/local-daemon/internal/provider/native/pi_model_invoke.goindex 402570ed..2db939bb 100644--- a/apps/computer/local-daemon/internal/provider/native/pi_model_invoke.go+++ b/apps/computer/local-daemon/internal/provider/native/pi_model_invoke.go@@ -5,22 +5,12 @@ import ("encoding/json""errors""log/slog"- "net/netip"- "net/url"- "slices"- "strings")-// ErrPiLocalModelUnavailable means Pi has no verified loaded local default.-// Do not send a background prompt to an unverified endpoint.-var ErrPiLocalModelUnavailable = errors.New("Pi background calls need a loaded local model selected as Pi's default")--// InvokePiModel runs a single tool-free RPC turn with the same Pi profile and-// event handling as managed execution, but with no persistent session.-func InvokePiModel(ctx context.Context, profile Profile, dir, instructionsFile, prompt, effort string, loadedModels []string) (Outcome, string, error) {- if len(loadedModels) == 0 {- return Outcome{}, "", ErrPiLocalModelUnavailable- }+// InvokePiModel runs a single tool-free RPC turn on Pi's default model, with+// the same Pi profile and event handling as managed execution but no+// persistent session. It returns the model Pi ran.+func InvokePiModel(ctx context.Context, profile Profile, dir, instructionsFile, prompt, effort string) (Outcome, string, error) {thinking, err := piThinkingLevel(effort)if err != nil {return Outcome{}, "", err@@ -55,16 +45,13 @@ func InvokePiModel(ctx context.Context, profile Profile, dir, instructionsFile,probeCtx, cancelProbe := context.WithTimeout(ctx, piStartupBudget)state, err := proc.call(probeCtx, "get_state", nil, nil)cancelProbe()- if err != nil {- return Outcome{}, "", errors.New("Pi background model state could not be read")- }var catalog piCatalogState- if json.Unmarshal(state.Data, &catalog) != nil {- return Outcome{}, "", ErrPiLocalModelUnavailable+ if err != nil || json.Unmarshal(state.Data, &catalog) != nil {+ return Outcome{}, "", errors.New("Pi background model state could not be read")}- model := catalog.Model.Provider + "/" + catalog.Model.ID- if !slices.Contains(loadedModels, model) || !piLoopbackURL(catalog.Model.BaseURL) {- return Outcome{}, "", ErrPiLocalModelUnavailable+ model := ""+ if catalog.Model.ID != "" {+ model = catalog.Model.Provider + "/" + catalog.Model.ID}runCtx, cancel := context.WithCancel(ctx)defer cancel()@@ -78,13 +65,3 @@ func InvokePiModel(ctx context.Context, profile Profile, dir, instructionsFile,}return <-turn.outcome, model, nil}--func piLoopbackURL(raw string) bool {- endpoint, err := url.Parse(raw)- if err != nil || endpoint.User != nil || (endpoint.Scheme != "http" && endpoint.Scheme != "https") {- return false- }- host := endpoint.Hostname()- ip, err := netip.ParseAddr(host)- return (err == nil && ip.Unmap().IsLoopback()) || strings.EqualFold(host, "localhost")-}diff --git a/apps/computer/local-daemon/internal/provider/native/pi_model_invoke_test.go b/apps/computer/local-daemon/internal/provider/native/pi_model_invoke_test.godeleted file mode 100644index 06656f52..00000000--- a/apps/computer/local-daemon/internal/provider/native/pi_model_invoke_test.go+++ /dev/null@@ -1,16 +0,0 @@-package native--import "testing"--func TestPiBackgroundEndpointMustBeLoopback(t *testing.T) {- for _, endpoint := range []string{"http://127.0.0.1:8080/v1", "http://[::1]:8080", "http://localhost:8080"} {- if !piLoopbackURL(endpoint) {- t.Errorf("refused loopback endpoint %s", endpoint)- }- }- for _, endpoint := range []string{"", "http://localhost.example.test", "https://example.test/v1", "http://[email protected]", "file://localhost/model"} {- if piLoopbackURL(endpoint) {- t.Errorf("accepted non-loopback endpoint %s", endpoint)- }- }-}diff --git a/apps/computer/local-daemon/internal/provider/pi_model_invoke.go b/apps/computer/local-daemon/internal/provider/pi_model_invoke.goindex b8ec8f23..e1aca9e4 100644--- a/apps/computer/local-daemon/internal/provider/pi_model_invoke.go+++ b/apps/computer/local-daemon/internal/provider/pi_model_invoke.go@@ -2,10 +2,8 @@ package providerimport ("context"- "errors""os""path/filepath"- "strings""github.com/simplexai-labs/linger/apps/computer/local-daemon/internal/provider/native"localworkspace "github.com/simplexai-labs/linger/apps/computer/local-daemon/internal/workspace"@@ -15,15 +13,7 @@ func invokePiModel(ctx context.Context, request ModelInvokeRequest, installed Moif request.Mode == ModelInvokeWorkspace {return ModelInvokeResult{Outcome: ModelInvokeRuntimeUnavailable, Reason: "Pi background calls do not run file tools"}}- environment := modelInvokeEnvironment(installed.Environment, scratch)- // The verified loopback endpoint must not be routed through a user proxy.- for key := range environment {- switch strings.ToUpper(key) {- case "HTTP_PROXY", "HTTPS_PROXY", "ALL_PROXY":- delete(environment, key)- }- }- environment, err := localworkspace.PiSourceEnvironment(environment)+ environment, err := localworkspace.PiSourceEnvironment(modelInvokeEnvironment(installed.Environment, scratch))if err != nil {return ModelInvokeResult{Outcome: ModelInvokeRuntimeUnavailable, Reason: "Pi background profile is unavailable"}}@@ -42,13 +32,11 @@ func invokePiModel(ctx context.Context, request ModelInvokeRequest, installed Modefer cancel()answer, model, err := native.InvokePiModel(invokeCtx, native.Profile{Program: installed.ExecutablePath, Env: environment},- work, instructionsFile, request.Input, request.ReasoningEffort, installed.LoadedPiModels,+ work, instructionsFile, request.Input, request.ReasoningEffort,)switch {case invokeCtx.Err() != nil:return classifyModelInvokeFailure(ctx, invokeCtx, err, "", "")- case errors.Is(err, native.ErrPiLocalModelUnavailable):- return ModelInvokeResult{Outcome: ModelInvokeRuntimeUnavailable, Reason: err.Error()}case err != nil || answer.Status != "completed" || !answer.ExitConfirmed:// Pi errors may include provider URLs or credentials.return ModelInvokeResult{Outcome: ModelInvokeFailed, Reason: "Pi background call did not complete"}diff --git a/apps/computer/local-daemon/internal/provider/pi_model_invoke_test.go b/apps/computer/local-daemon/internal/provider/pi_model_invoke_test.goindex 4b7d90c8..37e26836 100644--- a/apps/computer/local-daemon/internal/provider/pi_model_invoke_test.go+++ b/apps/computer/local-daemon/internal/provider/pi_model_invoke_test.go@@ -14,7 +14,7 @@ import ("time")-func TestModelInvokerPiLocal(t *testing.T) {+func TestModelInvokerPi(t *testing.T) {if runtime.GOOS == "windows" {t.Skip("fixture launches the POSIX pnpm Pi shim")}@@ -64,13 +64,12 @@ data: [DONE]}write("models.json", fmt.Sprintf(`{"providers":{"local-fixture":{"baseUrl":%q,"api":"openai-completions","apiKey":"fixture","models":[{"id":"fixture"}]}}}`, server.URL+"/v1"))write("settings.json", `{"defaultProvider":"local-fixture","defaultModel":"fixture"}`)- loaded := []string{"local-fixture/fixture"}invoker := ModelInvoker{TempBase: root,Lookup: func(_ context.Context, runtime string) (ModelInvokeRuntime, bool, error) {return ModelInvokeRuntime{- ExecutablePath: pi, LoadedPiModels: loaded,- Environment: map[string]string{"HOME": root, "PI_CODING_AGENT_DIR": root, "PATH": os.Getenv("PATH")},+ ExecutablePath: pi,+ Environment: map[string]string{"HOME": root, "PI_CODING_AGENT_DIR": root, "PATH": os.Getenv("PATH")},}, runtime == "pi", nil},}@@ -94,25 +93,15 @@ data: [DONE]}})}- for _, test := range []struct {- name, mode, reason string- loaded []string- }{- {name: "not loaded", mode: ModelInvokeText, reason: "loaded local model"},- {name: "default is not loaded", mode: ModelInvokeText, reason: "loaded local model", loaded: []string{"local-fixture/other"}},- {name: "file tools are not enabled", mode: ModelInvokeWorkspace, reason: "file tools", loaded: loaded},- } {- t.Run(test.name, func(t *testing.T) {- loaded = test.loaded- result := invoker.Invoke(t.Context(), ModelInvokeRequest{RuntimeType: "pi", Mode: test.mode, Input: "Must not be sent.", Timeout: 15 * time.Second})- if result.Outcome != ModelInvokeRuntimeUnavailable || !strings.Contains(result.Reason, test.reason) {- t.Fatalf("Pi invocation = %+v", result)- }- select {- case <-payloads:- t.Fatal("sent a prompt before Pi was eligible for the call")- default:- }- })- }+ t.Run("file tools are not enabled", func(t *testing.T) {+ result := invoker.Invoke(t.Context(), ModelInvokeRequest{RuntimeType: "pi", Mode: ModelInvokeWorkspace, Input: "Must not be sent.", Timeout: 15 * time.Second})+ if result.Outcome != ModelInvokeRuntimeUnavailable || !strings.Contains(result.Reason, "file tools") {+ t.Fatalf("Pi invocation = %+v", result)+ }+ select {+ case <-payloads:+ t.Fatal("sent a prompt for a workspace call")+ default:+ }+ })}diff --git a/apps/node-services/src/agent/AGENTS.md b/apps/node-services/src/agent/AGENTS.mdindex 2552067e..6e2a93f1 100644--- a/apps/node-services/src/agent/AGENTS.md+++ b/apps/node-services/src/agent/AGENTS.md@@ -39,8 +39,9 @@ take precedence.It is not a Runtime turn and never creates a Context, Local Run, orOperation. Callers name an owner (or an Agent placement) and a reasoningeffort; never add a model name, gateway, or model environment variable. Pi- stays on Pi and requires a loaded local default. It serves structured and- text calls without tools; workspace mode remains on Codex and Claude.+ stays on Pi, on whatever model Pi defaults to, and never falls back to+ Codex or Claude. It serves structured and text calls without tools; workspace mode remains on+ Codex and Claude.- TeamHub owns persisted Agent Runtime configuration, Execution Context,accepted input, Inbox cursor, Local Run, RuntimeSession, Runtime status,Local Computer and Agent placement state. Agent Runners and Operations livediff --git a/apps/node-services/src/agent/runner-gateway/runner-model-invocation.ts b/apps/node-services/src/agent/runner-gateway/runner-model-invocation.tsindex 651fed5c..97f51c19 100644--- a/apps/node-services/src/agent/runner-gateway/runner-model-invocation.ts+++ b/apps/node-services/src/agent/runner-gateway/runner-model-invocation.ts@@ -251,7 +251,7 @@ export class RunnerModelInvocation {if (!connections.supportsModelInvoke(computerId, runtimeType)) {throw new RunnerModelInvokeUnavailableError(runtimeType === "pi"- ? "Pi is not ready for background model calls. Update the Local Computer and load its local model."+ ? "Pi is not ready for background model calls. Update the Local Computer and check that Pi is ready.": `Local Computer Runtime ${runtimeType} is not ready`,);}diff --git a/apps/node-services/tests/agent/runner-gateway/go-local-daemon-process.test.ts b/apps/node-services/tests/agent/runner-gateway/go-local-daemon-process.test.tsindex 25b8ba2c..32db5968 100644--- a/apps/node-services/tests/agent/runner-gateway/go-local-daemon-process.test.ts+++ b/apps/node-services/tests/agent/runner-gateway/go-local-daemon-process.test.ts@@ -280,7 +280,7 @@ const publishContextView = async (};processTest(- "runs Memory and Wiki through a Pi-only Daemon and a loopback model endpoint",+ "runs Memory and Wiki on a Pi-only Daemon with whatever model Pi defaults to",async () => {const root = await mkdtemp(path.join(os.tmpdir(), "go-daemon-pi-model-"));const computerId = "computer-pi-background";@@ -370,46 +370,10 @@ processTest(const config = path.join(root, "computer.json");const profile = path.join(root, ".pi", "agent");const credential = path.join(root, "runner-token");- const library = path.join(root, "localmodels-fixture");await mkdir(profile, { recursive: true });- const report = JSON.stringify({- schema: "localmodels.library-status/v1",- tool_version: "fixture",- host: {- platform: "darwin",- arch: "arm64",- os_label: "fixture",- engine_label: "fixture",- ram_total_bytes: 1024,- disk_free_bytes: 1024,- gpus: [],- },- models: [- {- id: "model",- name: "Fixture",- description: "",- quant: "fixture",- context_tokens: 65536,- vision: false,- download_bytes: 0,- memory_bytes: 0,- fit: "none",- recommended: false,- availability: { downloadable: true },- state: "loaded",- pi_model: piModel,- },- ],- });await Promise.all([installDaemonBinary(binary),writeFile(credential, token, { mode: 0o600 }),- writeFile(- library,- `#!/bin/sh\n[ "$5 $6" = "library status" ] || exit 2\ncat <<'EOF'\n${report}\nEOF\n`,- { mode: 0o700 },- ),writeFile(path.join(profile, "settings.json"),JSON.stringify({@@ -427,6 +391,13 @@ processTest(apiKey: "fixture",models: [{ id: "model" }],},+ // Stands in for the person's own endpoint and API key.+ "fixture-own-key": {+ baseUrl: `http://127.0.0.1:${port}/v1`,+ api: "openai-completions",+ apiKey: "fixture-own-key",+ models: [{ id: "hosted" }],+ },},}),),@@ -451,12 +422,6 @@ processTest(root_path: root,},],- local_models: {- python: library,- module_directory: root,- state_directory: root,- base_directory: root,- },}),{ mode: 0o600 },),@@ -480,11 +445,6 @@ processTest(expect(gateway.supportsModelInvoke(computerId, "pi"), stderr).toBe(true,);- expect(- testRegistryOf(gateway).localModels(computerId).at(-1)?.models[0]- ?.pi_model,- stderr,- ).toBe(piModel);},{ timeout: 15_000 },);@@ -516,6 +476,25 @@ processTest().resolves.toEqual({ output: "Wiki fixture reply.", model: piModel });expect(inputs).toHaveLength(2);expect(inputs[1]).toContain("Wiki fixture evidence");+ // Background calls follow Pi's default, whichever provider serves it.+ await writeFile(+ path.join(profile, "settings.json"),+ JSON.stringify({+ defaultProvider: "fixture-own-key",+ defaultModel: "hosted",+ }),+ );+ await expect(+ model.chain(+ { kind: "wiki", key: "fixture-own-key", anotherMe, signal },+ (chain) => chain.text({ step: "write", input: "Own key evidence" }),+ ),+ ).resolves.toEqual({+ output: "Wiki fixture reply.",+ model: "fixture-own-key/hosted",+ });+ expect(inputs).toHaveLength(3);+ expect(inputs[2]).toContain("Own key evidence");expect(inputs.every((input) => !input.includes('"tools":[{'))).toBe(true);} finally {model.close();diff --git a/apps/teamhub/internal/roomagent/model_call.go b/apps/teamhub/internal/roomagent/model_call.goindex 81aa8d4c..4067640c 100644--- a/apps/teamhub/internal/roomagent/model_call.go+++ b/apps/teamhub/internal/roomagent/model_call.go@@ -1,7 +1,7 @@// Model calls ask the Agent Service for one stateless model answer-// (POST /v1/model-calls). The Agent Service runs it on the Codex or Claude-// Runtime of the owner's Another Me Computer with the Runtime's default model,-// so TeamHub names only a reasoning effort and never a model.+// (POST /v1/model-calls). The Agent Service runs it on the Runtime of the+// owner's Another Me Computer (Codex, Claude or Pi) with the model that Runtime+// serves by default, so TeamHub names only a reasoning effort and never a model.package roomagentdiff --git a/contracts/runner-gateway/asyncapi.yaml b/contracts/runner-gateway/asyncapi.yamlindex 6424c796..a45d0fa5 100644--- a/contracts/runner-gateway/asyncapi.yaml+++ b/contracts/runner-gateway/asyncapi.yaml@@ -42,8 +42,8 @@ info:the playground.execute with kind model_invoke is a one-shot model call on the Computer'sCodex, Claude or Pi Runtime that has no Context, takes no execution slot- and is not in the Operation ledger. A Pi call needs a loaded local default- model and has no workspace tools. The service sends Pi calls only to a+ and is not in the Operation ledger. A Pi call runs on Pi's default model and+ has no workspace tools. The service sends Pi calls only to aComputer release that can decode them. The Agent Service's model schedulerdecides when a call is sent; the Daemon runs every call it receives. Itsoptional session_key lets a Daemon answer the structured Codex calls ofdiff --git a/docs/local-inference.md b/docs/local-inference.mdindex 62392c13..fd50ac01 100644--- a/docs/local-inference.md+++ b/docs/local-inference.md@@ -40,12 +40,12 @@ confirm.Memory facts and reports, Agent Memory, and personal Wiki generation use theRuntime on the Computer where the relevant Agent is placed. On Pi, these calls-require a Computer Daemon at 0.55.0 or later and a default Pi model loaded in-the local library and served over loopback. Downloaded is not Loaded. Use the-local model setup or **Settings › Models** to load the model and use it for-Agents. Background Pi calls run without tools or a saved Pi session. If Pi-or its loaded local default is unavailable, they wait or fail with a Runtime-error; they do not switch to Codex, Claude Code or a remote Pi model.+require a Computer Daemon at 0.55.0 or later and run on the same model as+Pi's own work: its default model, whether that is a local model or your own+endpoint and key. Under Local model, downloaded is not loaded; load the model+from setup or **Settings › Models**. Background Pi calls run without tools or+a saved Pi session. If Pi or its model is unavailable, they wait or fail with+a Runtime error; they never switch to Codex or Claude Code.A Codex or Claude Code placement can still use the other ready Runtime onthat Computer. These calls use the chosen Runtime's default endpoint; ifdiff --git a/docs/self-hosting.md b/docs/self-hosting.mdindex b5bf891a..8dc2f932 100644--- a/docs/self-hosting.md+++ b/docs/self-hosting.md@@ -9,9 +9,9 @@ Docker Compose builds every service from this checkout and runs it, PostgreSQLand voice included. You need Docker with Compose. Linger needs no modelgateway or API key of its own. Model calls run through a Runtime on theuser's Computer, using its configured model endpoint. Memory and personal Wiki-work on Pi when its default model is loaded in the Computer's local library-and reached through the local gateway. This requires a Computer Daemon that-supports Pi background calls (0.55.0 or later), not a Codex or Claude Code login.+work on Pi runs on Pi's default model, local or your own API key. This+requires a Computer Daemon that supports Pi background calls (0.55.0 or+later), not a Codex or Claude Code login.See [Local Inference](local-inference.md#background-memory-and-wiki) for thebackground routing rules.