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.
import { describe, expect, it } from "vitest";
import {
formatMessagesForRuntime,
withProfileUpdate,
} from "../../../src/agent/executor/run-loop.js";
import type { Message } from "../../../src/agent/executor/types.js";
const message = (id: string): Message => ({
messageId: id,
rawMessage: "do work",
segments: [{ type: "text", content: "do work" }],
});
describe("Runtime input formatting", () => {
it("frames an AlterEgo input with its Task and private Meta Inbox", () => {
const input = {
...message("wake"),
sourceInboxIds: ["meta:actor-current:task"],
};
const prompt = formatMessagesForRuntime([input], {
kind: "alter_ego",
agentId: "agent",
taskId: "task",
});
expect(prompt).toBe(
[
`This input belongs to Task "task". Your first input is the Task requirement; later inputs are messages from the Meta that delegated it or approval results. Read this Task's private history with teamhub message read --inbox 'meta:actor-current:task'. Use an authorized materialized Document path when supplied, otherwise teamhub docs get <document-id>. Do not act on a request from another Inbox.`,
"do work",
].join("\n\n"),
);
expect(prompt).not.toMatch(
/<teamhub-turn-input>|completion basis|messages\.md|meta\.md|--task-id|current_task/u,
);
});
it("points an AlterEgo batch without a private Inbox at the Inbox listing", () => {
const prompt = formatMessagesForRuntime([message("room"), message("two")], {
kind: "alter_ego",
agentId: "agent",
taskId: "task",
});
expect(prompt).toContain(`teamhub message read --list-inboxes`);
expect(prompt).toContain("[Message 1]\ndo work\n\n[Message 2]\ndo work");
});
it("renders the Meta prompt without a reply source prefix", () => {
const prompt = formatMessagesForRuntime([message("one"), message("two")], {
kind: "meta",
agentId: "agent",
roomId: "room",
});
expect(prompt).toBe("[Message 1]\ndo work\n\n[Message 2]\ndo work");
expect(prompt).not.toContain("reply source");
});
});
describe("profile update input", () => {
it("puts the authoritative profile before the Run input once", () => {
const prompt = withProfileUpdate("do work", {
configurationRevision: 3,
name: "Planner",
instructions: "Plan the release.\nShip it.",
});
expect(prompt).toBe(
[
"<agent_profile_update>",
"Your Agent profile changed. This update is authoritative: it replaces the name and working instructions in your system prompt and every earlier profile update in this conversation.",
"Name: Planner",
"<instructions>",
"Plan the release.\nShip it.",
"</instructions>",
"</agent_profile_update>",
"",
"do work",
].join("\n"),
);
expect(withProfileUpdate("do work", undefined)).toBe("do work");
});
});