From c71b6b2451b4e3216e6bc1f1e1f83e577678bd54 Mon Sep 17 00:00:00 2001 From: Shivam Mittal Date: Sat, 3 Oct 2026 00:03:18 +0000 Subject: [PATCH] Fix LangGraph history source and local-state setup hints --- .../src/databricks_agentbricks/cli/memory.py | 4 +- .../databricks_agentbricks/cli/sessions.py | 4 +- .../ui/agent-langgraph/runtime/ui.py | 4 +- .../ui/agent-langgraph/tests/test_demo_ui.py | 4 +- .../templates/ui/agent-langgraph/ui/app.js | 42 +------------------ 5 files changed, 9 insertions(+), 49 deletions(-) diff --git a/integrations/agentbricks/src/databricks_agentbricks/cli/memory.py b/integrations/agentbricks/src/databricks_agentbricks/cli/memory.py index cefc0e3eb..8bf5d68ee 100644 --- a/integrations/agentbricks/src/databricks_agentbricks/cli/memory.py +++ b/integrations/agentbricks/src/databricks_agentbricks/cli/memory.py @@ -122,7 +122,7 @@ def memory_bind(obj, store: str, source: pathlib.Path) -> None: f"agentbricks memory stores create --name {store}", "Create the store now without deploying", ), - ("agentbricks dev", "Re-run to pick up the store locally"), + ("agentbricks dev", "Local development keeps long-term memory off"), ("agentbricks deploy ", "Create it if missing and grant the app access"), ], ) @@ -233,7 +233,7 @@ def stores_create(obj, display_name, description) -> None: (f"agentbricks memory stores get {store_id}", "View this store's details"), ( f"agentbricks memory bind {display_name}", - "Bind this store to the agent (wired in on dev/deploy)", + "Bind this store to the agent (used after deploy)", ), ], ) diff --git a/integrations/agentbricks/src/databricks_agentbricks/cli/sessions.py b/integrations/agentbricks/src/databricks_agentbricks/cli/sessions.py index 4a12e84af..d72509b93 100644 --- a/integrations/agentbricks/src/databricks_agentbricks/cli/sessions.py +++ b/integrations/agentbricks/src/databricks_agentbricks/cli/sessions.py @@ -88,7 +88,7 @@ def sessions_bind(obj, store: str, source: pathlib.Path) -> None: f"agentbricks sessions stores create --name {store}", "Create the store now without deploying", ), - ("agentbricks dev", "Re-run to pick up the store locally"), + ("agentbricks dev", "Local development keeps history in-process (lost on restart)"), ("agentbricks deploy ", "Create it if missing and grant the app access"), ], ) @@ -164,7 +164,7 @@ def stores_create(obj, name, description, metadata) -> None: (f"agentbricks sessions stores get {name}", "View this store's details"), ( f"agentbricks sessions bind {name}", - "Bind this store to the agent (wired in on dev/deploy)", + "Bind this store to the agent (used after deploy)", ), ], ) diff --git a/integrations/agentbricks/src/databricks_agentbricks/templates/ui/agent-langgraph/runtime/ui.py b/integrations/agentbricks/src/databricks_agentbricks/templates/ui/agent-langgraph/runtime/ui.py index 24ab29fb0..056bd12d5 100644 --- a/integrations/agentbricks/src/databricks_agentbricks/templates/ui/agent-langgraph/runtime/ui.py +++ b/integrations/agentbricks/src/databricks_agentbricks/templates/ui/agent-langgraph/runtime/ui.py @@ -520,7 +520,5 @@ async def append_session_items(request: Request, payload: SessionItemsRequest) - @app.get("/api/demo/session/items", include_in_schema=False) async def list_session_items(request: Request) -> dict: session_id = _request_session_id(request) - if _session_store(): - result = await _managed_call(_state_client().list_session_items, session_id) - return _chat_session_items(result) + # Managed session items contain checkpoints; the graph applies pending writes and reducers. return await _checkpoint_history(session_id, _request_actor(request)) diff --git a/integrations/agentbricks/src/databricks_agentbricks/templates/ui/agent-langgraph/tests/test_demo_ui.py b/integrations/agentbricks/src/databricks_agentbricks/templates/ui/agent-langgraph/tests/test_demo_ui.py index 7689d62ac..6db545b45 100644 --- a/integrations/agentbricks/src/databricks_agentbricks/templates/ui/agent-langgraph/tests/test_demo_ui.py +++ b/integrations/agentbricks/src/databricks_agentbricks/templates/ui/agent-langgraph/tests/test_demo_ui.py @@ -122,7 +122,7 @@ def _client(monkeypatch, *, configured=False, history=False, session_id="routing else: monkeypatch.delenv("AGENT_MEMORY_STORE", raising=False) monkeypatch.delenv("AGENT_SESSION_STORE", raising=False) - if history: + if history or configured: monkeypatch.setattr(ui, "_checkpoint_history", _session_history) # Keep model discovery deterministic and offline (no AI Gateway listing call). monkeypatch.setattr(ui, "_default_model", lambda: "system.ai.claude-sonnet-4-5") @@ -549,7 +549,7 @@ def test_managed_memory_and_session_routes(monkeypatch): assert [ item["data"]["content"] for item in client.get("/api/demo/session/items").json()["session_items"] - ] == ["s1", "saved reply"] + ] == ["s1", "checkpoint reply"] opened = client.post("/api/demo/sessions/s2/open") assert opened.json() == { diff --git a/integrations/agentbricks/src/databricks_agentbricks/templates/ui/agent-langgraph/ui/app.js b/integrations/agentbricks/src/databricks_agentbricks/templates/ui/agent-langgraph/ui/app.js index 6af362c9f..baad3927e 100644 --- a/integrations/agentbricks/src/databricks_agentbricks/templates/ui/agent-langgraph/ui/app.js +++ b/integrations/agentbricks/src/databricks_agentbricks/templates/ui/agent-langgraph/ui/app.js @@ -973,24 +973,6 @@ async function refreshSessionView({ hydrateChat = false } = {}) { await refreshSessions(); } -async function recordSessionItems(items) { - if (!state.config?.session.managed || !items.length) return; - try { - const sessionId = await ensureManagedSession(); - const response = await fetch(demoUrl("/api/demo/session/items"), { - method: "POST", - headers: { "Content-Type": "application/json", ...routingHeaders() }, - body: JSON.stringify({ items }), - }); - const result = await jsonResponse(response); - addEvent("session.items.append", result); - await refreshSessionView(); - } catch (error) { - stateMessage(elements.sessionItems, error instanceof Error ? error.message : String(error), "error"); - addEvent("session.error", { message: String(error) }); - } -} - async function invokeSync(payload) { const response = await fetch("/api/invocations", { method: "POST", @@ -1096,16 +1078,7 @@ async function sendText(text, mode = state.mode) { setBusy(true, mode === "background" ? "Starting background run" : mode === "streaming" ? "Streaming" : "Running"); try { await dispatch({ messages: [{ role: "user", content }] }, mode); - const items = [{ role: "user", content, transport: mode, instance_id: state.instanceId }]; - if (state.lastAssistantText) { - items.push({ - role: "assistant", - content: state.lastAssistantText, - transport: mode, - instance_id: state.instanceId, - }); - } - await recordSessionItems(items); + await refreshSessionView(); return state.lastAssistantText; } catch (error) { finishDraft(); @@ -1130,18 +1103,7 @@ async function resume(decision) { setBusy(true, "Resuming"); try { await dispatch(payload, "streaming"); - const items = [ - { role: "human_decision", content: decision, instance_id: state.instanceId }, - ]; - if (state.lastAssistantText) { - items.push({ - role: "assistant", - content: state.lastAssistantText, - transport: "streaming", - instance_id: state.instanceId, - }); - } - await recordSessionItems(items); + await refreshSessionView(); } catch (error) { appendError(error); } finally {