Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
86 changes: 70 additions & 16 deletions CHANGELOG.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@agentmemory/agentmemory",
"version": "0.9.21",
"version": "0.9.22",
"description": "Persistent memory for AI coding agents, powered by iii-engine's three primitives",
"type": "module",
"main": "dist/index.mjs",
Expand Down
2 changes: 1 addition & 1 deletion packages/mcp/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@agentmemory/mcp",
"version": "0.9.21",
"version": "0.9.22",
"description": "Standalone MCP server for agentmemory — thin shim that re-exposes @agentmemory/agentmemory's MCP entrypoint",
"type": "module",
"bin": {
Expand Down
2 changes: 1 addition & 1 deletion plugin/.claude-plugin/plugin.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "agentmemory",
"version": "0.9.21",
"version": "0.9.22",
"description": "Persistent memory for AI coding agents -- captures tool usage, compresses via LLM, injects context into future sessions. 12 hooks, 51 MCP tools, 4 skills, real-time viewer.",
"author": {
"name": "Rohit Ghumare",
Expand Down
2 changes: 1 addition & 1 deletion plugin/.codex-plugin/plugin.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "agentmemory",
"version": "0.9.21",
"version": "0.9.22",
"description": "Persistent memory for AI coding agents -- captures tool usage, compresses via LLM, injects context into future sessions. 6 hooks, 51 MCP tools, 4 skills, real-time viewer.",
"author": {
"name": "Rohit Ghumare",
Expand Down
6 changes: 3 additions & 3 deletions plugin/opencode/agentmemory-capture.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ const stashedFiles = new Map<string, Set<string>>();
const seenSubtaskIds = new Map<string, Set<string>>();
const seenToolCallIds = new Map<string, Set<string>>();
const contextInjectedSessions = new Set<string>();
// #431: cache the context returned by POST /session/start so the chat
// cache the context returned by POST /session/start so the chat
// system-transform hook can inject it without a second /context fetch.
// Auto-injection now happens at session.created (immediately) AND at
// the first prompt_submit (fallback for older OpenCode builds that
Expand Down Expand Up @@ -196,7 +196,7 @@ export const AgentmemoryCapturePlugin: Plugin = async (ctx) => {
project: projectPath,
cwd: projectPath,
});
// #431: cache the context returned at session/start so the
// cache the context returned at session/start so the
// chat.system.transform hook injects it without a second fetch.
const startCtx = (startResult as any)?.context;
if (typeof startCtx === "string" && startCtx.length > 0) {
Expand Down Expand Up @@ -605,7 +605,7 @@ export const AgentmemoryCapturePlugin: Plugin = async (ctx) => {
if (!contextInjectedSessions.has(sid)) {
if (!Array.isArray(output.system)) return;
output.system.push(AGENTMEMORY_INSTRUCTIONS);
// #431: prefer the context already fetched at session.created;
// prefer the context already fetched at session.created;
// fall back to a fresh /context call if the cache missed (e.g.
// session resumed across plugin reloads).
let ctx = startContextCache.get(sid);
Expand Down
6 changes: 3 additions & 3 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ function detectProvider(env: Record<string, string>): ProviderConfig {
if (hasRealValue(env["OPENROUTER_API_KEY"])) {
const model =
env["OPENROUTER_MODEL"] || "anthropic/claude-sonnet-4-20250514";
// #613: warn when the configured OpenRouter model is in the
// warn when the configured OpenRouter model is in the
// premium tier and likely to burn money on background compression.
// Captured workload data shows ~$5/35h on claude-sonnet-4 vs
// ~$0.46/35h on deepseek-v4-pro for the same compression mix.
Expand Down Expand Up @@ -241,7 +241,7 @@ export function loadClaudeBridgeConfig(): ClaudeBridgeConfig {
const lineBudget = safeParseInt(env["CLAUDE_MEMORY_LINE_BUDGET"], 200);
let memoryFilePath = "";
if (enabled && projectPath) {
// #625: Claude Code stores MEMORY.md at
// Claude Code stores MEMORY.md at
// ~/.claude/projects/<slug>/MEMORY.md
// where <slug> is the project path with `/` and `\` swapped for `-`.
// The leading `-` from an absolute POSIX path is preserved (Claude
Expand Down Expand Up @@ -269,7 +269,7 @@ export function loadTeamConfig(): TeamConfig | null {
return { teamId, userId, mode };
}

// #554: optional AGENT_ID env for multi-agent memory isolation.
// optional AGENT_ID env for multi-agent memory isolation.
// Returns null when unset so memory stays unscoped (legacy behavior).
// Trimmed + length-capped to keep KV writes well-formed.
//
Expand Down
1 change: 0 additions & 1 deletion src/functions/compress-synthetic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ export function buildSyntheticCompression(
};
if (raw.modality) result.modality = raw.modality;
if (raw.imageData) result.imageData = raw.imageData;
// #554: carry the role through synthetic compression too.
if (raw.agentId) result.agentId = raw.agentId;
return result;
}
1 change: 0 additions & 1 deletion src/functions/compress.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,6 @@ export function registerCompressFunction(
...(hasImage ? { modality: data.raw.modality } : {}),
...(imageDescription ? { imageDescription } : {}),
...(data.raw.imageData ? { imageRef: data.raw.imageData } : {}),
// #554: carry the role through LLM compression too.
...(data.raw.agentId ? { agentId: data.raw.agentId } : {}),
};

Expand Down
2 changes: 1 addition & 1 deletion src/functions/export-import.ts
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ export function registerExportImportFunction(sdk: ISdk, kv: StateKV): void {
const strategy = data.strategy || "merge";
const importData = data.exportData;

const supportedVersions = new Set(["0.3.0", "0.4.0", "0.5.0", "0.6.0", "0.6.1", "0.7.0", "0.7.2", "0.7.3", "0.7.4", "0.7.5", "0.7.6", "0.7.7", "0.7.9", "0.8.0", "0.8.1", "0.8.2", "0.8.3", "0.8.4", "0.8.5", "0.8.6", "0.8.7", "0.8.8", "0.8.9", "0.8.10", "0.8.11", "0.8.12", "0.8.13", "0.9.0", "0.9.1", "0.9.2", "0.9.3", "0.9.4", "0.9.5", "0.9.6", "0.9.7", "0.9.8", "0.9.9", "0.9.10", "0.9.11", "0.9.12", "0.9.13", "0.9.14", "0.9.15", "0.9.16", "0.9.17", "0.9.18", "0.9.19", "0.9.20", "0.9.21"]);
const supportedVersions = new Set(["0.3.0", "0.4.0", "0.5.0", "0.6.0", "0.6.1", "0.7.0", "0.7.2", "0.7.3", "0.7.4", "0.7.5", "0.7.6", "0.7.7", "0.7.9", "0.8.0", "0.8.1", "0.8.2", "0.8.3", "0.8.4", "0.8.5", "0.8.6", "0.8.7", "0.8.8", "0.8.9", "0.8.10", "0.8.11", "0.8.12", "0.8.13", "0.9.0", "0.9.1", "0.9.2", "0.9.3", "0.9.4", "0.9.5", "0.9.6", "0.9.7", "0.9.8", "0.9.9", "0.9.10", "0.9.11", "0.9.12", "0.9.13", "0.9.14", "0.9.15", "0.9.16", "0.9.17", "0.9.18", "0.9.19", "0.9.20", "0.9.21", "0.9.22"]);
if (!supportedVersions.has(importData.version)) {
return {
success: false,
Expand Down
19 changes: 5 additions & 14 deletions src/functions/observe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,22 +134,15 @@ export function registerObserveFunction(
}
}

// #554: inherit agentId from the parent session so every
// observation carries the role that wrote it. Pre-existing
// session takes precedence (multi-agent runtime stamped at
// session/start), env AGENT_ID is the fallback for the
// implicit-create path (#638) where session doesn't exist yet.
// We reuse this lookup later for observationCount/firstPrompt.
// Existing session is the source of truth for agentId (even
// undefined). Env AGENT_ID only fires when no session row
// exists yet — otherwise an unscoped session would get
// retroactively scoped by a later AGENT_ID export.
const existingSession = await kv.get<{
agentId?: string;
observationCount?: number;
firstPrompt?: string;
}>(KV.sessions, payload.sessionId);
// Existing session wins absolutely — even if its agentId is
// undefined. env AGENT_ID only fires on the implicit-create
// path where no session row exists yet (#638). Otherwise an
// unscoped session would get retroactively scoped by whatever
// AGENT_ID was set on the server later.
const inheritedAgentId = existingSession
? existingSession.agentId
: getAgentId();
Expand Down Expand Up @@ -241,7 +234,7 @@ export function registerObserveFunction(
typeof payload.cwd === "string" &&
payload.cwd.trim().length > 0
) {
// #638: OpenCode (and any plugin that skips POST /session/start)
// OpenCode (and any plugin that skips POST /session/start)
// can fire observations before the session record exists. Without
// an implicit create, those observations stack up but
// `memory_sessions` never lists them, and summarize bails with
Expand All @@ -262,8 +255,6 @@ export function registerObserveFunction(
updatedAt: ts,
status: "active",
observationCount: 1,
// #554: implicit-create path also stamps agentId so the
// session row matches its child observations.
...(inheritedAgentId ? { agentId: inheritedAgentId } : {}),
...(trimmedPrompt && trimmedPrompt.length > 0
? { firstPrompt: trimmedPrompt }
Expand Down
2 changes: 1 addition & 1 deletion src/functions/remember.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export function registerRememberFunction(sdk: ISdk, kv: StateKV): void {
}
}

// #554: stamp the agent role on the memory so future recall can
// stamp the agent role on the memory so future recall can
// filter by agent. Request body wins (multi-agent runtimes
// explicitly tagging at write time), env AGENT_ID fallback,
// none → memory is unscoped (legacy behavior).
Expand Down
2 changes: 1 addition & 1 deletion src/functions/smart-search.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export function registerSmartSearchFunction(
limit?: number;
project?: string;
includeLessons?: boolean;
// #554: optional per-call agent filter for runtimes routing many
// optional per-call agent filter for runtimes routing many
// roles through one server. "*" opts out of the env-default
// scope and returns hits from every agent.
agentId?: string;
Expand Down
2 changes: 1 addition & 1 deletion src/mcp/tools-registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -941,7 +941,7 @@ export function getAllTools(): McpToolDef[] {
];
}

// #553: default switched from "core" (8 essential tools) to "all"
// default switched from "core" (8 essential tools) to "all"
// (full 51-tool surface). README and plugin manifests have always
// advertised 51 tools "in proxy mode"; the old default left OpenCode /
// Claude Code users seeing 8 with no indication the other 43 existed.
Expand Down
8 changes: 4 additions & 4 deletions src/triggers/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -538,7 +538,7 @@ export function registerApiTriggers(
};
}
const title = typeof body.title === "string" ? body.title.trim() : undefined;
// #554: allow session/start to override AGENT_ID from request body
// allow session/start to override AGENT_ID from request body
// (multi-agent runtimes that route many roles through one server
// process). Falls back to the AGENT_ID env on the server.
const requestAgentId =
Expand Down Expand Up @@ -1082,7 +1082,7 @@ export function registerApiTriggers(
async (req: ApiRequest): Promise<Response> => {
const authErr = checkAuth(req, secret);
if (authErr) return authErr;
// #544: mem::export already supports maxSessions/offset internally,
// mem::export already supports maxSessions/offset internally,
// but the HTTP endpoint hardcoded an empty payload — so /export on a
// real corpus (40 sessions × 34K observations × 8K memories) hit the
// iii engine invocation timeout and `agentmemory status` reported 0.
Expand Down Expand Up @@ -1530,7 +1530,7 @@ export function registerApiTriggers(
if (authErr) return authErr;
const memories = await kv.list<import("../types.js").Memory>(KV.memories);
const latest = req.query_params?.["latest"] === "true";
// #554: agentId filter. Request param wins, env AGENT_ID (when
// agentId filter. Request param wins, env AGENT_ID (when
// scope=isolated) is the fallback. Shared mode keeps the tag but
// does not restrict the list endpoint. Pass agentId=* to opt out
// of the env scope entirely. includeOrphans=true surfaces
Expand All @@ -1556,7 +1556,7 @@ export function registerApiTriggers(
);
}

// #544: viewer + `agentmemory status` were hitting this endpoint to
// viewer + `agentmemory status` were hitting this endpoint to
// count memories. On a real corpus (8K+ memories) the unbounded
// response either timed out at the iii engine boundary ("Invocation
// stopped") or arrived too large for the viewer to render — so the
Expand Down
2 changes: 1 addition & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ export interface ExportPagination {
}

export interface ExportData {
version: "0.3.0" | "0.4.0" | "0.5.0" | "0.6.0" | "0.6.1" | "0.7.0" | "0.7.2" | "0.7.3" | "0.7.4" | "0.7.5" | "0.7.6" | "0.7.7" | "0.7.9" | "0.8.0" | "0.8.1" | "0.8.2" | "0.8.3" | "0.8.4" | "0.8.5" | "0.8.6" | "0.8.7" | "0.8.8" | "0.8.9" | "0.8.10" | "0.8.11" | "0.8.12" | "0.8.13" | "0.9.0" | "0.9.1" | "0.9.2" | "0.9.3" | "0.9.4" | "0.9.5" | "0.9.6" | "0.9.7" | "0.9.8" | "0.9.9" | "0.9.10" | "0.9.11" | "0.9.12" | "0.9.13" | "0.9.14" | "0.9.15" | "0.9.16" | "0.9.17" | "0.9.18" | "0.9.19" | "0.9.20" | "0.9.21";
version: "0.3.0" | "0.4.0" | "0.5.0" | "0.6.0" | "0.6.1" | "0.7.0" | "0.7.2" | "0.7.3" | "0.7.4" | "0.7.5" | "0.7.6" | "0.7.7" | "0.7.9" | "0.8.0" | "0.8.1" | "0.8.2" | "0.8.3" | "0.8.4" | "0.8.5" | "0.8.6" | "0.8.7" | "0.8.8" | "0.8.9" | "0.8.10" | "0.8.11" | "0.8.12" | "0.8.13" | "0.9.0" | "0.9.1" | "0.9.2" | "0.9.3" | "0.9.4" | "0.9.5" | "0.9.6" | "0.9.7" | "0.9.8" | "0.9.9" | "0.9.10" | "0.9.11" | "0.9.12" | "0.9.13" | "0.9.14" | "0.9.15" | "0.9.16" | "0.9.17" | "0.9.18" | "0.9.19" | "0.9.20" | "0.9.21" | "0.9.22";
exportedAt: string;
sessions: Session[];
observations: Record<string, CompressedObservation[]>;
Expand Down
2 changes: 1 addition & 1 deletion src/version.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export const VERSION = "0.9.21";
export const VERSION = "0.9.22";
10 changes: 5 additions & 5 deletions src/viewer/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -1766,7 +1766,7 @@ <h1>agentmemory</h1>
}
lastMX = e.clientX;
lastMY = e.clientY;
// #563: wake the simulation if it parked itself after settling
// wake the simulation if it parked itself after settling
wakeGraphSim();
});
canvas.addEventListener('mousemove', function(e) {
Expand Down Expand Up @@ -1824,7 +1824,7 @@ <h1>agentmemory</h1>
e.preventDefault();
var factor = e.deltaY > 0 ? 0.9 : 1.1;
graphSim.zoom = Math.max(0.1, Math.min(5, graphSim.zoom * factor));
// #563: zoom is visually meaningless if the rAF loop is parked —
// zoom is visually meaningless if the rAF loop is parked —
// wake the simulation so the next frame redraws at the new scale.
wakeGraphSim();
}, { passive: false });
Expand Down Expand Up @@ -1914,7 +1914,7 @@ <h1>agentmemory</h1>
var edges = graphSim.edges;
var nodeCount = nodes.length;
graphSim.tickCount = (graphSim.tickCount || 0) + 1;
// #563: dense graphs (>1000 nodes) used to oscillate forever
// dense graphs (>1000 nodes) used to oscillate forever
// because the per-node force pile-up exceeded what 0.9 damping
// could bleed off each tick. Tick-decay tightens damping over
// time so the layout actually settles; a per-node velocity cap
Expand Down Expand Up @@ -1977,7 +1977,7 @@ <h1>agentmemory</h1>
totalKineticEnergy += n.vx * n.vx + n.vy * n.vy;
});

// #563: park the simulation when the layout is quiet to save CPU.
// park the simulation when the layout is quiet to save CPU.
// Pick up again when a drag/interaction wakes the loop.
var rmsVelocity = nodes.length > 0 ? Math.sqrt(totalKineticEnergy / nodes.length) : 0;
if (rmsVelocity < 0.05 && graphSim.tickCount > 60 && !graphSim.dragNode) {
Expand Down Expand Up @@ -2261,7 +2261,7 @@ <h1>agentmemory</h1>
async function loadMemories() {
var el = document.getElementById('view-memories');
el.innerHTML = '<div class="loading">Loading memories...</div>';
// #544: cap at 2000 so the viewer remains responsive on large
// cap at 2000 so the viewer remains responsive on large
// corpora. Older endpoints returned the full unbounded list which
// hit the iii invocation timeout and the UI fell through to 0.
var result = await apiGet('memories?latest=true&limit=2000');
Expand Down
2 changes: 1 addition & 1 deletion test/agent-id-scope.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ vi.mock("../src/logger.js", () => ({
logger: { info: vi.fn(), warn: vi.fn(), error: vi.fn() },
}));

// #554: AGENT_ID scope for multi-agent memory isolation.
// AGENT_ID scope for multi-agent memory isolation.

describe("loadAgentScope (#554)", () => {
const ORIG = process.env["AGENT_ID"];
Expand Down
2 changes: 1 addition & 1 deletion test/claude-bridge-path.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { homedir } from "node:os";
import { join } from "node:path";
import { loadClaudeBridgeConfig } from "../src/config.js";

// #625: bridge path must match Claude Code's slug convention exactly:
// bridge path must match Claude Code's slug convention exactly:
// ~/.claude/projects/<slug>/MEMORY.md
// where <slug> replaces every / and \ with - and KEEPS any leading -.
// The previous code stripped the leading - and added a /memory/
Expand Down
4 changes: 2 additions & 2 deletions test/cli-connect.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ describe("agentmemory connect — dispatcher", () => {
});

it("ships the supported agent list", () => {
// Bumped to 11 with Qwen Code (#647), Antigravity (#614), Kiro (#618).
// Bumped to 11 after adding Qwen Code + Antigravity + Kiro.
expect(knownAgents().sort()).toEqual(
[
"antigravity",
Expand Down Expand Up @@ -133,7 +133,7 @@ describe("agentmemory connect — claude-code adapter (mock filesystem)", () =>
const config = JSON.parse(readFileSync(join(tmpHome, ".claude.json"), "utf-8"));
const entry = config.mcpServers.agentmemory;
expect(entry.env).toBeDefined();
// #510: env interpolation must carry a default so Claude Code
// env interpolation must carry a default so Claude Code
// doesn't silently drop the server when the user hasn't exported
// AGENTMEMORY_URL / AGENTMEMORY_SECRET. Defaults match the
// documented runtime (localhost:3111, no auth, all tools).
Expand Down
2 changes: 1 addition & 1 deletion test/codex-plugin.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ describe("Codex plugin manifest (developers.openai.com/codex/plugins)", () => {
>;
}>(join(pluginRoot, ".mcp.json"));

// #510: env interpolation must include defaults so Claude Code (and
// env interpolation must include defaults so Claude Code (and
// any other MCP host that fails parse on unset ${VAR}) doesn't drop
// the server silently when the user hasn't exported the var.
expect(mcp.mcpServers.agentmemory?.env?.AGENTMEMORY_URL).toMatch(
Expand Down
13 changes: 6 additions & 7 deletions test/connect-new-agents.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,15 @@ import { mkdtempSync, mkdirSync, rmSync, readFileSync, existsSync } from "node:f
import { tmpdir, platform } from "node:os";
import { join } from "node:path";

// #647 / #614 / #618: connect adapters for Qwen Code, Antigravity, and
// Kiro. Each writes the canonical agentmemory MCP block (npx
// @agentmemory/mcp + env defaults from PR #650) into the agent's
// documented config path.
// Connect adapters for Qwen Code, Antigravity, and Kiro. Each writes
// the canonical MCP block (npx @agentmemory/mcp + env defaults) into
// the agent's documented config path.

function freshHome(): string {
return mkdtempSync(join(tmpdir(), "am-connect-"));
}

describe("connect: Qwen Code (#647)", () => {
describe("connect: Qwen Code", () => {
let home: string;
const ORIG = process.env["HOME"];
beforeEach(() => {
Expand Down Expand Up @@ -50,7 +49,7 @@ describe("connect: Qwen Code (#647)", () => {
});
});

describe("connect: Antigravity (#614)", () => {
describe("connect: Antigravity", () => {
let home: string;
const ORIG = process.env["HOME"];
beforeEach(() => {
Expand Down Expand Up @@ -83,7 +82,7 @@ describe("connect: Antigravity (#614)", () => {
});
});

describe("connect: Kiro (#618)", () => {
describe("connect: Kiro", () => {
let home: string;
const ORIG = process.env["HOME"];
beforeEach(() => {
Expand Down
2 changes: 1 addition & 1 deletion test/export-import.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ describe("Export/Import Functions", () => {
it("export produces valid ExportData structure", async () => {
const result = (await sdk.trigger("mem::export", {})) as ExportData;

expect(result.version).toBe("0.9.21");
expect(result.version).toBe("0.9.22");
expect(result.exportedAt).toBeDefined();
expect(result.sessions.length).toBe(1);
expect(result.sessions[0].id).toBe("ses_1");
Expand Down
2 changes: 1 addition & 1 deletion test/hermes-plugin.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ describe("Hermes plugin manifest", () => {
expect(declaredHooks).toEqual(expectedHermesHooks);
});

it("preloads AGENTMEMORY_URL default at import time (#520)", () => {
it("preloads AGENTMEMORY_URL default at import time", () => {
const source = readFileSync("integrations/hermes/__init__.py", "utf8");
expect(source).toMatch(
/os\.environ\.setdefault\(\s*["']AGENTMEMORY_URL["']\s*,\s*DEFAULT_BASE_URL\s*\)/,
Expand Down
Loading