Same agent Smaller bill. The tools and infrastructure to get more work from your AI. Fewer tokens. Less compute. Lower cost.
TypeScript agent-harnessagent-harness-engineeringai-engineeringai-observabilityamd-gpuclaude-codeclickhousecodexcoding-agentcoding-agentscursorgenaigpu-monitoringllm-observabilityllmopsnvidia-smiobservabilityopen-sourceopenaiopentelemetry
feat(client): add LangGraph memory connector (#1667)
Raúl Mermans6192e3e46af1
diff --git a/docs/latest/openlit/connectors/datasource.mdx b/docs/latest/openlit/connectors/datasource.mdxindex 7feb481a..06feda6f 100644--- a/docs/latest/openlit/connectors/datasource.mdx+++ b/docs/latest/openlit/connectors/datasource.mdx@@ -205,7 +205,7 @@ See the [OpenPlait repository](https://github.com/openlit/openplait) for publish<CardGroup cols={2}><Card title="Memory connectors" href="/latest/openlit/connectors/memory" icon="brain">- Claude, Mem0, and Zep for agent memory.+ Claude, LangGraph, Mem0, and Zep for agent memory.</Card><Card title="Scanner connectors" href="/latest/openlit/connectors/scanner" icon="magnifying-glass">Trustabl scans of GitHub repositories.diff --git a/docs/latest/openlit/connectors/memory.mdx b/docs/latest/openlit/connectors/memory.mdxindex 06a49f95..05659905 100644--- a/docs/latest/openlit/connectors/memory.mdx+++ b/docs/latest/openlit/connectors/memory.mdx@@ -1,7 +1,7 @@---title: 'Memory connectors'sidebarTitle: 'Memory'-description: 'Connect OpenLIT to Claude, Mem0, and Zep memory stores — browse, search, write, copy, and ask Otter about agent memories'+description: 'Connect OpenLIT to Claude, LangGraph, Mem0, and Zep memory stores — browse, search, write, copy, and ask Otter about agent memories'icon: 'brain'---@@ -27,7 +27,7 @@ flowchart LROtter --> Tools[list / search / add / update / delete]```-- **Atomic connectors** — one Mem0 project endpoint, one Zep tenant, one Claude memory store configuration per connector instance.+- **Atomic connectors** — one Mem0 project endpoint, one Zep tenant, one Claude memory store configuration, or one LangGraph server per connector instance.- **Capability-driven UI** — each vendor advertises supported operations (`list`, `search`, `add`, `update`, `delete`, `feedback`). OpenLIT hides actions the vendor does not support.- **Filters** — user, session/run, and agent filters are declared per vendor. Some connectors require a session or user before listing memories.- **Port links** — copying a memory to another connector stores provenance metadata so you can trace copies back to the source.@@ -39,6 +39,7 @@ flowchart LR| **Claude** | `https://api.anthropic.com` | Browse and edit memories in Anthropic Claude memory stores (Managed Agents memory beta) || **Mem0** | `https://api.mem0.ai` | Store and search long-term agent memories scoped by user, run, or agent || **Zep** | `https://api.getzep.com` | Session memory and knowledge-graph facts for agents |+| **LangGraph** | None — enter your server URL | Long-term memories in the Store of a LangGraph Platform deployment or self-hosted LangGraph server |Self-hosted Mem0 or Zep deployments work when you point the connector at a compatible API URL and supply the same authentication style as the hosted service.@@ -49,11 +50,14 @@ Self-hosted Mem0 or Zep deployments work when you point the connector at a compa| **Claude** | Yes | Yes* | Yes | Yes | Yes | Yes | No | Memory store (session) || **Mem0** | Yes | Yes | Yes | Yes | Yes | Yes | Yes | Optional user / run / agent || **Zep** | Yes | Yes | Yes | Yes | No | Yes† | No | User; session required for writes |+| **LangGraph** | Yes | Yes‡ | Yes | Yes | Yes | Yes | No | Namespace (session) for writes, or the template's placeholders |\* Claude has no dedicated search API — OpenLIT filters listed memories locally for search queries.† Zep delete targets graph edges/nodes, not an entire session.+‡ LangGraph search is semantic only when the server has a store index configured. Without one, LangGraph ignores the query and returns items in listing order with no relevance score; OpenLIT does not emulate semantic search.+## Add a memory connector<Steps>@@ -64,10 +68,10 @@ Self-hosted Mem0 or Zep deployments work when you point the connector at a compaGo to **Configuration → Connectors**, open the **Memory** section in the catalog, and choose **Add connector**.</Step><Step title="Pick a vendor">- Select **Claude**, **Mem0**, or **Zep**.+ Select **Claude**, **LangGraph**, **Mem0**, or **Zep**.</Step><Step title="Configure endpoint and credentials">- Set the API URL (defaults work for hosted services), optional SSRF toggles for private networks, and the API key. Mem0 also accepts optional organization and project IDs.+ Set the API URL (defaults work for hosted services), optional SSRF toggles for private networks, and the API key. Mem0 also accepts optional organization and project IDs. LangGraph has no default URL, an optional API key, and an optional namespace template (see [LangGraph namespaces](#langgraph-namespaces)).</Step><Step title="Test and save">Run a health check, then save. Open **Memory** (`/memory`) and select the connector from the dropdown.@@ -114,9 +118,25 @@ Otter passes required filter arguments (user, session, agent) when the vendor ma| **Claude** | API key (`x-api-key`) | Sends the `agent-memory-2026-07-22` beta header for memory store APIs || **Mem0** | Token (`Authorization: Token <apiKey>`) | Works with Mem0 Platform or self-hosted compatible endpoints || **Zep** | API key (`Authorization: Api-Key <apiKey>`) | Works with Zep Cloud or self-hosted compatible endpoints |+| **LangGraph** | None, or API key (`x-api-key`) | Leave the key empty for self-hosted servers without auth; use a LangSmith API key for LangGraph Platform. Bearer tokens and custom auth handlers are not supported |API keys are stored encrypted on the connector (`enc:v1:…`) and decrypted only server-side for outbound requests.+## LangGraph namespaces++LangGraph Store items live in a namespace (an ordered list of labels) under a key. LangGraph gives namespace labels no meaning of their own, so OpenLIT only maps them to user, session, and agent filters when you declare it with a **namespace template**:++| Namespace template | Behaviour |+| --- | --- |+| *(empty)* | Each discovered namespace is a **Namespace or thread** (session) filter, for example `memories.u1`. Writes go to the selected namespace. |+| `memories` | Same, limited to namespaces under `memories`. |+| `memories/{user_id}` | The second label is the user. |+| `memories/{user_id}/{thread_id}/{assistant_id}` | Labels map to user, session (thread), and agent filters. Writes need a value for every placeholder. |++Fixed template segments must match exactly; placeholders are `{user_id}`, `{thread_id}`, and `{assistant_id}`. Labels cannot be empty or contain `.`. Items deeper than the template still match; items that do not fit it are hidden.++Memory content is read from the LangMem shapes `{"kind": ..., "content": {"content": "..."}}` and `{"content": "..."}`, falling back to the JSON of the whole value, including arrays and primitives. The original value is always shown in metadata under `langgraph`. New memories are written as `{"content": "..."}`. Updates change only the field the content was read from and keep every other field. OpenLIT refuses to edit a value that is not an object, or a non-text `content` or `metadata` field, because that would overwrite data. Because LangGraph has no compare-and-swap, an update can overwrite a concurrent change made between OpenLIT's read and write.+## Copy between connectorsUse **Copy** on the Memory page to duplicate memories into another write-capable connector in the same project and environment. OpenLIT:@@ -146,6 +166,9 @@ In [OpenLIT Enterprise](/latest/openlit/enterprise), copying requires the `conne<Card title="Zep SDK" href="https://help.getzep.com/sdk-reference" icon="book">Zep Cloud API and graph memory.</Card>+ <Card title="LangGraph Agent Server" href="https://docs.langchain.com/langsmith/agent-server" icon="book">+ LangGraph server and Store API.+ </Card></CardGroup>## Relateddiff --git a/docs/latest/openlit/connectors/overview.mdx b/docs/latest/openlit/connectors/overview.mdxindex 9dae4933..9886fd83 100644--- a/docs/latest/openlit/connectors/overview.mdx+++ b/docs/latest/openlit/connectors/overview.mdx@@ -24,7 +24,7 @@ Connectors share one registry model across categories. **Data-source connectors*ClickHouse, Tempo, Loki, Prometheus, and Jaeger — read traces, logs, and metrics with per-signal routing.</Card><Card title="Memory connectors" href="/latest/openlit/connectors/memory" icon="brain">- Claude, Mem0, and Zep — browse, search, write, and copy agent memories from the Memory page and Otter.+ Claude, LangGraph, Mem0, and Zep — browse, search, write, and copy agent memories from the Memory page and Otter.</Card><Card title="Scanner connectors" href="/latest/openlit/connectors/scanner" icon="magnifying-glass">Trustabl — scan GitHub repositories for agent SDK, MCP, and policy findings.@@ -58,6 +58,7 @@ flowchart LRbindM --> DS3[Prometheus]mem --> M1[Mem0]mem --> M2[Zep]+ mem --> M3[LangGraph]scan --> S1[Trustabl]```diff --git a/docs/latest/openlit/connectors/scanner.mdx b/docs/latest/openlit/connectors/scanner.mdxindex 7ffcb26b..316fe954 100644--- a/docs/latest/openlit/connectors/scanner.mdx+++ b/docs/latest/openlit/connectors/scanner.mdx@@ -123,7 +123,7 @@ Authenticate with an OpenLIT API key and send organisation, project, and environTempo, Loki, Prometheus, Jaeger, and ClickHouse.</Card><Card title="Memory connectors" href="/latest/openlit/connectors/memory" icon="brain">- Claude, Mem0, and Zep for agent memory.+ Claude, LangGraph, Mem0, and Zep for agent memory.</Card><Card title="Coding agents" href="/latest/openlit/coding-agents/overview" icon="code">How coding-agent traces expose `vcs.repository.url.full`.diff --git a/src/client/public/images/connectors/langgraph.svg b/src/client/public/images/connectors/langgraph.svgnew file mode 100644index 00000000..f6953771--- /dev/null+++ b/src/client/public/images/connectors/langgraph.svg@@ -0,0 +1 @@+<svg fill="#7FC8FF" role="img" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><title>LangGraph</title><path d="M5 19H10A5 5 0 115 14ZM19 14A5 5 0 1114 19H19ZM10 5A5 5 0 105 10V5ZM19 5V10A5 5 0 1014 5Z"/></svg>\ No newline at end of filediff --git a/src/client/src/__tests__/lib/platform/connectors/coverage.test.ts b/src/client/src/__tests__/lib/platform/connectors/coverage.test.tsindex 9da63cc4..3eab51a2 100644--- a/src/client/src/__tests__/lib/platform/connectors/coverage.test.ts+++ b/src/client/src/__tests__/lib/platform/connectors/coverage.test.ts@@ -37,11 +37,13 @@ describe("connector coverage", () => {it("exposes memory connectors through the adapter and connector registries", () => {ensureMemoryAdaptersRegistered();expect(hasMemoryAdapterFactory("claude")).toBe(true);+ expect(hasMemoryAdapterFactory("langgraph")).toBe(true);expect(hasMemoryAdapterFactory("mem0")).toBe(true);expect(hasMemoryAdapterFactory("memcode")).toBe(true);expect(hasMemoryAdapterFactory("zep")).toBe(true);expect(listConnectorTypes("memory").map((item) => item.type).sort()).toEqual(["claude",+ "langgraph","mem0","memcode","zep",@@ -50,6 +52,7 @@ describe("connector coverage", () => {it("maps memory vendors to local brand assets", () => {expect(connectorIconPath("claude")).toBe("/images/connectors/claude.svg");+ expect(connectorIconPath("langgraph")).toBe("/images/connectors/langgraph.svg");expect(connectorIconPath("mem0")).toBe("/images/connectors/mem0.svg");expect(connectorIconPath("memcode")).toBe("/images/connectors/memcode.png");expect(connectorIconPath("zep")).toBe("/images/connectors/zep.svg");diff --git a/src/client/src/__tests__/lib/platform/connectors/memory-adapters.test.ts b/src/client/src/__tests__/lib/platform/connectors/memory-adapters.test.tsindex a1993fcd..736399ca 100644--- a/src/client/src/__tests__/lib/platform/connectors/memory-adapters.test.ts+++ b/src/client/src/__tests__/lib/platform/connectors/memory-adapters.test.ts@@ -28,9 +28,14 @@ import { ClaudeAdapter, claudeAdapterFactory } from "@/lib/platform/connectors/mimport { Mem0Adapter, mem0AdapterFactory } from "@/lib/platform/connectors/memory/mem0/adapter";import { MemcodeAdapter, memcodeAdapterFactory } from "@/lib/platform/connectors/memory/memcode/adapter";import { ZepAdapter, zepAdapterFactory } from "@/lib/platform/connectors/memory/zep/adapter";+import {+ LangGraphAdapter,+ langgraphAdapterFactory,+} from "@/lib/platform/connectors/memory/langgraph/adapter";import { SourceResponseError } from "@/lib/platform/connectors/datasource/http/safe-fetch";import { resolveSourceSecret } from "@/lib/platform/connectors/datasource/http/secret";import type { MemorySourceDescriptor } from "@/lib/platform/connectors/memory/types";+import { UnsupportedMemoryCapabilityError } from "@/lib/platform/connectors/memory/types";function defaultUrl(type: "claude" | "mem0" | "memcode" | "zep"): string {if (type === "claude") return "https://api.anthropic.com";@@ -3031,3 +3036,590 @@ describe("Claude adapter", () => {);});});++describe("LangGraph adapter", () => {+ const BASE = "https://langgraph.example.com";++ function lgDescriptor(settings: Record<string, unknown> = {}): MemorySourceDescriptor {+ return {+ type: "langgraph",+ id: "memory:langgraph",+ settings: { url: BASE, ...settings },+ secretRef: "vault-1",+ name: "langgraph",+ projectId: "proj-1",+ };+ }++ function call(index: number) {+ const [url, options] = mockSafeFetch.mock.calls[index];+ return {+ url: String(url),+ method: options.method,+ headers: options.headers,+ body: options.body === undefined ? undefined : JSON.parse(options.body),+ };+ }++ function item(namespace: string[], key: string, value: unknown, extra: Record<string, unknown> = {}) {+ return {+ namespace,+ key,+ value,+ created_at: "2026-09-01T00:00:00Z",+ updated_at: "2026-09-02T00:00:00Z",+ ...extra,+ };+ }++ it("describes a self-hosted friendly config schema and capabilities", () => {+ const described = langgraphAdapterFactory.describe();+ expect(described.type).toBe("langgraph");+ expect(described.capabilities).toEqual({+ add: true,+ search: true,+ get: true,+ list: true,+ update: true,+ delete: true,+ feedback: false,+ });+ expect(described.configFields.map((field) => field.key)).toEqual([+ "url",+ "allowHttp",+ "allowPrivateNetwork",+ "apiKey",+ "namespaceTemplate",+ ]);+ expect(described.configFields[0].defaultValue).toBeUndefined();+ expect(described.filterFields?.map((field) => field.key)).toEqual([+ "userId",+ "sessionId",+ "agentId",+ ]);+ expect(described.filterFields?.every((field) => !field.required)).toBe(true);+ expect(described.authStyle).toBe("api-key");+ });++ it("health-checks an authenticated store route and sends x-api-key", async () => {+ mockSafeFetch.mockResolvedValue({ namespaces: [] });+ const adapter = new LangGraphAdapter(lgDescriptor());+ await expect(adapter.healthCheck()).resolves.toEqual(+ expect.objectContaining({ ok: true })+ );+ const request = call(0);+ expect(request.url).toBe(`${BASE}/store/namespaces`);+ expect(request.method).toBe("POST");+ expect(request.body).toEqual({ limit: 1 });+ expect(request.headers["x-api-key"]).toBe("secret-key");+ expect(request.headers.Authorization).toBeUndefined();+ });++ it("sends no auth header when the connector has no API key", async () => {+ (resolveSourceSecret as jest.Mock).mockResolvedValueOnce({ raw: "", credentials: {} });+ mockSafeFetch.mockResolvedValue({ namespaces: [] });+ const adapter = new LangGraphAdapter({ ...lgDescriptor(), secretRef: null });+ await adapter.healthCheck();+ expect(call(0).headers["x-api-key"]).toBeUndefined();+ });++ it("reports auth failures, missing store routes, and other errors from the health check", async () => {+ const adapter = new LangGraphAdapter(lgDescriptor());+ mockSafeFetch.mockRejectedValueOnce(new SourceResponseError(401, "Data source responded 401"));+ await expect(adapter.healthCheck()).resolves.toEqual(+ expect.objectContaining({ ok: false, message: expect.stringMatching(/rejected the credentials/) })+ );+ mockSafeFetch.mockRejectedValueOnce(new SourceResponseError(403, "Data source responded 403"));+ await expect(adapter.healthCheck()).resolves.toEqual(+ expect.objectContaining({ ok: false, message: expect.stringMatching(/rejected the credentials/) })+ );+ mockSafeFetch.mockRejectedValueOnce(new SourceResponseError(404, "Data source responded 404"));+ await expect(adapter.healthCheck()).resolves.toEqual(+ expect.objectContaining({ ok: false, message: expect.stringMatching(/Store API was not found/) })+ );+ mockSafeFetch.mockRejectedValueOnce(new Error("connect ECONNREFUSED"));+ await expect(adapter.healthCheck()).resolves.toEqual(+ expect.objectContaining({ ok: false, message: "connect ECONNREFUSED" })+ );+ });++ it("requires a server URL and a valid namespace template", async () => {+ const noUrl = new LangGraphAdapter(lgDescriptor({ url: "" }));+ await expect(noUrl.healthCheck()).resolves.toEqual(+ expect.objectContaining({ ok: false, message: expect.stringMatching(/server URL is required/) })+ );+ await expect(noUrl.list({})).rejects.toThrow(/server URL is required/);+ for (const namespaceTemplate of ["memories/{org_id}", "a.b/{user_id}", "{user_id}/{user_id}", "x{user_id}"]) {+ const adapter = new LangGraphAdapter(lgDescriptor({ namespaceTemplate }));+ await expect(adapter.healthCheck()).resolves.toEqual(+ expect.objectContaining({ ok: false, message: expect.stringMatching(/template is invalid/) })+ );+ }+ expect(mockSafeFetch).not.toHaveBeenCalled();+ });++ it("gets an item with a dot-joined namespace and URI-encoded key", async () => {+ mockSafeFetch.mockResolvedValue(item(["memories", "u:1"], "k:1", { content: "likes tea" }));+ const adapter = new LangGraphAdapter(lgDescriptor());+ const record = await adapter.get("memories.u:1:k%3A1");+ const request = call(0);+ expect(request.method).toBe("GET");+ expect(request.url).toBe(`${BASE}/store/items?namespace=memories.u%3A1&key=k%3A1`);+ expect(record).toMatchObject({+ id: "memories.u:1:k%3A1",+ content: "likes tea",+ sessionId: "memories.u:1",+ createdAt: "2026-09-01T00:00:00Z",+ updatedAt: "2026-09-02T00:00:00Z",+ });+ });++ it("returns null for a missing item (200 null) and for malformed ids", async () => {+ mockSafeFetch.mockResolvedValue(null);+ const adapter = new LangGraphAdapter(lgDescriptor());+ await expect(adapter.get("memories.u1:missing")).resolves.toBeNull();+ mockSafeFetch.mockClear();+ for (const id of ["no-separator", ":key", "a..b:key", "memories.u1:", "memories.u1:%E0%A4%A"]) {+ await expect(adapter.get(id)).resolves.toBeNull();+ }+ expect(mockSafeFetch).not.toHaveBeenCalled();+ await expect(adapter.update("bad", { content: "x" })).rejects.toThrow(/could not be found/);+ await expect(adapter.delete("bad")).rejects.toThrow(/could not be found/);+ });++ it("adds a plain-text memory as {content} and handles the 204 response", async () => {+ mockSafeFetch.mockResolvedValue(undefined);+ const adapter = new LangGraphAdapter(lgDescriptor());+ const [record] = await adapter.add({ content: " likes tea ", sessionId: "memories.u1", userId: "ignored" });+ const request = call(0);+ expect(request.method).toBe("PUT");+ expect(request.url).toBe(`${BASE}/store/items`);+ expect(request.body.namespace).toEqual(["memories", "u1"]);+ expect(typeof request.body.key).toBe("string");+ expect(request.body.value).toEqual({ content: "likes tea" });+ expect(request.body).not.toHaveProperty("index");+ expect(record).toMatchObject({+ id: `memories.u1:${encodeURIComponent(request.body.key)}`,+ content: "likes tea",+ sessionId: "memories.u1",+ });+ expect(record.userId).toBeUndefined();+ });++ it("writes caller metadata but never OpenLIT's langgraph projection", async () => {+ mockSafeFetch.mockResolvedValue(undefined);+ const adapter = new LangGraphAdapter(lgDescriptor());+ await adapter.add({+ messages: [{ role: "user", content: "one" }, { role: "assistant", content: "two" }],+ sessionId: "memories.u1",+ metadata: { openlit: { port: { sourceMemoryId: "m1" } }, langgraph: { value: {} } },+ });+ expect(call(0).body.value).toEqual({+ content: "one\ntwo",+ metadata: { openlit: { port: { sourceMemoryId: "m1" } } },+ });+ });++ it("rejects writes without content, namespace, or with invalid labels", async () => {+ const adapter = new LangGraphAdapter(lgDescriptor({ namespaceTemplate: "memories" }));+ await expect(adapter.add({ sessionId: "memories.u1" })).rejects.toThrow(/content or messages/);+ await expect(adapter.add({ content: "x" })).rejects.toThrow(/session id is required/);+ await expect(adapter.add({ content: "x", sessionId: "memories..u1" })).rejects.toThrow(/namespace labels/);+ await expect(adapter.add({ content: "x", sessionId: "other.u1" })).rejects.toThrow(/namespace labels/);+ expect(mockSafeFetch).not.toHaveBeenCalled();+ });++ it("deletes an item with a JSON body", async () => {+ mockSafeFetch.mockResolvedValue(undefined);+ const adapter = new LangGraphAdapter(lgDescriptor());+ await expect(adapter.delete("memories.u1:k1")).resolves.toBeUndefined();+ const request = call(0);+ expect(request.method).toBe("DELETE");+ expect(request.url).toBe(`${BASE}/store/items`);+ expect(request.body).toEqual({ namespace: ["memories", "u1"], key: "k1" });+ });++ it("lists all namespaces and normalizes LangMem and arbitrary values", async () => {+ const nested = { kind: "Memory", content: { content: "prefers dark mode", other: true } };+ const arbitrary = { foo: 123 };+ mockSafeFetch.mockResolvedValue({+ items: [+ item(["memories", "u1"], "a", { content: "likes tea", metadata: { source: "chat" } }, { score: null }),+ item(["memories", "u1"], "b", nested),+ item(["profiles"], "c", arbitrary),+ ],+ });+ const adapter = new LangGraphAdapter(lgDescriptor());+ const records = await adapter.list({});+ expect(call(0).body).toEqual({ namespace_prefix: [], limit: 25, offset: 0 });+ expect(records.map((record) => record.content)).toEqual([+ "likes tea",+ "prefers dark mode",+ JSON.stringify(arbitrary),+ ]);+ expect(records[0].score).toBeUndefined();+ expect(records[0].metadata).toEqual({+ source: "chat",+ langgraph: {+ namespace: ["memories", "u1"],+ key: "a",+ value: { content: "likes tea", metadata: { source: "chat" } },+ },+ });+ expect(records[1].metadata?.langgraph).toEqual({ namespace: ["memories", "u1"], key: "b", value: nested });+ expect(records.map((record) => record.sessionId)).toEqual(["memories.u1", "memories.u1", "profiles"]);+ expect(records.every((record) => !record.userId && !record.agentId)).toBe(true);+ });++ it("uses the session filter as an exact namespace without a template", async () => {+ mockSafeFetch.mockResolvedValue({+ items: [+ item(["memories", "u1"], "a", { content: "kept" }),+ item(["memories", "u1", "profile"], "b", { content: "child namespace" }),+ ],+ });+ const adapter = new LangGraphAdapter(lgDescriptor());+ const records = await adapter.list({ sessionId: "memories.u1", limit: 5 });+ expect(call(0).body).toEqual({ namespace_prefix: ["memories", "u1"], limit: 5, offset: 0 });+ expect(records.map((record) => record.content)).toEqual(["kept"]);+ });++ it("matches nothing for user or agent filters when no template declares them", async () => {+ const adapter = new LangGraphAdapter(lgDescriptor());+ await expect(adapter.list({ userId: "u1" })).resolves.toEqual([]);+ await expect(adapter.search({ query: "tea", agentId: "a1" })).resolves.toEqual([]);+ const templated = new LangGraphAdapter(lgDescriptor({ namespaceTemplate: "memories/{user_id}" }));+ await expect(templated.list({ sessionId: "t1" })).resolves.toEqual([]);+ expect(mockSafeFetch).not.toHaveBeenCalled();+ });++ it("passes search queries through and keeps numeric scores", async () => {+ mockSafeFetch.mockResolvedValue({+ items: [item(["memories", "u1"], "a", { content: "likes tea" }, { score: 0.82 })],+ });+ const adapter = new LangGraphAdapter(lgDescriptor());+ const records = await adapter.search({ query: " tea ", limit: 3 });+ expect(call(0).url).toBe(`${BASE}/store/items/search`);+ expect(call(0).body).toEqual({ namespace_prefix: [], limit: 3, offset: 0, query: "tea" });+ expect(records[0].score).toBe(0.82);+ await expect(adapter.search({ query: " " })).rejects.toThrow(/search query is required/);+ });++ it("maps {user_id} from a template and drops items outside it", async () => {+ mockSafeFetch.mockResolvedValue({+ items: [+ item(["memories", "u1"], "a", { content: "fits" }),+ item(["memories", "u1", "profile"], "b", { content: "deeper namespace still fits" }),+ ],+ });+ const adapter = new LangGraphAdapter(lgDescriptor({ namespaceTemplate: "/memories/{user_id}/" }));+ const records = await adapter.list({ userId: "u1" });+ expect(call(0).body.namespace_prefix).toEqual(["memories", "u1"]);+ expect(records.map((record) => [record.content, record.userId, record.sessionId])).toEqual([+ ["fits", "u1", undefined],+ ["deeper namespace still fits", "u1", undefined],+ ]);++ mockSafeFetch.mockClear();+ mockSafeFetch.mockResolvedValue({+ items: [item(["memories"], "c", { content: "too shallow" }), item(["other", "u2"], "d", { content: "x" })],+ });+ await expect(adapter.list({})).resolves.toEqual([]);+ expect(call(0).body.namespace_prefix).toEqual(["memories"]);+ });++ it("maps {thread_id} and {assistant_id} from a template", async () => {+ mockSafeFetch.mockResolvedValue({+ items: [item(["memories", "u1", "t1", "a1"], "k", { content: "fact" })],+ });+ const adapter = new LangGraphAdapter(+ lgDescriptor({ namespaceTemplate: "memories/{user_id}/{thread_id}/{assistant_id}" })+ );+ const [record] = await adapter.list({ userId: "u1", sessionId: "t1", agentId: "a1" });+ expect(call(0).body.namespace_prefix).toEqual(["memories", "u1", "t1", "a1"]);+ expect(record).toMatchObject({ userId: "u1", sessionId: "t1", agentId: "a1", id: "memories.u1.t1.a1:k" });+ });++ it("writes into the template namespace and names missing placeholders", async () => {+ mockSafeFetch.mockResolvedValue(undefined);+ const adapter = new LangGraphAdapter(+ lgDescriptor({ namespaceTemplate: "memories/{user_id}/{thread_id}" })+ );+ const [record] = await adapter.add({ content: "x", userId: "u1", sessionId: "t1" });+ expect(call(0).body.namespace).toEqual(["memories", "u1", "t1"]);+ expect(record).toMatchObject({ userId: "u1", sessionId: "t1" });+ await expect(adapter.add({ content: "x", userId: "u1" })).rejects.toThrow(+ "This connector's namespace template needs thread_id to write a memory."+ );+ await expect(adapter.add({ content: "x" })).rejects.toThrow(/needs user_id, thread_id/);+ await expect(adapter.add({ content: "x", userId: "u.1", sessionId: "t1" })).rejects.toThrow(/namespace labels/);+ });++ it("resolves candidate namespaces when an earlier placeholder is missing", async () => {+ mockSafeFetch+ .mockResolvedValueOnce({+ namespaces: [+ ["memories", "u1", "t1"],+ ["memories", "u2", "t1"],+ ["memories", "u3", "t9"],+ ["memories", "u4"],+ ],+ })+ .mockResolvedValueOnce({+ items: [item(["memories", "u1", "t1"], "a", { content: "older" }, { updated_at: "2026-09-01T00:00:00Z" })],+ })+ .mockResolvedValueOnce({+ items: [item(["memories", "u2", "t1"], "b", { content: "newer" }, { updated_at: "2026-09-03T00:00:00Z" })],+ });+ const adapter = new LangGraphAdapter(+ lgDescriptor({ namespaceTemplate: "memories/{user_id}/{thread_id}" })+ );+ const records = await adapter.list({ sessionId: "t1" });+ expect(call(0).url).toBe(`${BASE}/store/namespaces`);+ expect(call(0).body).toEqual({ prefix: ["memories"], max_depth: 3, limit: 100, offset: 0 });+ expect(call(1).body.namespace_prefix).toEqual(["memories", "u1", "t1"]);+ expect(call(2).body.namespace_prefix).toEqual(["memories", "u2", "t1"]);+ expect(mockSafeFetch).toHaveBeenCalledTimes(3);+ expect(records.map((record) => [record.content, record.userId])).toEqual([+ ["newer", "u2"],+ ["older", "u1"],+ ]);+ });++ it("bounds namespace discovery pages and candidate searches", async () => {+ const page = Array.from({ length: 100 }, (_, index) => ["memories", `u${index}`, "t1"]);+ mockSafeFetch.mockImplementation((url: string) =>+ Promise.resolve(String(url).endsWith("/store/namespaces") ? { namespaces: page } : { items: [] })+ );+ const adapter = new LangGraphAdapter(+ lgDescriptor({ namespaceTemplate: "memories/{user_id}/{thread_id}" })+ );+ await adapter.list({ sessionId: "t1" });+ const urls = mockSafeFetch.mock.calls.map(([url]) => String(url));+ expect(urls.filter((url) => url.endsWith("/store/namespaces"))).toHaveLength(5);+ expect(urls.filter((url) => url.endsWith("/store/items/search"))).toHaveLength(10);+ });++ it("discovers namespaces as session filters without a template", async () => {+ mockSafeFetch.mockResolvedValue([["memories", "u2"], ["memories", "u1"], ["bad.label"]]);+ const adapter = new LangGraphAdapter(lgDescriptor());+ const filters = await adapter.listFilters();+ expect(call(0).body).toEqual({ limit: 100, offset: 0 });+ expect(filters).toEqual({+ users: [],+ sessions: [+ { id: "memories.u1", label: "memories.u1" },+ { id: "memories.u2", label: "memories.u2" },+ ],+ agents: [],+ });+ });++ it("discovers template users, threads, and assistants", async () => {+ mockSafeFetch.mockResolvedValue({+ namespaces: [+ ["memories", "u1", "t1", "a1"],+ ["memories", "u1", "t2", "a1"],+ ["other", "x", "y", "z"],+ ],+ });+ const adapter = new LangGraphAdapter(+ lgDescriptor({ namespaceTemplate: "memories/{user_id}/{thread_id}/{assistant_id}" })+ );+ const filters = await adapter.listFilters();+ expect(call(0).body).toEqual({ prefix: ["memories"], max_depth: 4, limit: 100, offset: 0 });+ expect(filters.users).toEqual([{ id: "u1", label: "u1" }]);+ expect(filters.sessions).toEqual([+ { id: "t1", label: "t1", userId: "u1" },+ { id: "t2", label: "t2", userId: "u1" },+ ]);+ expect(filters.agents).toEqual([{ id: "a1", label: "a1" }]);+ });++ it("returns empty filters when namespace discovery fails", async () => {+ mockSafeFetch.mockRejectedValue(new Error("down"));+ const adapter = new LangGraphAdapter(lgDescriptor());+ await expect(adapter.listFilters()).resolves.toEqual({ users: [], sessions: [], agents: [] });+ });++ describe("update", () => {+ async function runUpdate(existing: unknown, input: { content: string; metadata?: Record<string, unknown> }) {+ mockSafeFetch+ .mockResolvedValueOnce(item(["memories", "u1"], "k1", existing))+ .mockResolvedValueOnce(undefined);+ const adapter = new LangGraphAdapter(lgDescriptor());+ const record = await adapter.update("memories.u1:k1", input);+ expect(call(0).method).toBe("GET");+ const put = call(1);+ expect(put.method).toBe("PUT");+ expect(put.body.namespace).toEqual(["memories", "u1"]);+ expect(put.body.key).toBe("k1");+ return { value: put.body.value, record };+ }++ it("replaces top-level content and keeps unrelated fields", async () => {+ const { value, record } = await runUpdate({ content: "old", foo: 123 }, { content: "new" });+ expect(value).toEqual({ content: "new", foo: 123 });+ expect(record).toMatchObject({ id: "memories.u1:k1", content: "new" });+ });++ it("replaces nested LangMem content and keeps kind and sibling fields", async () => {+ const { value } = await runUpdate(+ { kind: "Memory", content: { content: "old", other: true } },+ { content: "new" }+ );+ expect(value).toEqual({ kind: "Memory", content: { content: "new", other: true } });+ });++ it("adds top-level content to a JSON-fallback value without deleting data", async () => {+ const { value, record } = await runUpdate({ foo: 123 }, { content: "new" });+ expect(value).toEqual({ foo: 123, content: "new" });+ expect(record.content).toBe("new");+ });++ it("merges metadata into an existing metadata object", async () => {+ const { value } = await runUpdate(+ { content: "old", metadata: { a: 1 } },+ { content: "new", metadata: { b: 2, langgraph: { value: {} } } }+ );+ expect(value).toEqual({ content: "new", metadata: { a: 1, b: 2 } });+ });++ it("refuses updates that would overwrite a non-text content or metadata field", async () => {+ const adapter = new LangGraphAdapter(lgDescriptor());+ mockSafeFetch.mockResolvedValueOnce(item(["memories", "u1"], "k1", { content: { text: "old" } }));+ await expect(adapter.update("memories.u1:k1", { content: "new" })).rejects.toThrow(/cannot edit/);+ mockSafeFetch.mockResolvedValueOnce(item(["memories", "u1"], "k1", { content: "old", metadata: "note" }));+ await expect(+ adapter.update("memories.u1:k1", { content: "new", metadata: { a: 1 } })+ ).rejects.toThrow(/cannot edit/);+ expect(mockSafeFetch).toHaveBeenCalledTimes(2);+ expect(mockSafeFetch.mock.calls.every(([, options]) => options.method === undefined || options.method === "GET")).toBe(true);+ });++ it("reports a missing item without writing", async () => {+ mockSafeFetch.mockResolvedValueOnce(null);+ const adapter = new LangGraphAdapter(lgDescriptor());+ await expect(adapter.update("memories.u1:k1", { content: "new" })).rejects.toThrow(/could not be found/);+ expect(mockSafeFetch).toHaveBeenCalledTimes(1);+ });+ });++ it("keeps arbitrary object values in metadata and uses the JSON fallback for content", async () => {+ const value = { profile: { tags: ["a", "b"] }, count: 2, active: true };+ mockSafeFetch.mockResolvedValue(item(["profiles", "u1"], "k1", value));+ const adapter = new LangGraphAdapter(lgDescriptor());+ const record = await adapter.get("profiles.u1:k1");+ expect(record?.content).toBe(JSON.stringify(value));+ expect(record?.metadata).toEqual({+ langgraph: { namespace: ["profiles", "u1"], key: "k1", value },+ });+ });++ it("keeps array and primitive Store values instead of coercing them to an empty object", async () => {+ const values = [["tea", "coffee"], "likes tea", 3, false, null];+ mockSafeFetch.mockResolvedValue({+ items: values.map((value, index) => item(["memories", "u1"], `k${index}`, value)),+ });+ const adapter = new LangGraphAdapter(lgDescriptor());+ const records = await adapter.list({});+ expect(records.map((record) => record.content)).toEqual(values.map((value) => JSON.stringify(value)));+ expect(+ records.map((record) => (record.metadata?.langgraph as { value: unknown }).value)+ ).toEqual(values);++ mockSafeFetch.mockClear();+ mockSafeFetch.mockResolvedValue(item(["profiles", "u1"], "k1", "raw note"));+ const record = await adapter.get("profiles.u1:k1");+ expect(record?.content).toBe(JSON.stringify("raw note"));+ expect(record?.metadata).toEqual({+ langgraph: { namespace: ["profiles", "u1"], key: "k1", value: "raw note" },+ });+ });++ it("refuses to update a non-object Store value", async () => {+ const adapter = new LangGraphAdapter(lgDescriptor());+ mockSafeFetch.mockResolvedValueOnce(item(["memories", "u1"], "k1", ["tea"]));+ await expect(adapter.update("memories.u1:k1", { content: "new" })).rejects.toThrow(/cannot edit/);+ expect(mockSafeFetch).toHaveBeenCalledTimes(1);+ expect(call(0).method).toBe("GET");+ });++ describe("namespace scope for direct ids", () => {+ it("does not get items outside a fixed namespace prefix", async () => {+ const adapter = new LangGraphAdapter(lgDescriptor({ namespaceTemplate: "memories" }));+ await expect(adapter.get("other.u1:k1")).resolves.toBeNull();+ await expect(adapter.get("memoriesx.u1:k1")).resolves.toBeNull();+ expect(mockSafeFetch).not.toHaveBeenCalled();++ mockSafeFetch.mockResolvedValue(item(["memories", "u1"], "k1", { content: "in scope" }));+ await expect(adapter.get("memories.u1:k1")).resolves.toMatchObject({ content: "in scope" });+ expect(call(0).url).toBe(`${BASE}/store/items?namespace=memories.u1&key=k1`);+ });++ it("does not get items outside a placeholder template", async () => {+ const adapter = new LangGraphAdapter(+ lgDescriptor({ namespaceTemplate: "memories/{user_id}/{thread_id}" })+ );+ for (const id of ["other.u1.t1:k1", "memories.u1:k1", "memories:k1"]) {+ await expect(adapter.get(id)).resolves.toBeNull();+ }+ expect(mockSafeFetch).not.toHaveBeenCalled();++ mockSafeFetch.mockResolvedValue(item(["memories", "u1", "t1"], "k1", { content: "in scope" }));+ await expect(adapter.get("memories.u1.t1:k1")).resolves.toMatchObject({+ content: "in scope",+ userId: "u1",+ sessionId: "t1",+ });+ });++ it("does not update or delete out-of-scope items and sends no request", async () => {+ for (const namespaceTemplate of ["memories", "memories/{user_id}"]) {+ const adapter = new LangGraphAdapter(lgDescriptor({ namespaceTemplate }));+ await expect(adapter.update("other.u1:k1", { content: "new" })).rejects.toThrow(+ /could not be found/+ );+ await expect(adapter.delete("other.u1:k1")).rejects.toThrow(/could not be found/);+ }+ expect(mockSafeFetch).not.toHaveBeenCalled();+ });++ it("still updates and deletes in-scope items", async () => {+ const adapter = new LangGraphAdapter(lgDescriptor({ namespaceTemplate: "memories/{user_id}" }));+ mockSafeFetch+ .mockResolvedValueOnce(item(["memories", "u1"], "k1", { content: "old", foo: 1 }))+ .mockResolvedValueOnce(undefined)+ .mockResolvedValueOnce(undefined);+ await expect(adapter.update("memories.u1:k1", { content: "new" })).resolves.toMatchObject({+ content: "new",+ userId: "u1",+ });+ expect(call(1).body).toEqual({+ namespace: ["memories", "u1"],+ key: "k1",+ value: { content: "new", foo: 1 },+ });+ await expect(adapter.delete("memories.u1:k1")).resolves.toBeUndefined();+ expect(call(2)).toMatchObject({+ method: "DELETE",+ body: { namespace: ["memories", "u1"], key: "k1" },+ });+ });++ it("allows any valid namespace when no template is configured", async () => {+ mockSafeFetch.mockResolvedValue(undefined);+ const adapter = new LangGraphAdapter(lgDescriptor());+ await expect(adapter.delete("anything.at.all:k1")).resolves.toBeUndefined();+ expect(call(0).body).toEqual({ namespace: ["anything", "at", "all"], key: "k1" });+ });+ });++ it("does not support feedback", async () => {+ const adapter = new LangGraphAdapter(lgDescriptor());+ expect(adapter.capabilities().feedback).toBe(false);+ await expect(adapter.feedback("memories.u1:k1", { rating: "positive" })).rejects.toBeInstanceOf(+ UnsupportedMemoryCapabilityError+ );+ });+});diff --git a/src/client/src/__tests__/lib/platform/connectors/memory-bootstrap.test.ts b/src/client/src/__tests__/lib/platform/connectors/memory-bootstrap.test.tsindex a1a46210..5de13d03 100644--- a/src/client/src/__tests__/lib/platform/connectors/memory-bootstrap.test.ts+++ b/src/client/src/__tests__/lib/platform/connectors/memory-bootstrap.test.ts@@ -24,15 +24,17 @@ beforeEach(() => {});describe("memory connector bootstrap", () => {- it("registers Claude, Mem0, MemCode, and Zep exactly once", () => {+ it("registers Claude, LangGraph, Mem0, MemCode, and Zep exactly once", () => {ensureMemoryAdaptersRegistered();ensureMemoryAdaptersRegistered();expect(hasMemoryAdapterFactory("claude")).toBe(true);+ expect(hasMemoryAdapterFactory("langgraph")).toBe(true);expect(hasMemoryAdapterFactory("mem0")).toBe(true);expect(hasMemoryAdapterFactory("memcode")).toBe(true);expect(hasMemoryAdapterFactory("zep")).toBe(true);expect(listMemoryTypeDescriptors().map((item) => item.type).sort()).toEqual(["claude",+ "langgraph","mem0","memcode","zep",@@ -62,6 +64,7 @@ describe("memory connector bootstrap", () => {ensureMemoryAdaptersRegistered();expect(listConnectorTypes("memory").map((item) => item.type).sort()).toEqual(["claude",+ "langgraph","mem0","memcode","zep",diff --git a/src/client/src/constants/messages/en.ts b/src/client/src/constants/messages/en.tsindex 65a3c0fc..b540424a 100644--- a/src/client/src/constants/messages/en.ts+++ b/src/client/src/constants/messages/en.ts@@ -2971,6 +2971,30 @@ export const MEMORY_CONNECTOR_AUTH_HELP_MEMCODE ="Use a MemCode API key from memory.memcode.in. Calls send Authorization: Bearer.";export const MEMORY_CONNECTOR_AUTH_HELP_ZEP ="Use a Zep Cloud API key. Self-hosted Zep can use a custom endpoint with the same Api-Key authentication.";+export const MEMORY_CONNECTOR_LANGGRAPH_DESCRIPTION =+ "Browse and edit long-term memories in a LangGraph Store.";+export const MEMORY_CONNECTOR_AUTH_HELP_LANGGRAPH =+ "Leave the API key empty for self-hosted LangGraph servers without authentication. For LangGraph Platform deployments, use a LangSmith API key; it is sent as x-api-key. Bearer tokens and custom auth handlers are not supported.";+export const MEMORY_CONNECTOR_LANGGRAPH_API_KEY_HELP =+ "Optional. Sent as x-api-key when set.";+export const MEMORY_CONNECTOR_FIELD_NAMESPACE_TEMPLATE = "Namespace template";+export const MEMORY_CONNECTOR_FIELD_NAMESPACE_TEMPLATE_HELP =+ "Optional. Segments separated by /, for example memories/{user_id}/{thread_id}. {user_id}, {thread_id}, and {assistant_id} map to the user, session, and agent filters; other segments must match exactly. Without placeholders, each namespace is a session filter.";+export const MEMORY_CONNECTOR_FIELD_NAMESPACE_OR_THREAD = "Namespace or thread";+export const MEMORY_CONNECTOR_LANGGRAPH_URL_REQUIRED =+ "A LangGraph server URL is required.";+export const MEMORY_CONNECTOR_LANGGRAPH_INVALID_NAMESPACE =+ "LangGraph namespace labels must be non-empty, cannot contain \".\", and must stay within the configured namespace template.";+export const MEMORY_CONNECTOR_LANGGRAPH_INVALID_TEMPLATE =+ "The namespace template is invalid. Use / between segments, only {user_id}, {thread_id}, or {assistant_id} placeholders (each at most once), and no \".\" in fixed segments.";+export const MEMORY_CONNECTOR_LANGGRAPH_TEMPLATE_VALUES_REQUIRED = (names: string) =>+ `This connector's namespace template needs ${names} to write a memory.`;+export const MEMORY_CONNECTOR_LANGGRAPH_UPDATE_CONFLICT =+ "This LangGraph item has a content or metadata field OpenLIT cannot edit without overwriting data. Update it from LangGraph instead.";+export const MEMORY_CONNECTOR_LANGGRAPH_AUTH_FAILED =+ "LangGraph rejected the credentials. Check the API key, or clear it for servers without authentication.";+export const MEMORY_CONNECTOR_LANGGRAPH_STORE_NOT_FOUND =+ "The LangGraph Store API was not found at this URL. Check the server URL and that the store routes are enabled.";export const MEMORY_CONNECTOR_SETUP_CLAUDE_SUMMARY ="Claude memory stores keep agent notes across Managed Agents sessions.";export const MEMORY_CONNECTOR_SETUP_MEM0_SUMMARY =@@ -3267,6 +3291,11 @@ export const DATA_SOURCE_SETUP_GUIDES: Record<string, { summary: string; steps:steps: ["Create a Zep Cloud API key, or point the endpoint at a self-hosted Zep service.", "Paste the API key into the credentials field. It is stored in the OpenLIT vault.", "Save the connector, then test the connection before using it from agents."],docsUrl: "https://help.getzep.com/sdk-reference",},+ langgraph: {+ summary: "Connect OpenLIT to the Store API of a LangGraph server.",+ steps: ["Enter the LangGraph server URL, for example a LangGraph Platform deployment or a self-hosted server such as http://localhost:2024.", "For LangGraph Platform, paste a LangSmith API key. Leave it empty for self-hosted servers without authentication.", "Optionally set a namespace template such as memories/{user_id}, then test the connection."],+ docsUrl: "https://docs.langchain.com/langsmith/agent-server",+ },trustabl: {summary: "Connect OpenLIT to Trustabl for agent reliability scans.",steps: [diff --git a/src/client/src/helpers/client/connector-analytics.ts b/src/client/src/helpers/client/connector-analytics.tsindex 3966d86b..e60c0f84 100644--- a/src/client/src/helpers/client/connector-analytics.ts+++ b/src/client/src/helpers/client/connector-analytics.ts@@ -20,6 +20,7 @@ const CONNECTOR_DISPLAY_NAMES: Record<string, string> = {mem0: "Mem0",memcode: "MemCode",zep: "Zep",+ langgraph: "LangGraph",};export function classifySignalRoutingChange(diff --git a/src/client/src/lib/platform/connectors/descriptions.ts b/src/client/src/lib/platform/connectors/descriptions.tsindex 4393cffb..0edf5ceb 100644--- a/src/client/src/lib/platform/connectors/descriptions.ts+++ b/src/client/src/lib/platform/connectors/descriptions.ts@@ -8,6 +8,7 @@ const CONNECTOR_DESCRIPTIONS: Record<string, string> = {mem0: "Long-term agent memory from Mem0.",memcode: "Long-term agent memory from MemCode.",zep: "Session and graph memory from Zep.",+ langgraph: "Long-term agent memory from a LangGraph Store.",trustabl: "Agent SDK and MCP reliability scans from Trustabl.",};diff --git a/src/client/src/lib/platform/connectors/icons.ts b/src/client/src/lib/platform/connectors/icons.tsindex 4c105294..7cc4aaac 100644--- a/src/client/src/lib/platform/connectors/icons.ts+++ b/src/client/src/lib/platform/connectors/icons.ts@@ -9,6 +9,7 @@ const CONNECTOR_ICONS: Record<string, string> = {mem0: "/images/connectors/mem0.svg",memcode: "/images/connectors/memcode.png",zep: "/images/connectors/zep.svg",+ langgraph: "/images/connectors/langgraph.svg",trustabl: "/images/connectors/trustabl.svg",};diff --git a/src/client/src/lib/platform/connectors/memory/README.md b/src/client/src/lib/platform/connectors/memory/README.mdindex 66177642..a5ebc904 100644--- a/src/client/src/lib/platform/connectors/memory/README.md+++ b/src/client/src/lib/platform/connectors/memory/README.md@@ -1,7 +1,7 @@# Memory connectors — add-a-vendor checklistThis layer is **vendor-agnostic**: OpenLIT talks to external memory providers-(Claude, Mem0, MemCode, and Zep today) through one adapter + a self-describing+(Claude, LangGraph, Mem0, MemCode, and Zep today) through one adapter + a self-describingdescriptor. Theshared forms, Prisma `ConnectorInstance` rows, and the connector catalog aredriven by that descriptor, so **adding a new memory vendor must not requirediff --git a/src/client/src/lib/platform/connectors/memory/bootstrap.ts b/src/client/src/lib/platform/connectors/memory/bootstrap.tsindex e1038a53..df3e2b08 100644--- a/src/client/src/lib/platform/connectors/memory/bootstrap.ts+++ b/src/client/src/lib/platform/connectors/memory/bootstrap.ts@@ -1,11 +1,12 @@/**- * Adapter bootstrap for CE memory connectors: Claude, Mem0, MemCode, and Zep.+ * Adapter bootstrap for CE memory connectors: Claude, LangGraph, Mem0, MemCode, and Zep.* Enterprise builds may contribute additional factories through the* neutral extension hook.*/import { getExternalMemoryAdapters } from "./enterprise";import { claudeAdapterFactory } from "./claude/adapter";+import { langgraphAdapterFactory } from "./langgraph/adapter";import { mem0AdapterFactory } from "./mem0/adapter";import { memcodeAdapterFactory } from "./memcode/adapter";import {@@ -17,6 +18,7 @@ import { registerMemoryConnectorTypes } from "./index";const VENDOR_FACTORIES = [claudeAdapterFactory,+ langgraphAdapterFactory,mem0AdapterFactory,memcodeAdapterFactory,zepAdapterFactory,@@ -34,6 +36,7 @@ export function ensureMemoryAdaptersRegistered(): void {if (registered &&hasMemoryAdapterFactory("claude") &&+ hasMemoryAdapterFactory("langgraph") &&hasMemoryAdapterFactory("mem0") &&hasMemoryAdapterFactory("memcode") &&hasMemoryAdapterFactory("zep")diff --git a/src/client/src/lib/platform/connectors/memory/claude/adapter.ts b/src/client/src/lib/platform/connectors/memory/claude/adapter.tsindex 852f0a88..a5982cf6 100644--- a/src/client/src/lib/platform/connectors/memory/claude/adapter.ts+++ b/src/client/src/lib/platform/connectors/memory/claude/adapter.ts@@ -25,6 +25,7 @@ import type {MemoryWriteInput,} from "../types";import { emptyMemoryFilters } from "../types";+import { asRecord, stringValue, writeContent } from "../values";const DEFAULT_URL = "https://api.anthropic.com";const ANTHROPIC_VERSION = "2023-06-01";@@ -48,18 +49,6 @@ const HISTORY_EVENTS: Record<string, string> = {deleted: "DELETE",};-function asRecord(value: unknown): Record<string, unknown> {- return value && typeof value === "object" && !Array.isArray(value)- ? (value as Record<string, unknown>)- : {};-}--function stringValue(value: unknown): string | undefined {- if (typeof value !== "string") return undefined;- const trimmed = value.trim();- return trimmed || undefined;-}-function objectValue(value: unknown): Record<string, unknown> | undefined {const record = asRecord(value);return Object.keys(record).length ? record : undefined;@@ -117,17 +106,6 @@ function actorId(raw: unknown): string | undefined {);}-function writeContent(input: MemoryWriteInput): string {- const content = stringValue(input.content);- if (content) return content;- const joined = (input.messages || [])- .map((message) => stringValue(message.content))- .filter((item): item is string => !!item)- .join("\n")- .trim();- return joined;-}-function writePath(input: MemoryWriteInput, content: string): string {const raw = stringValue(input.metadata?.path);if (raw) return raw.startsWith("/") ? raw : `/${raw}`;diff --git a/src/client/src/lib/platform/connectors/memory/enterprise.ts b/src/client/src/lib/platform/connectors/memory/enterprise.tsindex 32b7cd98..ec7e49d5 100644--- a/src/client/src/lib/platform/connectors/memory/enterprise.ts+++ b/src/client/src/lib/platform/connectors/memory/enterprise.ts@@ -1,7 +1,7 @@/*** Neutral extension hook for additional memory connector adapters.*- * CE memory vendors (Claude, Mem0, MemCode, Zep) are registered via `bootstrap.ts`. This hook+ * CE memory vendors (Claude, LangGraph, Mem0, MemCode, Zep) are registered via `bootstrap.ts`. This hook* stays empty in CE so a private fork can contribute extra factories without* importing `@/ee/**` from shared code.*/diff --git a/src/client/src/lib/platform/connectors/memory/langgraph/adapter.ts b/src/client/src/lib/platform/connectors/memory/langgraph/adapter.tsnew file mode 100644index 00000000..5564f240--- /dev/null+++ b/src/client/src/lib/platform/connectors/memory/langgraph/adapter.ts@@ -0,0 +1,760 @@+/**+ * LangGraph memory connector.+ *+ * Talks to the Store API of a LangGraph Server (LangGraph Platform / LangSmith+ * deployments or a self-hosted server). Both expose the same `/store/*` routes;+ * only authentication differs. The API key is optional and, when set, is sent+ * as `x-api-key`. Bearer and other custom auth handlers are not supported.+ *+ * Store items are addressed by a namespace (ordered string labels) plus a key.+ * Namespace segments carry no user/thread/assistant meaning unless the optional+ * namespace template declares it (for example `memories/{user_id}`). Without+ * placeholders, full namespaces are exposed through the session filter, the+ * same way the Claude connector exposes memory stores.+ *+ * Item values are arbitrary JSON. Content is read from the LangMem shapes+ * (`{kind, content: {content}}` or `{content}`) and otherwise falls back to the+ * JSON of the whole value, including arrays and primitives. The original value+ * is always kept in metadata.+ *+ * Search is semantic only when the server has a store index configured.+ * Without one LangGraph ignores the query, returns items in listing order, and+ * scores are null. OpenLIT does not emulate semantic search locally.+ */++import { randomUUID } from "crypto";+import getMessage from "@/constants/messages";+import type { ConnectorHealthResult } from "../../types";+import {+ allowHttpField,+ allowPrivateNetworkField,+ endpointField,+} from "../../datasource/config-fields";+import { SourceResponseError } from "../../datasource/http/safe-fetch";+import type { ResolvedSecret } from "../../datasource/http/secret";+import { BaseMemoryAdapter } from "../base-adapter";+import { memoryApiKeyField, memoryPageFilters } from "../config-fields";+import { memoryBaseUrl, memoryRequest } from "../http";+import type {+ MemoryCapabilities,+ MemoryFilterOptions,+ MemoryListFilter,+ MemoryRecord,+ MemorySearchQuery,+ MemorySourceDescriptor,+ MemoryTypeDescriptor,+ MemoryUpdateInput,+ MemoryWriteInput,+} from "../types";+import { emptyMemoryFilters } from "../types";+import { asRecord, isPlainObject, stringValue, uniqueChoices, writeContent } from "../values";++const DOCS_URL = "https://docs.langchain.com/langsmith/agent-server";+const URL_PLACEHOLDER = "http://localhost:2024";+const DEFAULT_LIMIT = 25;+const NAMESPACE_PAGE_SIZE = 100;+const MAX_NAMESPACE_PAGES = 5;+/** Upper bound on namespaces searched when a template prefix has a gap. */+const MAX_CANDIDATE_NAMESPACES = 10;++const LANGGRAPH_CAPABILITIES: MemoryCapabilities = {+ add: true,+ search: true,+ get: true,+ list: true,+ update: true,+ delete: true,+ feedback: false,+};++type Placeholder = "user_id" | "thread_id" | "assistant_id";+type RecordField = "userId" | "sessionId" | "agentId";++const PLACEHOLDER_FIELDS: Record<Placeholder, RecordField> = {+ user_id: "userId",+ thread_id: "sessionId",+ assistant_id: "agentId",+};++type TemplateSegment =+ | { kind: "fixed"; value: string }+ | { kind: "placeholder"; name: Placeholder };++interface NamespaceScope {+ /** Fixed and placeholder segments, or null when no template is configured. */+ template: TemplateSegment[] | null;+ /** True when the template declares at least one placeholder. */+ mapped: boolean;+ /** Leading fixed segments, used as the discovery/listing prefix. */+ prefix: string[];+}++interface StoreItem {+ namespace: string[];+ key: string;+ /**+ * Arbitrary JSON. Writes send objects because Store PUT rejects anything+ * else, but reads keep arrays, primitives, and null so they are not lost.+ */+ value: unknown;+ createdAt?: string;+ updatedAt?: string;+ score?: number;+}++type ContentSource = "nested" | "content" | "fallback";++function isValidLabel(label: string): boolean {+ return label.length > 0 && !label.includes(".");+}++/** LangGraph rejects empty labels and labels containing "." (GET joins with "."). */+function assertNamespace(namespace: string[]): string[] {+ if (!namespace.length || !namespace.every(isValidLabel)) {+ throw new Error(getMessage().MEMORY_CONNECTOR_LANGGRAPH_INVALID_NAMESPACE);+ }+ return namespace;+}++function namespaceId(namespace: string[]): string {+ return namespace.join(".");+}++function parseNamespaceId(value: string): string[] {+ return assertNamespace(value.split(".").map((label) => label.trim()));+}++/**+ * Memory ids are `<namespace joined by ".">:<URI-encoded key>`. Labels may+ * contain ":" but the encoded key never does, so the last ":" splits the id.+ */+function encodeMemoryRef(namespace: string[], key: string): string {+ return `${namespaceId(namespace)}:${encodeURIComponent(key)}`;+}++function parseMemoryRef(id: string): { namespace: string[]; key: string } | null {+ const trimmed = id.trim();+ const split = trimmed.lastIndexOf(":");+ if (split <= 0) return null;+ const namespace = trimmed.slice(0, split).split(".");+ if (!namespace.every(isValidLabel)) return null;+ let key: string;+ try {+ key = decodeURIComponent(trimmed.slice(split + 1));+ } catch {+ return null;+ }+ return key ? { namespace, key } : null;+}++function parseTemplate(raw: unknown): TemplateSegment[] | null {+ if (typeof raw !== "string" || !raw.trim()) return null;+ const segments = raw+ .split("/")+ .map((part) => part.trim())+ .filter(Boolean);+ const seen = new Set<Placeholder>();+ const parsed: TemplateSegment[] = [];+ for (const segment of segments) {+ const match = /^\{([a-z_]+)\}$/.exec(segment);+ if (match) {+ const name = match[1] as Placeholder;+ if (!(name in PLACEHOLDER_FIELDS) || seen.has(name)) {+ throw new Error(getMessage().MEMORY_CONNECTOR_LANGGRAPH_INVALID_TEMPLATE);+ }+ seen.add(name);+ parsed.push({ kind: "placeholder", name });+ continue;+ }+ if (!isValidLabel(segment) || /[{}]/.test(segment)) {+ throw new Error(getMessage().MEMORY_CONNECTOR_LANGGRAPH_INVALID_TEMPLATE);+ }+ parsed.push({ kind: "fixed", value: segment });+ }+ return parsed.length ? parsed : null;+}++function leadingFixed(template: TemplateSegment[] | null): string[] {+ const prefix: string[] = [];+ for (const segment of template || []) {+ if (segment.kind !== "fixed") break;+ prefix.push(segment.value);+ }+ return prefix;+}++function startsWith(namespace: string[], prefix: string[]): boolean {+ return prefix.every((label, index) => namespace[index] === label);+}++/** Placeholder values an item's namespace provides, or null when it does not fit the template. */+function matchTemplate(+ template: TemplateSegment[],+ namespace: string[]+): Partial<Record<RecordField, string>> | null {+ if (namespace.length < template.length) return null;+ const fields: Partial<Record<RecordField, string>> = {};+ for (let index = 0; index < template.length; index += 1) {+ const segment = template[index];+ if (segment.kind === "fixed") {+ if (namespace[index] !== segment.value) return null;+ } else {+ fields[PLACEHOLDER_FIELDS[segment.name]] = namespace[index];+ }+ }+ return fields;+}++/** Whether a namespace falls inside the connector's configured template or prefix. */+function namespaceInScope(scope: NamespaceScope, namespace: string[]): boolean {+ return scope.mapped && scope.template+ ? !!matchTemplate(scope.template, namespace)+ : startsWith(namespace, scope.prefix);+}++function filterValue(+ filter: { userId?: string; sessionId?: string; agentId?: string },+ field: RecordField+): string | undefined {+ return stringValue(filter[field]);+}++/**+ * Where OpenLIT's content came from in a Store value:+ * 1. LangMem `MemoryStoreManager` shape: `value.content.content`+ * 2. LangMem memory tools shape: string `value.content`+ * 3. fallback: JSON of the whole value+ */+function jsonFallback(value: unknown): string {+ if (value === undefined) return "{}";+ try {+ return JSON.stringify(value) ?? "";+ } catch {+ return "";+ }+}++function contentSource(value: unknown): ContentSource {+ if (!isPlainObject(value)) return "fallback";+ if (isPlainObject(value.content) && typeof value.content.content === "string") {+ return "nested";+ }+ if (typeof value.content === "string") return "content";+ return "fallback";+}++function readContent(value: unknown): string {+ if (!isPlainObject(value)) return jsonFallback(value);+ const source = contentSource(value);+ if (source === "nested") return asRecord(value.content).content as string;+ if (source === "content") return value.content as string;+ return jsonFallback(value);+}++/**+ * Rebuilds a value with new content, touching only the field the content was+ * read from. Throws instead of overwriting when a JSON-fallback value already+ * has a non-text `content` field.+ */+function replaceContent(+ value: Record<string, unknown>,+ content: string+): Record<string, unknown> {+ const source = contentSource(value);+ if (source === "nested") {+ return { ...value, content: { ...asRecord(value.content), content } };+ }+ if (source === "fallback" && Object.prototype.hasOwnProperty.call(value, "content")) {+ throw new Error(getMessage().MEMORY_CONNECTOR_LANGGRAPH_UPDATE_CONFLICT);+ }+ return { ...value, content };+}++/** `langgraph` is OpenLIT's read-only projection of the item; never write it back. */+function writableMetadata(+ metadata: Record<string, unknown> | undefined+): Record<string, unknown> | undefined {+ if (!metadata) return undefined;+ const { langgraph: _projection, ...rest } = metadata;+ return Object.keys(rest).length ? rest : undefined;+}++function normalizeItem(raw: unknown): StoreItem | null {+ const row = asRecord(raw);+ const key = typeof row.key === "string" ? row.key : "";+ const namespace = Array.isArray(row.namespace)+ ? row.namespace.filter((label): label is string => typeof label === "string")+ : [];+ if (!key || !namespace.length) return null;+ return {+ namespace,+ key,+ value: Object.prototype.hasOwnProperty.call(row, "value") ? row.value : {},+ createdAt: stringValue(row.created_at),+ updatedAt: stringValue(row.updated_at),+ score:+ typeof row.score === "number" && Number.isFinite(row.score)+ ? row.score+ : undefined,+ };+}++function normalizeItems(raw: unknown): StoreItem[] {+ const rows = asRecord(raw).items;+ if (!Array.isArray(rows)) return [];+ return rows+ .map((row) => normalizeItem(row))+ .filter((item): item is StoreItem => !!item);+}++/** Documented as a bare array; the server returns `{ namespaces }`. Accept both. */+function normalizeNamespaces(raw: unknown): string[][] {+ const rows = Array.isArray(raw) ? raw : asRecord(raw).namespaces;+ if (!Array.isArray(rows)) return [];+ return rows+ .filter((row): row is unknown[] => Array.isArray(row))+ .map((row) => row.filter((label): label is string => typeof label === "string"))+ .filter((row) => row.length > 0 && row.every(isValidLabel));+}++function sortMerged(items: StoreItem[]): StoreItem[] {+ return [...items].sort((a, b) => {+ const scoreA = a.score ?? Number.NEGATIVE_INFINITY;+ const scoreB = b.score ?? Number.NEGATIVE_INFINITY;+ if (scoreA !== scoreB) return scoreB - scoreA;+ return String(b.updatedAt || "").localeCompare(String(a.updatedAt || ""));+ });+}++export class LangGraphAdapter extends BaseMemoryAdapter {+ readonly type = "langgraph";++ private get baseUrl(): string {+ const url = memoryBaseUrl(this.descriptor, "");+ if (!url) throw new Error(getMessage().MEMORY_CONNECTOR_LANGGRAPH_URL_REQUIRED);+ return url;+ }++ private scope(): NamespaceScope {+ const template = parseTemplate(this.descriptor.settings.namespaceTemplate);+ return {+ template,+ mapped: !!template?.some((segment) => segment.kind === "placeholder"),+ prefix: leadingFixed(template),+ };+ }++ private request<T>(+ path: string,+ opts: { method?: string; body?: unknown; timeoutMs?: number } = {}+ ) {+ return memoryRequest<T>(this.descriptor, this.baseUrl, path, {+ ...opts,+ authHeaders: (secret: ResolvedSecret): Record<string, string> => {+ const apiKey = secret.credentials.apiKey || secret.raw;+ return apiKey ? { "x-api-key": apiKey } : {};+ },+ });+ }++ capabilities(): MemoryCapabilities {+ return { ...LANGGRAPH_CAPABILITIES };+ }++ /** `/ok` and `/info` skip auth, so probe an authenticated store route instead. */+ async healthCheck(): Promise<ConnectorHealthResult> {+ const started = Date.now();+ try {+ this.scope();+ await this.request("store/namespaces", {+ method: "POST",+ body: { limit: 1 },+ timeoutMs: 10_000,+ });+ return { ok: true, latencyMs: Date.now() - started };+ } catch (error) {+ const messages = getMessage();+ const status = error instanceof SourceResponseError ? error.status : undefined;+ return {+ ok: false,+ latencyMs: Date.now() - started,+ message:+ status === 401 || status === 403+ ? messages.MEMORY_CONNECTOR_LANGGRAPH_AUTH_FAILED+ : status === 404+ ? messages.MEMORY_CONNECTOR_LANGGRAPH_STORE_NOT_FOUND+ : String((error as Error)?.message || error),+ };+ }+ }++ async add(input: MemoryWriteInput): Promise<MemoryRecord[]> {+ const content = writeContent(input);+ if (!content) throw new Error(getMessage().MEMORY_CONNECTOR_CONTENT_REQUIRED);+ const namespace = this.writeNamespace(input);+ const key = randomUUID();+ const metadata = writableMetadata(input.metadata);+ const value: Record<string, unknown> = {+ content,+ ...(metadata ? { metadata } : {}),+ };+ await this.request("store/items", {+ method: "PUT",+ body: { namespace, key, value },+ });+ return [this.toRecord({ namespace, key, value })];+ }++ async search(query: MemorySearchQuery): Promise<MemoryRecord[]> {+ const q = query.query.trim();+ if (!q) throw new Error(getMessage().MEMORY_CONNECTOR_QUERY_REQUIRED);+ return this.find(query, q);+ }++ async list(filter: MemoryListFilter): Promise<MemoryRecord[]> {+ return this.find(filter);+ }++ async get(id: string): Promise<MemoryRecord | null> {+ const ref = this.scopedRef(id);+ if (!ref) return null;+ const item = await this.fetchItem(ref.namespace, ref.key);+ return item ? this.toRecord(item) : null;+ }++ /**+ * Store PUT replaces the whole value, so update is read-modify-write: read+ * the item, replace only the field the content came from, keep every other+ * field, and PUT the result. The Store API offers no compare-and-swap, so a+ * write landing between the read and the PUT can be lost.+ */+ async update(id: string, input: MemoryUpdateInput): Promise<MemoryRecord> {+ const messages = getMessage();+ const ref = this.scopedRef(id);+ if (!ref) throw new Error(messages.MEMORY_DETAIL_NOT_FOUND);+ const existing = await this.fetchItem(ref.namespace, ref.key);+ if (!existing) throw new Error(messages.MEMORY_DETAIL_NOT_FOUND);++ if (!isPlainObject(existing.value)) {+ throw new Error(messages.MEMORY_CONNECTOR_LANGGRAPH_UPDATE_CONFLICT);+ }+ let value = replaceContent(existing.value, input.content);+ const metadata = writableMetadata(input.metadata);+ if (metadata) {+ const current = existing.value.metadata;+ if (current !== undefined && !isPlainObject(current)) {+ throw new Error(messages.MEMORY_CONNECTOR_LANGGRAPH_UPDATE_CONFLICT);+ }+ value = { ...value, metadata: { ...asRecord(current), ...metadata } };+ }++ await this.request("store/items", {+ method: "PUT",+ body: { namespace: ref.namespace, key: ref.key, value },+ });+ return this.toRecord({ ...existing, value, updatedAt: undefined });+ }++ async delete(id: string): Promise<void> {+ const ref = this.scopedRef(id);+ if (!ref) throw new Error(getMessage().MEMORY_DETAIL_NOT_FOUND);+ await this.request("store/items", {+ method: "DELETE",+ body: { namespace: ref.namespace, key: ref.key },+ });+ }++ async listFilters(): Promise<MemoryFilterOptions> {+ try {+ const scope = this.scope();+ const namespaces = await this.listNamespaces(+ scope.prefix,+ scope.mapped ? scope.template?.length : undefined+ );+ const filters = emptyMemoryFilters();+ if (!scope.mapped || !scope.template) {+ filters.sessions = uniqueChoices(+ namespaces.map((namespace) => ({+ id: namespaceId(namespace),+ label: namespaceId(namespace),+ }))+ );+ return filters;+ }+ for (const namespace of namespaces) {+ const fields = matchTemplate(scope.template, namespace);+ if (!fields) continue;+ if (fields.userId) {+ filters.users.push({ id: fields.userId, label: fields.userId });+ }+ if (fields.sessionId) {+ filters.sessions.push({+ id: fields.sessionId,+ label: fields.sessionId,+ ...(fields.userId ? { userId: fields.userId } : {}),+ });+ }+ if (fields.agentId) {+ filters.agents.push({ id: fields.agentId, label: fields.agentId });+ }+ }+ return {+ users: uniqueChoices(filters.users),+ sessions: uniqueChoices(filters.sessions),+ agents: uniqueChoices(filters.agents),+ };+ } catch {+ return emptyMemoryFilters();+ }+ }++ /**+ * Parses a memory id and rejects namespaces outside this connector's scope+ * before any request, so a crafted id cannot reach other namespaces and+ * out-of-scope items look the same as missing ones.+ */+ private scopedRef(id: string): { namespace: string[]; key: string } | null {+ const ref = parseMemoryRef(id);+ return ref && namespaceInScope(this.scope(), ref.namespace) ? ref : null;+ }++ private async fetchItem(namespace: string[], key: string): Promise<StoreItem | null> {+ const params = new URLSearchParams();+ params.set("namespace", namespaceId(assertNamespace(namespace)));+ params.set("key", key);+ const body = await this.request(`store/items?${params.toString()}`);+ return normalizeItem(body);+ }++ private writeNamespace(input: MemoryWriteInput): string[] {+ const messages = getMessage();+ const scope = this.scope();+ if (!scope.mapped || !scope.template) {+ const selected = stringValue(input.sessionId);+ if (!selected) throw new Error(messages.MEMORY_CONNECTOR_SESSION_REQUIRED);+ const namespace = parseNamespaceId(selected);+ if (!startsWith(namespace, scope.prefix)) {+ throw new Error(messages.MEMORY_CONNECTOR_LANGGRAPH_INVALID_NAMESPACE);+ }+ return namespace;+ }+ const missing: string[] = [];+ const namespace = scope.template.map((segment) => {+ if (segment.kind === "fixed") return segment.value;+ const value = filterValue(input, PLACEHOLDER_FIELDS[segment.name]);+ if (!value) missing.push(segment.name);+ return value || "";+ });+ if (missing.length) {+ throw new Error(messages.MEMORY_CONNECTOR_LANGGRAPH_TEMPLATE_VALUES_REQUIRED(missing.join(", ")));+ }+ return assertNamespace(namespace);+ }++ /** Shared list/search path: resolve namespace prefixes, query, and keep matching items. */+ private async find(+ filter: MemoryListFilter,+ query?: string+ ): Promise<MemoryRecord[]> {+ const scope = this.scope();+ const limit = filter.limit || DEFAULT_LIMIT;+ const prefixes = await this.searchPrefixes(scope, filter);+ if (!prefixes.length) return [];++ const batches = await Promise.all(+ prefixes.map((prefix) => this.searchItems(prefix, limit, query))+ );+ const items = batches.flat().filter((item) => this.matches(scope, filter, item));+ const ordered = prefixes.length > 1 ? sortMerged(items) : items;+ return ordered.slice(0, limit).map((item) => this.toRecord(item, scope));+ }++ /**+ * Namespace prefixes to search. The Store only matches prefixes, so a+ * template whose supplied values leave a gap (e.g. thread without user)+ * resolves candidate namespaces through `/store/namespaces` first.+ * Returns [] when a filter can never match in this connector's mode.+ */+ private async searchPrefixes(+ scope: NamespaceScope,+ filter: MemoryListFilter+ ): Promise<string[][]> {+ if (!scope.mapped || !scope.template) {+ if (filterValue(filter, "userId") || filterValue(filter, "agentId")) return [];+ const selected = filterValue(filter, "sessionId");+ if (!selected) return [scope.prefix];+ const namespace = parseNamespaceId(selected);+ return startsWith(namespace, scope.prefix) ? [namespace] : [];+ }++ const template = scope.template;+ const declared = new Set<RecordField>();+ for (const segment of template) {+ if (segment.kind === "placeholder") declared.add(PLACEHOLDER_FIELDS[segment.name]);+ }+ const fields: RecordField[] = ["userId", "sessionId", "agentId"];+ if (fields.some((field) => filterValue(filter, field) && !declared.has(field))) {+ return [];+ }++ const values = template.map((segment) =>+ segment.kind === "fixed"+ ? segment.value+ : filterValue(filter, PLACEHOLDER_FIELDS[segment.name])+ );+ values.forEach((value) => {+ if (value !== undefined && !isValidLabel(value)) {+ throw new Error(getMessage().MEMORY_CONNECTOR_LANGGRAPH_INVALID_NAMESPACE);+ }+ });+ const gap = values.findIndex((value) => value === undefined);+ const prefix = (gap === -1 ? values : values.slice(0, gap)) as string[];+ let lastDefined = -1;+ values.forEach((value, index) => {+ if (value !== undefined) lastDefined = index;+ });+ if (lastDefined < prefix.length) return [prefix];++ const depth = lastDefined + 1;+ const candidates = await this.listNamespaces(prefix, depth);+ const seen = new Set<string>();+ const resolved: string[][] = [];+ for (const namespace of candidates) {+ if (namespace.length < depth) continue;+ const truncated = namespace.slice(0, depth);+ const fits = values+ .slice(0, depth)+ .every((value, index) => value === undefined || truncated[index] === value);+ if (!fits) continue;+ const id = namespaceId(truncated);+ if (seen.has(id)) continue;+ seen.add(id);+ resolved.push(truncated);+ if (resolved.length >= MAX_CANDIDATE_NAMESPACES) break;+ }+ return resolved;+ }++ private matches(+ scope: NamespaceScope,+ filter: MemoryListFilter,+ item: StoreItem+ ): boolean {+ if (!scope.mapped || !scope.template) {+ if (!startsWith(item.namespace, scope.prefix)) return false;+ const selected = filterValue(filter, "sessionId");+ return !selected || namespaceId(item.namespace) === selected;+ }+ const fields = matchTemplate(scope.template, item.namespace);+ if (!fields) return false;+ return (["userId", "sessionId", "agentId"] as RecordField[]).every((field) => {+ const wanted = filterValue(filter, field);+ return !wanted || fields[field] === wanted;+ });+ }++ private async searchItems(+ prefix: string[],+ limit: number,+ query?: string+ ): Promise<StoreItem[]> {+ const body = await this.request("store/items/search", {+ method: "POST",+ body: {+ namespace_prefix: prefix,+ limit,+ offset: 0,+ ...(query ? { query } : {}),+ },+ });+ return normalizeItems(body);+ }++ private async listNamespaces(prefix: string[], maxDepth?: number): Promise<string[][]> {+ const namespaces: string[][] = [];+ for (let page = 0; page < MAX_NAMESPACE_PAGES; page += 1) {+ const body = await this.request("store/namespaces", {+ method: "POST",+ body: {+ ...(prefix.length ? { prefix } : {}),+ ...(maxDepth ? { max_depth: maxDepth } : {}),+ limit: NAMESPACE_PAGE_SIZE,+ offset: page * NAMESPACE_PAGE_SIZE,+ },+ });+ const rows = normalizeNamespaces(body);+ namespaces.push(...rows);+ if (rows.length < NAMESPACE_PAGE_SIZE) break;+ }+ return namespaces;+ }++ private toRecord(item: StoreItem, scope: NamespaceScope = this.scope()): MemoryRecord {+ const fields =+ scope.mapped && scope.template+ ? matchTemplate(scope.template, item.namespace) || {}+ : { sessionId: namespaceId(item.namespace) };+ const ownMetadata =+ isPlainObject(item.value) && isPlainObject(item.value.metadata)+ ? item.value.metadata+ : {};+ return {+ id: encodeMemoryRef(item.namespace, item.key),+ content: readContent(item.value),+ ...fields,+ metadata: {+ ...ownMetadata,+ langgraph: {+ namespace: item.namespace,+ key: item.key,+ value: item.value,+ },+ },+ score: item.score,+ createdAt: item.createdAt,+ updatedAt: item.updatedAt,+ };+ }+}++export const langgraphAdapterFactory = {+ type: "langgraph",+ create: (descriptor: MemorySourceDescriptor) => new LangGraphAdapter(descriptor),+ describe: (): MemoryTypeDescriptor => {+ const messages = getMessage();+ return {+ type: "langgraph",+ displayName: "LangGraph",+ description: messages.MEMORY_CONNECTOR_LANGGRAPH_DESCRIPTION,+ capabilities: { ...LANGGRAPH_CAPABILITIES },+ configFields: [+ endpointField(URL_PLACEHOLDER),+ allowHttpField(),+ allowPrivateNetworkField(),+ {+ ...memoryApiKeyField(),+ description: messages.MEMORY_CONNECTOR_LANGGRAPH_API_KEY_HELP,+ },+ {+ key: "namespaceTemplate",+ label: messages.MEMORY_CONNECTOR_FIELD_NAMESPACE_TEMPLATE,+ kind: "text",+ group: "settings",+ placeholder: "memories/{user_id}",+ description: messages.MEMORY_CONNECTOR_FIELD_NAMESPACE_TEMPLATE_HELP,+ },+ ],+ filterFields: memoryPageFilters([+ "userId",+ {+ key: "sessionId",+ label: messages.MEMORY_CONNECTOR_FIELD_NAMESPACE_OR_THREAD,+ },+ "agentId",+ ]),+ authStyle: "api-key",+ authHelp: messages.MEMORY_CONNECTOR_AUTH_HELP_LANGGRAPH,+ docsUrl: DOCS_URL,+ };+ },+};diff --git a/src/client/src/lib/platform/connectors/memory/mem0/adapter.ts b/src/client/src/lib/platform/connectors/memory/mem0/adapter.tsindex 74b4a32f..d406eb7b 100644--- a/src/client/src/lib/platform/connectors/memory/mem0/adapter.ts+++ b/src/client/src/lib/platform/connectors/memory/mem0/adapter.ts@@ -30,6 +30,7 @@ import type {MemoryWriteInput,} from "../types";import { emptyMemoryFilters } from "../types";+import { asRecord, stringValue, uniqueChoices } from "../values";const DEFAULT_URL = "https://api.mem0.ai";@@ -55,18 +56,6 @@ const RATING_TO_MEM0_FEEDBACK: Record<MemoryFeedbackRating, string> = {very_negative: "VERY_NEGATIVE",};-function asRecord(value: unknown): Record<string, unknown> {- return value && typeof value === "object" && !Array.isArray(value)- ? (value as Record<string, unknown>)- : {};-}--function stringValue(value: unknown): string | undefined {- if (typeof value !== "string") return undefined;- const trimmed = value.trim();- return trimmed || undefined;-}-function stringList(value: unknown): string[] {if (!Array.isArray(value)) return [];return value@@ -230,17 +219,6 @@ function normalizeList(raw: unknown): MemoryRecord[] {.filter((row): row is MemoryRecord => !!row);}-function uniqueChoices(choices: MemoryFilterChoice[]): MemoryFilterChoice[] {- const seen = new Set<string>();- const next: MemoryFilterChoice[] = [];- for (const choice of choices) {- if (!choice.id || seen.has(choice.id)) continue;- seen.add(choice.id);- next.push(choice);- }- return next.sort((a, b) => a.label.localeCompare(b.label));-}-function entityKind(row: Record<string, unknown>): "user" | "agent" | "session" | null {const type = (stringValue(row.type) ||diff --git a/src/client/src/lib/platform/connectors/memory/memcode/adapter.ts b/src/client/src/lib/platform/connectors/memory/memcode/adapter.tsindex 82ed257a..8cc179bc 100644--- a/src/client/src/lib/platform/connectors/memory/memcode/adapter.ts+++ b/src/client/src/lib/platform/connectors/memory/memcode/adapter.ts@@ -22,6 +22,7 @@ import { BaseMemoryAdapter } from "../base-adapter";import { memoryHttpVendorFields, memoryPageFilters } from "../config-fields";import { memoryBaseUrl, memoryRequest } from "../http";import { classifyMemoryKind } from "../graph";+import { asRecord, stringValue } from "../values";import type {MemoryGraphEdge,MemoryGraphModel,@@ -83,18 +84,6 @@ const MEMCODE_CAPABILITIES: MemoryCapabilities = {feedback: false,};-function asRecord(value: unknown): Record<string, unknown> {- return value && typeof value === "object" && !Array.isArray(value)- ? (value as Record<string, unknown>)- : {};-}--function stringValue(value: unknown): string | undefined {- if (typeof value !== "string") return undefined;- const trimmed = value.trim();- return trimmed || undefined;-}-function numberValue(value: unknown): number | undefined {return typeof value === "number" && Number.isFinite(value) ? value : undefined;}diff --git a/src/client/src/lib/platform/connectors/memory/port-link.ts b/src/client/src/lib/platform/connectors/memory/port-link.tsindex 0540b4df..5e215c19 100644--- a/src/client/src/lib/platform/connectors/memory/port-link.ts+++ b/src/client/src/lib/platform/connectors/memory/port-link.ts@@ -3,6 +3,7 @@*/import type { MemoryPortLink, MemoryRecord } from "./types";+import { asRecord, stringValue } from "./values";export function memoryContentFingerprint(content: string,@@ -16,18 +17,6 @@ export function memoryContentFingerprint(return Math.abs(hash).toString(16);}-function asRecord(value: unknown): Record<string, unknown> {- return value && typeof value === "object" && !Array.isArray(value)- ? (value as Record<string, unknown>)- : {};-}--function stringValue(value: unknown): string | undefined {- if (typeof value !== "string") return undefined;- const trimmed = value.trim();- return trimmed || undefined;-}-export function parseMemoryPortLink(metadata?: Record<string, unknown> | null): MemoryPortLink | undefined {diff --git a/src/client/src/lib/platform/connectors/memory/read.ts b/src/client/src/lib/platform/connectors/memory/read.tsindex 8c8d5e1b..ee69bc07 100644--- a/src/client/src/lib/platform/connectors/memory/read.ts+++ b/src/client/src/lib/platform/connectors/memory/read.ts@@ -38,6 +38,7 @@ import {} from "./types";import { getMemoryTypeDescriptor } from "./registry";import { attachMemoryPorts } from "./port-link";+import { uniqueChoices } from "./values";import {DATA_SOURCE_SECRET_DECRYPT_FAILED,DATA_SOURCE_SECRET_NOT_FOUND,@@ -144,17 +145,6 @@ function resolveFilterFields(type: string): MemoryFilterField[] {return fallbackFilterFields();}-function uniqueChoices(choices: MemoryFilterChoice[]): MemoryFilterChoice[] {- const seen = new Set<string>();- const next: MemoryFilterChoice[] = [];- for (const choice of choices) {- if (!choice.id || seen.has(choice.id)) continue;- seen.add(choice.id);- next.push(choice);- }- return next.sort((a, b) => a.label.localeCompare(b.label));-}-function mergeFilters(base: MemoryFilterOptions,extra: MemoryFilterOptionsdiff --git a/src/client/src/lib/platform/connectors/memory/registry.ts b/src/client/src/lib/platform/connectors/memory/registry.tsindex f3145a9d..26f9961f 100644--- a/src/client/src/lib/platform/connectors/memory/registry.ts+++ b/src/client/src/lib/platform/connectors/memory/registry.ts@@ -2,7 +2,7 @@* Memory connector adapter registry (CE).** Holds adapter factories keyed by connector type. `bootstrap.ts` registers- * Claude, Mem0, MemCode, and Zep. Extra private factories can still be contributed+ * Claude, LangGraph, Mem0, MemCode, and Zep. Extra private factories can still be contributed* through the neutral `getExternalMemoryAdapters()` hook without an* `@/ee/**` import.*/diff --git a/src/client/src/lib/platform/connectors/memory/values.ts b/src/client/src/lib/platform/connectors/memory/values.tsnew file mode 100644index 00000000..b97dcb01--- /dev/null+++ b/src/client/src/lib/platform/connectors/memory/values.ts@@ -0,0 +1,45 @@+/**+ * Shared value helpers for memory connectors.+ *+ * Adapters keep vendor-specific parsing local. These helpers are the copies+ * that were identical across Claude, LangGraph, Mem0, MemCode, Zep, and the+ * read path. Zep keeps its own stringValue because Zep ids can be numbers.+ */++import type { MemoryFilterChoice, MemoryWriteInput } from "./types";++export function isPlainObject(value: unknown): value is Record<string, unknown> {+ return !!value && typeof value === "object" && !Array.isArray(value);+}++export function asRecord(value: unknown): Record<string, unknown> {+ return isPlainObject(value) ? value : {};+}++export function stringValue(value: unknown): string | undefined {+ if (typeof value !== "string") return undefined;+ const trimmed = value.trim();+ return trimmed || undefined;+}++export function uniqueChoices(choices: MemoryFilterChoice[]): MemoryFilterChoice[] {+ const seen = new Set<string>();+ const next: MemoryFilterChoice[] = [];+ for (const choice of choices) {+ if (!choice.id || seen.has(choice.id)) continue;+ seen.add(choice.id);+ next.push(choice);+ }+ return next.sort((a, b) => a.label.localeCompare(b.label));+}++/** Content field, or the joined text of messages when content is empty. */+export function writeContent(input: MemoryWriteInput): string {+ const content = stringValue(input.content);+ if (content) return content;+ return (input.messages || [])+ .map((message) => stringValue(message.content))+ .filter((item): item is string => !!item)+ .join("\n")+ .trim();+}diff --git a/src/client/src/lib/platform/connectors/memory/zep/adapter.ts b/src/client/src/lib/platform/connectors/memory/zep/adapter.tsindex 97edf33e..63c05583 100644--- a/src/client/src/lib/platform/connectors/memory/zep/adapter.ts+++ b/src/client/src/lib/platform/connectors/memory/zep/adapter.ts@@ -27,6 +27,7 @@ import type {MemoryWriteInput,} from "../types";import { emptyMemoryFilters } from "../types";+import { asRecord, uniqueChoices } from "../values";const DEFAULT_URL = "https://api.getzep.com";const EDGE_PAGE_SIZE = 50;@@ -43,12 +44,7 @@ const ZEP_CAPABILITIES: MemoryCapabilities = {feedback: false,};-function asRecord(value: unknown): Record<string, unknown> {- return value && typeof value === "object" && !Array.isArray(value)- ? (value as Record<string, unknown>)- : {};-}-+/** Zep ids arrive as numbers as well as strings. The shared helper only accepts strings. */function stringValue(value: unknown): string | undefined {if (typeof value === "number" && Number.isFinite(value)) return String(value);if (typeof value !== "string") return undefined;@@ -77,17 +73,6 @@ function requireScope(filter: { userId?: string; sessionId?: string }): void {}}-function uniqueChoices(choices: MemoryFilterChoice[]): MemoryFilterChoice[] {- const seen = new Set<string>();- const next: MemoryFilterChoice[] = [];- for (const choice of choices) {- if (!choice.id || seen.has(choice.id)) continue;- seen.add(choice.id);- next.push(choice);- }- return next.sort((a, b) => a.label.localeCompare(b.label));-}-function rowsFrom(raw: unknown, keys: string[]): unknown[] {if (Array.isArray(raw)) return raw;const body = asRecord(raw);diff --git a/src/client/src/lib/platform/connectors/visible-types.ts b/src/client/src/lib/platform/connectors/visible-types.tsindex cda43c91..573fcf5e 100644--- a/src/client/src/lib/platform/connectors/visible-types.ts+++ b/src/client/src/lib/platform/connectors/visible-types.ts@@ -9,6 +9,7 @@ export const VISIBLE_CONNECTOR_TYPES = ["mem0","memcode","zep",+ "langgraph","trustabl",] as const;