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.

fix(web): deduplicate local model Used by list via agent_management_id

Dongdong Chene325773dde87
diff --git a/apps/web/src/features/local-models/local-model-agents.test.ts b/apps/web/src/features/local-models/local-model-agents.test.ts
index bd6c71d9..9918ee65 100644
--- a/apps/web/src/features/local-models/local-model-agents.test.ts
+++ b/apps/web/src/features/local-models/local-model-agents.test.ts
@@ -73,6 +73,7 @@ describe("local-model-agents", () => {
codexOnLab.actor.id,
]);
expect(result[0]!).toMatchObject({
+ agentManagementId: delegate!.agent_management_id,
busy: false,
grantId: "grant-rw",
isAnotherMe: true,
@@ -172,6 +173,29 @@ describe("local-model-agents", () => {
expect(
usedByAgentNames(sameNameEntry, [sameNameAgent], "computer-lab"),
).toEqual(["Helper", "Helper"]);
+
+ const alreadyInSnapshot = {
+ ...entry,
+ used_by: [
+ {
+ agent_id: delegate.agent_management_id,
+ name: delegate.actor.display_name,
+ },
+ ],
+ };
+ expect(
+ usedByAgentNames(alreadyInSnapshot, [agent!], "computer-lab"),
+ ).toEqual(["Jenny's Delegate"]);
+ expect(
+ isAgentUsingModel(
+ {
+ ...alreadyInSnapshot,
+ model: { ...alreadyInSnapshot.model, pi_model: undefined },
+ },
+ agent!,
+ "computer-lab",
+ ),
+ ).toBe(true);
});
it("omits incompatible Claude reasoning efforts when Pi has not listed the model yet, and preserves valid Pi efforts when listed", () => {
@@ -183,6 +207,7 @@ describe("local-model-agents", () => {
};
const baseAgent = {
actorId: "actor-delegate",
+ agentManagementId: "anotherme-jenny",
busy: false,
configurationRevision: 3,
currentComputerId: "computer-lab",
diff --git a/apps/web/src/features/local-models/local-model-agents.ts b/apps/web/src/features/local-models/local-model-agents.ts
index f0859d22..54e704b1 100644
--- a/apps/web/src/features/local-models/local-model-agents.ts
+++ b/apps/web/src/features/local-models/local-model-agents.ts
@@ -12,6 +12,7 @@ import type { ModelEntry } from "./local-models-rules";
/** A Sponsor-owned Agent eligible to run against a loaded Local Model on one Computer. */
export interface AssignableLocalModelAgent {
actorId: string;
+ agentManagementId: string;
busy: boolean;
configurationRevision: number;
currentComputerId?: string;
@@ -77,6 +78,7 @@ export function assignableLocalModelAgents(
if (!grantId) continue;
result.push({
actorId: agent.actor.id,
+ agentManagementId: agent.agent_management_id,
busy: busyByActorId.get(agent.actor.id) ?? false,
configurationRevision: agent.configuration_revision,
currentComputerId: placement?.computer_id,
@@ -106,7 +108,7 @@ export function isAgentUsingModel(
agent: AssignableLocalModelAgent,
computerId: string,
): boolean {
- if (entry.used_by.some((user) => user.agent_id === agent.actorId)) {
+ if (entry.used_by.some((user) => user.agent_id === agent.agentManagementId)) {
return true;
}
return (
@@ -127,7 +129,7 @@ export function usedByAgentNames(
for (const agent of assignableAgents) {
if (
isAgentUsingModel(entry, agent, computerId) &&
- !entry.used_by.some((user) => user.agent_id === agent.actorId)
+ !entry.used_by.some((user) => user.agent_id === agent.agentManagementId)
) {
names.push(agent.name);
}