Self-improving AI Employees for everyone
Python ai-agentsai-employeeai-employeesassistantautonomous-agentsco-employeescompanygrok-botinstinctloop-agentsmuseown-your-datapersonalself-hosted
docs(context): align every reference with the plain conversation store
trohitg7bea8b3b3511
diff --git a/CLAUDE.md b/CLAUDE.mdindex 90d8ca6b..a6d9306e 100644--- a/CLAUDE.md+++ b/CLAUDE.md@@ -1386,15 +1386,19 @@ A new chat-model provider is one self-contained folder under `server/nodes/modelTwo different things, deliberately separated. Read [RFC-0002](./RFC-0002-AGENT-CONTEXT-AND-MEMORY.md) before touching either.-**Context** is the plain conversation store — what the agent actually sent and received, as JSON messages. One table (`agent_conversations`, [models/agent_context.py](./server/models/agent_context.py)) keyed by **`(workflow_id, generation, agent_node_id)`** → `messages` (MessageWire list) + `updated_at`; the service is four functions in [`services/agent_context/conversation.py`](./server/services/agent_context/conversation.py) (`load_conversation` / `save_conversation` (per-key lock, whole-list upsert, post-commit notify) / `clear_conversation` / `list_conversations`). Every firing of an agent — chat message or taskTrigger review — loads the row at run start and saves the live message list back per turn, so the one conversation continues across firings; Reset admits a new generation = new key = fresh conversation (old rows stay as inert history until workflow delete). The `context` node (`server/nodes/context/`, `input-context` handle) is the **opt-in switch and viewing panel**, nothing more — it declares no parameters. This is the LangGraph `thread_id` / OpenAI `conversation_id` pattern; the previous hash-chained journal (threads, epochs, checkpoints, blobs, provider bindings, session/task/execution thread routing) is deleted.+**Context** is the plain conversation store — what the agent actually sent and received, as JSON messages. One table (`agent_conversations`, [models/agent_context.py](./server/models/agent_context.py)) keyed by **`(workflow_id, generation, agent_node_id)`** → `messages` (MessageWire list) + `updated_at`; the service is four functions in [`services/agent_context/conversation.py`](./server/services/agent_context/conversation.py) (`load_conversation` / `save_conversation` (per-key lock, whole-list upsert, post-commit notify) / `clear_conversation` / `list_conversations`). Every firing of an agent — chat message or taskTrigger review — loads the row at run start and saves the live message list back per turn, so the one conversation continues across firings; Reset admits a new generation = new key = fresh conversation, AND the Context node's `reset_execution_state` clears the workflow's stored rows + fences warm claude subprocesses + broadcasts `context.updated` — the generation bump alone is not enough because the panel shows the newest STORED generation, so surviving rows would render the pre-Reset conversation as the live context and Reset would look like a no-op. (A plain Stop→Start leaves prior generations as inert, non-browsable history until workflow delete or Reset.) The `context` node (`server/nodes/context/`, `input-context` handle) is the **opt-in switch and viewing panel**, nothing more — it declares no parameters. This is the LangGraph `thread_id` / OpenAI `conversation_id` pattern; the previous hash-chained journal (threads, epochs, checkpoints, blobs, provider bindings, session/task/execution thread routing) is deleted.Load-bearing invariants, learned the hard way: (1) *attaching a Context node must never change what the agent sends* — requests are always built from `messages`; `conversation_key` only says where to save. (2) *The store records what was sent, after it was sent* — `agent.execute_llm_step` saves `[...sent, assistant]` immediately after `ChatUnifier.chat` returns; nothing writes before a request exists (the retired `prepare_context` activity did, and journalled fabricated requests). (3) **Loads are LOUD, saves are best-effort** — `agent.prepare_payload` raises `ApplicationError("ConversationLoadFailed")` (retryable) / `ApplicationError("ConversationTooLarge")` (non-retryable, 1 MB cap) rather than silently running an amnesiac agent that burns tokens on an empty prompt; the save runs post-billing and swallows failures with a WARN. (4) Seeding precedence is **carried rollover transcript > stored conversation > bare build** — a `continue_as_new` resume carries the live transcript in its resume marker (size-guarded ≤ 1 MB) and must win over the store. Locked by `tests/temporal/test_agent_workflow.py::TestConversationIdentity`.Both paths implement the same contract: Temporal via `prepare_agent_payload` (load) + `_save_conversation` in the LLM activity; in-process via `AIService._prepare_context` → `_AgentContextRuntime{key, history, database}` + the loop's `conversation_saver=runtime.save` hook. Specialized providers (claude_code / codex / rlm / vertex) use `SpecializedAgentContextBridge` ([services/cli_agent/context_bridge.py](./server/services/cli_agent/context_bridge.py)): `resolve` loads, `augment_prompt` renders the transcript into the prompt, `record_turn(original_prompt, response)` saves — always the ORIGINAL prompt, never the augmented one, or the save nests the transcript inside itself. The claude pool key is the conversation key (`(workflow_id, agent_node_id, generation)`), so a Reset's generation bump fences warm subprocesses at `acquire`; a same-generation panel Clear calls `ClaudeSessionPool.terminate_conversations`. Manual canvas Runs persist nothing (`generation > 0` gate — only Start admits a generation).-**Live viewing is emitted at the persistence boundary, not per caller.** `save_conversation` is the one place every writer passes through, and it announces durable saves through the fanout registry in [`services/agent_context/listeners.py`](./server/services/agent_context/listeners.py) — `register_conversation_listener` / `notify_conversation_saved` — with `nodes/context/__init__.py` registering the broadcaster. Same shape as the plugin registries, same reason: the store must never import `nodes/`. The notification fires after the commit, and a listener can never fail a save. The single Context event (`context.updated`) **broadcasts directly via `get_status_broadcaster()`, not through `services.events.dispatch.emit`** — no canary consumer exists for `com.opencompany.context.*`, so `emit`'s Visibility query would match nothing once per save. Payload is identity + count only; the panel refetches through the authorized `get_agent_context` WS handler (`clear_agent_context` is the other handler; the journal-era fork/export handlers are gone). One `case 'context.updated'` in `WebSocketContext.tsx` invalidates `['agentContext']`; the panel contains no subscription code. See [event_framework.md → UI-only lifecycle events](./docs-internal/event_framework.md).+**Live viewing is emitted at the persistence boundary, not per caller.** `save_conversation` is the one place every writer passes through, and it announces durable saves through the fanout registry in [`services/agent_context/listeners.py`](./server/services/agent_context/listeners.py) — `register_conversation_listener` / `notify_conversation_saved` — with `nodes/context/__init__.py` registering the broadcaster. Same shape as the plugin registries, same reason: the store must never import `nodes/`. The notification fires after the commit, and a listener can never fail a save (failures log at WARNING — a silently failing listener is exactly how "the panel never updates live" becomes undiagnosable). The single Context event (`context.updated`) **broadcasts directly via `get_status_broadcaster()`, not through `services.events.dispatch.emit`** — no canary consumer exists for `com.opencompany.context.*`, so `emit`'s Visibility query would match nothing once per save. Payload is identity + count only; the panel refetches through the authorized `get_agent_context` WS handler (`clear_agent_context` is the other handler; the journal-era fork/export handlers are gone). One `case 'context.updated'` in `WebSocketContext.tsx` invalidates `['agentContext']`; the panel contains no subscription code. See [event_framework.md → UI-only lifecycle events](./docs-internal/event_framework.md).-**Memory** (`simpleMemory`, plugin `server/nodes/tool/simple_memory/`) is a `ToolNode` on `input-tools` — durable facts the agent explicitly remembers, recalls, updates and forgets. It is not conversation history and has no markdown surface; `SimpleMemoryParams` declares only `reset_policy` (with `extra="ignore"`, so leftover legacy keys on migrated graphs are inert). `reset_policy` is in `server_controlled_fields`, which stops the **model** overriding it through tool arguments — it does not stop the operator editing it.+**The store also stamps timestamps.** `save_conversation` attaches a `ts` (UTC ISO) to every stored message: callers regenerate wires from live `Message` objects each turn, so the store keeps the original stamp for the unchanged prefix and stamps only the appended turn — a message's time is when it first persisted, not when the conversation last saved. `ts` is a stored-view field only; `message_from_wire` ignores it, so it never reaches a provider on any path.++**Compaction never touches the system prompt, and its summary rides a USER message.** The AgentWorkflow's threshold compaction swaps `messages` for `[original system (verbatim), user(summary + current request)]`. The system prompt is the agent's byte-stable contract (prompt caching, behavioral consistency), and the seeding filter drops stored system messages — so a summary stored under the system role (the earlier design) silently vanished on the next firing while the noisy tool tail survived it. Prior tool calls/results are dropped at the swap and live only inside the summary; tool messages after the summary in the panel are new post-compaction work (their `ts` postdates it). Trigger, swap (before→after counts), and summarizer usage all log at INFO. Locked in `tests/temporal/test_agent_workflow.py`. See [agent_context_flow.md → Compaction](./docs-internal/agent_context_flow.md).++**Memory** (node type `simpleMemory`, displayed as **"Memory"** — the wire type is stored verbatim in graphs/pool keys and must not be renamed; plugin `server/nodes/tool/simple_memory/`) is a `ToolNode` on `input-tools` — durable facts the agent explicitly remembers, recalls, updates and forgets. It is not conversation history and has no markdown surface; `SimpleMemoryParams` declares only `reset_policy` (with `extra="ignore"`, so leftover legacy keys on migrated graphs are inert). `reset_policy` is in `server_controlled_fields`, which stops the **model** overriding it through tool arguments — it does not stop the operator editing it. Two model-facing contracts are load-bearing: (1) the `tool_description` ClassVar is imperative — *check memory (recall/list) before answering anything about the user; never claim ignorance without checking* — because with a passive "store and retrieve when useful" wording, models answered "I don't know who you are" from priors while the user's name sat one recall away (`tool_schema_locked = True` pins this description against stale ToolSchema rows). (2) Every durable mutation (remember/update/forget/clear, from the agent tool call or the panel) broadcasts the identity-only `memory.updated` CloudEvent ([`_events.py`](./server/nodes/tool/simple_memory/_events.py), same direct-broadcast rationale as `context.updated`), which `WebSocketContext.tsx` routes to invalidate the `memoryItems`/`memoryItem` queries.Lifecycle helpers live in `server/services/memory/`; token tracking and compaction thresholds are in **[Memory Compaction](./docs-internal/memory_compaction.md)**. **[Memory Lifecycle](./docs-internal/memory_lifecycle.md)** still documents the pre-RFC-0002 markdown model and is stale.@@ -2780,5 +2784,7 @@ This function:- **Multi-vendor nodes: one node, a `provider` dropdown, two registries.** `nodes/speech/` is the reference and the first multi-credential plugin in the repo (`credentials = (A, B, C)`; `ctx.connection(id)` is a dict lookup over that tuple). Four load-bearing rules. (1) **Imperative `@Operation` only** — the declarative `routing=` path resolves `credentials[0]` (`base.py:571`), so a routed op authenticates every provider with the first key in the tuple and `test_plugin_contract.py` would not catch it. (2) **Registry membership IS the capability** — one registry per direction, the node's provider enum literally *is* `tts_providers()`, so a synthesis-only vendor cannot be selected for transcription and there is no `supports_x` flag to keep honest. (3) **Capabilities live in JSON** (`server/config/speech_defaults.json`), per-model overrides resolved exact -> longest-prefix -> `_default`, boolean flags defaulting **permissive**; no shared code branches on a vendor name. (4) **Vendor divergence stays in the vendor module** — auth scheme, query-vs-body, response shape. The v1 set diverges on all three axes and three of those divergences fail *silently* (ElevenLabs ignores a body-placed `output_format`, Deepgram ignores body options entirely, Sarvam returns a base64 array), so each has a test asserting the outgoing request rather than the parsed result. Full reference: **[Speech Provider RFC](./docs-internal/speech_provider_rfc.md)** + [plugin_system.md -> Multi-credential nodes](./docs-internal/plugin_system.md#multi-credential-nodes).- **Never name a Params field `model` or `api_key` on a node that also has a `provider` field.** An effect at [`ParameterRenderer.tsx:866`](./client/src/components/ParameterRenderer.tsx#L866) keys on those two literal names: with a sibling `provider` field present it overwrites `model` with the *chat-model* list and clears `api_key` — and it never validates that the provider is an LLM provider, so `provider: "elevenlabs"` still triggers it and the field is wiped the moment the user picks a vendor. Line 930 also writes options onto the literal string `'model'`, not `parameter.name`. Prefix instead (`tts_model` / `stt_model`), locked by a test in `tests/nodes/test_speech.py`. Other reserved sibling names with name-based magic in that file: `parameters`, `message_type`, `group_id`, `group_name`, `channel_jid`, `sender_number`, `sender_name`, `session_id`, `service_id`, `action`.- **`usable_as_tool = True` auto-hides both canvas handles.** `base.py:215` sets `hide_input_handle` / `hide_output_handle` to `True` unless the class declares them, so a dual-purpose node that must stay wirable has to declare both `False` explicitly. Symptom: the node works fine as an AI tool but cannot be connected to anything on the canvas.+- **Temporal LLM tool calls carry unmerged `tool_args`, and ToolNodes take `execute_as_tool`.** The AgentWorkflow schedules each tool call as the tool's own per-type activity; the payload carries BOTH the merged `node_data` (legacy/dual-purpose contract) AND the model's raw arguments as `tool_args`, forwarded through `as_activity`'s extras into the legacy handler, which routes ToolNodes through `execute_as_tool` for real `ToolInput` validation. Without this, the merged dict validated against `Params` (`extra="ignore"`) and a split-schema tool's model arguments were silently DROPPED — every Simple Memory `remember` degraded to a harmless `list`, reported success, and stored nothing. Dual-purpose ActionNodes deliberately keep their documented merged-params behavior. Locked by `tests/nodes/test_tool_call_dispatch.py` (including an end-to-end store assertion). Related guard: a function-local `import` makes its name local for the WHOLE function, so any use above it raises `UnboundLocalError` at runtime that `py_compile` cannot catch — a mid-function `import json` below the conversation size guard failed every Context-connected run this way (AST-locked in `test_agent_workflow.py`).+- **Inspection panels opt out of the global `refetchOnMount: false`.** The QueryClient default ("trust the cache; the broadcast bridge keeps it in sync") assumes an active observer exists when the invalidation lands — but Context/Memory data mutates while those panels are CLOSED, so the broadcast invalidates a query nobody observes and a later mount renders stale cache until a manual Refresh. `ContextPanel` and `MemoryToolPanel` therefore declare `refetchOnMount: 'always', staleTime: 0`; the `context.updated` / `memory.updated` broadcasts cover the panel-open case. Apply the same override to any future panel whose data is written by agent runs rather than by the panel itself.- **Media leaves a node as a reference, never as bytes.** `services/media/` + `FileRef` (~400 B, `extra="forbid"`) with `AudioRef(FileRef)` as the probed-container narrowing — set `kind="audio"` only when the duration actually came from `inspect_audio`, because a fabricated one silently mis-bills per-second providers; the `gallery` node therefore emits `kind="file"` even for a `.wav`. A node result is persisted 3x, broadcast 2x, retained in `_status` forever, aggregated into the workflow result, copied into every downstream activity *input*, and — if `usable_as_tool` — serialized into an LLM message; a 12 MB base64 payload therefore fails the activity, **retries 3x re-billing the provider each time**, and reports a generic error. Nodes call `write_audio` (out) and `coerce_file_param` (in); both enforce containment through `resolve_within`, which closed a live traversal that let `audio_file="../../credentials.db"` read the encrypted credential store and upload it. **id/slug trap:** workspace dirs are named by the mutable `Workflow.slug` while a ref stores the immutable `workflow_id` so refs survive rename — `workspace_root()` raises rather than composing a wrong path, and the lookup now lives in `services/workspace_locator.py`, which every database-holding caller delegates to (the HTTP route, the gallery WS handlers, `WorkflowService`). Reads may fall back to the anonymous `"default"` workspace; **mutating callers must pass `allow_default=False`**, or a stale tab's unresolvable id destroys files in a different context than the caller believes. Full reference: **[Media Transport](./docs-internal/media_transport.md)**.- never use emojis in printsdiff --git a/RFC-0002-AGENT-CONTEXT-AND-MEMORY.md b/RFC-0002-AGENT-CONTEXT-AND-MEMORY.mdindex c3793b20..b02cc7db 100644--- a/RFC-0002-AGENT-CONTEXT-AND-MEMORY.md+++ b/RFC-0002-AGENT-CONTEXT-AND-MEMORY.md@@ -1,9 +1,24 @@# RFC-0002 — Agent Context V2 and Tool-Based Memory-Status: Implementing+Status: Partly superseded (August 2026)Graph version: 2Compatibility boundary: new workflow generations only+> ## ⚠ Context implementation superseded+>+> The Context/Memory **separation** this RFC argues for stands, and the+> Memory sections remain accurate. But the Context *implementation* it+> specifies — the append-only journal with threads, epochs, hash-chained+> events, checkpoints, blobs, provider bindings, and session > task >+> execution thread resolution — was replaced in August 2026 by the **plain+> conversation store**: one `agent_conversations` row per+> `(workflow_id, generation, agent_node_id)` → messages JSON, loaded at run+> start and saved per turn. There are no threads, epochs, or operation ids+> to resolve; every firing of an agent continues the one conversation.+> **[docs-internal/agent_context_flow.md](./docs-internal/agent_context_flow.md)+> is the normative Context reference.** Sections below describing the+> journal are historical rationale, not the running system.+## 1. SummaryOpenCompany separates two concepts that were previously conflated:diff --git a/docs-internal/TEMPORAL_ARCHITECTURE.md b/docs-internal/TEMPORAL_ARCHITECTURE.mdindex 82e9d2f1..9dcbfd83 100644--- a/docs-internal/TEMPORAL_ARCHITECTURE.md+++ b/docs-internal/TEMPORAL_ARCHITECTURE.md@@ -457,23 +457,22 @@ The other nine support skills and durable delegation:| `agent.finish_delegation` | Idempotently records a delegated child's terminal result and usage. || `agent.finalize_team` | Finalizes a team after its required tasks reach accepted or terminal states. |-The Context journal surface adds `agent.prepare_context` (resolves the thread;-journals nothing, because it runs before the request exists),-`agent.reconstruct_context_messages`, `agent.append_context` and-`agent.compact_context`.--**`agent.reconstruct_context_messages` is the only place the journal is read-back on the execution path.** `AgentWorkflow` rolls over under history pressure-*only when `context_ref` is set*, and a rollover carries references rather than-the conversation — so without a replay step, attaching a Context node is what-makes a long run silently forget everything it had said. The resumed run calls-this activity before its first LLM step and seeds `messages` from the result. It-degrades rather than raising: an opaque provider checkpoint or an unreadable-thread returns `restored: False` with a reason and the run continues from the-rebuilt system + memory + prompt, since a rehydration miss must not turn an-unreadable thread into a dead agent. This does **not** weaken the rule that the-request is always built from `messages` — nothing reconstructs mid-loop, only at-the rollover boundary.+**Context needs no dedicated activities.** The plain conversation store+(see [agent_context_flow.md](./agent_context_flow.md)) rides the existing+pipeline: `agent.prepare_payload` loads the stored conversation for+`(workflow_id, generation, agent_node_id)` and returns it with the+`conversation_key` (load failures are LOUD — `ConversationLoadFailed`+retryable / `ConversationTooLarge` non-retryable at 1 MB), and+`agent.execute_llm_step` saves `[...sent, assistant]` best-effort after each+provider call. A continue-as-new rollover carries the live transcript in its+resume marker, so nothing reconstructs from the store mid-run. The+journal-era activities (`agent.prepare_context`,+`agent.reconstruct_context_messages`, `agent.append_context`) are retired;+`agent.compact_context` (the shared client-side summarizer that bounds the+carried transcript) remains.+Tool calls scheduled by the workflow carry the model's unmerged `tool_args`+in the per-type activity payload so ToolNodes validate against their+`ToolInput` via `execute_as_tool` (see `tests/nodes/test_tool_call_dispatch.py`).The F4.B compaction threshold is prepared from the model context length andthe ratio configuration. It currently does not readdiff --git a/docs-internal/agent_context_flow.md b/docs-internal/agent_context_flow.mdindex ebeafa80..04c6e66e 100644--- a/docs-internal/agent_context_flow.md+++ b/docs-internal/agent_context_flow.md@@ -35,7 +35,7 @@ remember/recall — and plays no automatic part in continuity.| Function | Contract ||---|---|| `load_conversation(db, *, workflow_id, generation, agent_node_id) → List[Dict]` | The stored wires, `[]` when the key has no row. |-| `save_conversation(db, *, …, messages)` | Whole-list upsert under a per-key asyncio lock; notifies listeners **after** the commit. |+| `save_conversation(db, *, …, messages)` | Whole-list upsert under a per-key asyncio lock; stamps each message with a `ts` (UTC ISO — kept for the unchanged prefix, minted for the appended turn, view-only: `message_from_wire` ignores it); notifies listeners **after** the commit. || `clear_conversation(db, *, workflow_id, generation=None, agent_node_id=None) → int` | Deletes rows, optionally narrowed; returns the count. || `list_conversations(db, *, workflow_id)` | Panel metadata (`generation`, `agent_node_id`, `message_count`, `updated_at`), newest generation first. |@@ -105,7 +105,32 @@ The carried transcript caps at ~1 MB serialized2 MiB for the whole continue-as-new argument; over-cap degrades to theopening prompt with a warning — never a failure.-## Loading is loud; saving is best-effort+## Compaction: one system prompt, summary as a user message++When the loop's token total crosses the threshold, `agent.compact_context`+summarizes the live transcript and the workflow swaps `messages` for+`[original system (verbatim), user("## Compacted conversation summary" ++summary + current request)]`. Two rules are load-bearing (locked by+`TestConversationIdentity::test_compaction_preserves_the_system_prompt_and_summary_survival`):++- **The system prompt is never modified or duplicated.** It is the agent's+ contract (personality + tool/delegation guidance) and must stay+ byte-stable — for provider prompt caching, and because the next firing's+ seeding drops stored system messages so policy changes take effect.+ Anything compaction stores under the system role therefore silently+ vanishes on the next firing; that is exactly how an earlier+ second-system-message design lost the summary on the next chat message+ while the noisy tool tail (non-system) outlived it.+- **The summary rides a user message**, so the compacted knowledge persists+ through seeding and crosses firings with the conversation it summarizes.++Prior tool calls/results are dropped from the live list at the swap — they+survive only inside the summary text. Tool messages that appear *after* the+summary in the panel are **new work the agent did post-compaction**, not+survivors (their `ts` stamps postdate the summary). Both the trigger+(`tokens >= threshold`, live message count) and the applied swap (before →+after counts, summary size) log at INFO, as does the activity (rendered+chars in, summary chars + summarizer usage out).- **Load failures raise.** `agent.prepare_payload` raises`ApplicationError("ConversationLoadFailed")` (retryable) when the row@@ -141,17 +166,35 @@ time, and a same-generation panel Clear terminates them explicitly## The Context node and panel`nodes/context/` owns the opt-in descriptor (`_descriptor.py`), two WS-handlers (`get_agent_context` returns+handlers (`get_agent_context` returns the **live generation only** —`{conversations, generation, agent_node_id, updated_at, message_count,-messages}`; `clear_agent_context` deletes rows and fences warm claude+messages}`, with an `agent_node_id` selector for nodes shared by several+agents; `clear_agent_context` deletes rows and fences warm claudeprocesses), and one CloudEvents broadcast (`context.updated`, fired from theregistered save listener; payload is identity + count only — the panelrefetches through the authorized handler). The node declares **no-parameters**; the connection is the whole configuration. Reset rotates-nothing: the new generation's key is simply empty, and prior generations-remain readable history until the workflow is deleted (which clears every-row via the existing archive-outbox drain in-`services/workflow_storage/handlers.py`).+parameters**; the connection is the whole configuration.++The panel ([`ContextPanel.tsx`](../client/src/components/parameterPanel/ContextPanel.tsx))+renders role-tinted message cards with per-message `ts` timestamps, routes+JSON-shaped payloads (tool calls, tool results) through the themed JSON+tree on the per-theme `--code-*` surface, and offers a **Raw** tab showing+the stored wires verbatim. It declares `refetchOnMount: 'always'` because+the app's global `refetchOnMount: false` default would render stale cache+when the panel opens after a run that mutated the conversation while no+observer was mounted.++**Reset wipes.** `AgentContextNode.reset_execution_state` clears every+stored conversation for the workflow, terminates warm claude subprocesses+holding the wiped transcript, and broadcasts `context.updated` so open+panels refresh. The generation bump alone is NOT enough: the panel shows+the newest STORED generation, so surviving rows would keep rendering the+pre-Reset conversation as the live context and Reset would look like a+no-op. A plain Stop → Start (new generation without Reset) leaves prior+rows in the store as inert history — deliberately **not browsable from+the panel**, which shows only the agent's current context — until the+workflow is deleted (the archive-outbox drain in+`services/workflow_storage/handlers.py`) or Reset runs.## Invariants (do not break)@@ -162,7 +205,7 @@ row via the existing archive-outbox drain in| 3 | Seeding precedence: carried transcript > stored conversation > bare build. | Rollover mid-run truth beats the store; the store beats cold start. || 4 | Load failures are LOUD (`ConversationLoadFailed` / `ConversationTooLarge`); save failures are best-effort. | Never burn tokens on an amnesiac prompt; never fail a billed turn over bookkeeping. || 5 | Save the exact sent list, after the provider call. Nothing writes to the store before a request exists. | The journal's `prepare_context` wrote fabricated requests assembled from configuration. |-| 6 | Reset = new generation = new key. No epoch machinery; old rows are inert history. | Reset must be a real reset, with zero lifecycle choreography to miss. |+| 6 | Reset = new generation = new key, AND the Context node's reset hook clears the workflow's stored rows. | The panel shows the newest stored generation, so surviving rows make Reset look like a no-op. || 7 | `input-memory` is retired; the conversation store is the continuity carrier. Do not resurrect markdown seeding. | `normalize_workflow_graph` migrates it away and the validator rejects it; two carriers would drift. || 8 | Specialized bridges record the ORIGINAL prompt, never the augmented one. | Recording the rendered transcript nests the conversation inside itself and grows without bound. || 9 | The store never imports `nodes/`; the plugin registers its broadcaster via `register_conversation_listener`, and a listener failure can never fail a save. | Same layering rule as every plugin registry; a UI notification must not break execution. |diff --git a/docs-internal/event_framework.md b/docs-internal/event_framework.mdindex 1dee2654..d327f7ec 100644--- a/docs-internal/event_framework.md+++ b/docs-internal/event_framework.md@@ -232,9 +232,10 @@ See RFC §6.4 for the classification rule + the canonicalin-process as a side effect. That query is only worth paying for when some nodetype registered the event via `register_canary_trigger_type`.-The Context lifecycle events (`context.updated` / `context.compacted` /-`context.epoch.started`, in `nodes/context/_events.py`) have no canary consumer,-so the query is guaranteed to match nothing — once per journal append. They call+The Context conversation event (`context.updated`, in+`nodes/context/_events.py`) and the Memory mutation event (`memory.updated`,+in `nodes/tool/simple_memory/_events.py`) have no canary consumer, so the+query is guaranteed to match nothing — once per save/mutation. They call`get_status_broadcaster().broadcast({...})` directly instead, which is the samepattern `nodes/telegram/_events.py` uses for status. The CloudEvents envelope,`source`, `type`, `subject` and `data` are identical either way, so the wire@@ -248,39 +249,37 @@ the reasoning without tripping the assertion).### Context events are emitted at the persistence boundary-`AgentContextStore` is the one place every Context writer passes through — the-in-process agent loop, the Temporal LLM activity, and the CLI-agent bridge all-reach durable state through it. So the "thread advanced" notification is emitted-there rather than at each call site, via a fanout registry in+`save_conversation` (`services/agent_context/conversation.py`) is the one+place every Context writer passes through — the in-process agent loop, the+Temporal LLM activity, and the specialized-provider bridge all persist+through it. So the "conversation advanced" notification is emitted there+rather than at each call site, via a fanout registry in`services/agent_context/listeners.py`:```python-register_context_commit_listener(async_fn) # nodes/context/__init__.py-await notify_context_commit(ref, provider=..., active_token_count=..., sequence=...)+register_conversation_listener(async_fn) # nodes/context/__init__.py+await notify_conversation_saved(workflow_id=..., generation=..., agent_node_id=..., message_count=...)```Same shape as the plugin registries in `plugin_system.md`, and for the samereason: the store must never import `nodes/`. A new writer gets live updates forfree, and no caller carries broadcast code.-Three properties are load-bearing and have tests in-`tests/services/agent_context/test_commit_listeners.py`:--- **After commit, after reload.** The notification carries the post-commit- revision and can never be observed ahead of the state it describes.-- **Replays emit nothing.** `append_transition` returns early on a reused- `operation_id` without committing; broadcasting there would wake every open- panel for something that did not happen.-- **A listener can never fail a commit.** `notify_context_commit` swallows and- logs. These commits run inside the Temporal LLM activity's post-send window,- which is heartbeat-silent under a 60 s `heartbeat_timeout` on a- `maximum_attempts=1` retry policy — a throwing or slow listener there would- fail a run over a UI notification.--Epoch rotation is deliberately **not** routed through the store listener:-`start_epoch`'s callers already emit `context.epoch.started` with a `reason`-(`clear` / `fork` / `workflow_reset`) the store cannot know, so emitting from-the store would both duplicate the broadcast and lose the reason.+Two properties are load-bearing and have tests in+`tests/services/agent_context/test_conversation.py`:++- **After commit.** The notification fires only after the durable upsert, so+ it can never be observed ahead of the state it describes.+- **A listener can never fail a save.** `notify_conversation_saved` swallows+ and logs at WARNING (visible at the default log level — a silently failing+ listener is how "the panel never updates live" becomes undiagnosable).+ Saves run inside the Temporal LLM activity's post-send window, after the+ provider has been called and billed — a throwing listener there would fail+ a run over a UI notification.++Clears are deliberately **not** routed through the store listener: the+clear handler and the Context node's Reset hook dispatch `context.updated`+themselves (a delete is not a save, and only the caller knows it happened).## Verificationdiff --git a/docs-internal/memory_lifecycle.md b/docs-internal/memory_lifecycle.mdindex bea03818..807b6aea 100644--- a/docs-internal/memory_lifecycle.md+++ b/docs-internal/memory_lifecycle.md@@ -5,9 +5,13 @@> This document describes the pre-RFC-0002 model, in which `simpleMemory` hung> off an agent's `input-memory` handle and held the conversation transcript as> Markdown. **That model no longer exists.** Conversation state is now the-> backend-owned Context journal (`server/nodes/context/`, `input-context`), and-> `simpleMemory` is a `ToolNode` on `input-tools` holding durable facts the-> agent explicitly remembers — it has no transcript and no markdown surface.+> plain conversation store (`agent_conversations`, keyed by+> `(workflow_id, generation, agent_node_id)` — see+> [agent_context_flow.md](./agent_context_flow.md); the intermediate+> "Context journal" described in RFC-0002 was itself replaced), and+> `simpleMemory` (displayed as "Memory") is a `ToolNode` on `input-tools`+> holding durable facts the agent explicitly remembers — it has no+> transcript and no markdown surface.>> **Still accurate here:** §2 (the `services/memory/` markdown + JSONL helper> API), §3 (`services.memory` canonicality, `append_memory_turns_atomic`), §4diff --git a/docs-internal/node-logic-flows/README.md b/docs-internal/node-logic-flows/README.mdindex bd5b8651..9108c0f7 100644--- a/docs-internal/node-logic-flows/README.md+++ b/docs-internal/node-logic-flows/README.md@@ -34,7 +34,8 @@ match its doc here, and each doc must still describe what the code does.- [AI Agent (`aiAgent`)](./ai_agents/aiAgent.md)- [Zeenie (`chatAgent`)](./ai_agents/chatAgent.md)-- [Simple Memory (`simpleMemory`)](./ai_agents/simpleMemory.md)+- [Memory (`simpleMemory`)](./ai_agents/simpleMemory.md)+- [Context (`context`)](./ai_agents/context.md)### ai_chat_modelsdiff --git a/docs-internal/node-logic-flows/ai_agents/context.md b/docs-internal/node-logic-flows/ai_agents/context.mdnew file mode 100644index 00000000..2bde0f4e--- /dev/null+++ b/docs-internal/node-logic-flows/ai_agents/context.md@@ -0,0 +1,80 @@+# Context (`context`)++| Field | Value |+|------|-------|+| **Category** | memory (config node on `input-context`) |+| **Backend handler** | [`server/nodes/context/__init__.py::AgentContextNode`](../../../server/nodes/context/__init__.py) |+| **Tests** | [`server/tests/nodes/test_agent_context_node.py`](../../../server/tests/nodes/test_agent_context_node.py), [`server/tests/nodes/test_context_handlers.py`](../../../server/tests/nodes/test_context_handlers.py), [`server/tests/services/agent_context/test_conversation.py`](../../../server/tests/services/agent_context/test_conversation.py) |+| **Skill (if any)** | - |+| **Dual-purpose tool** | no |++## Purpose++The opt-in switch and viewing panel for durable agent conversation.+Connecting `output-context` to an agent's `input-context` handle opts the+agent into the plain conversation store: one `agent_conversations` row per+`(workflow_id, generation, agent_node_id)`, loaded at run start and saved+per turn, so every firing (chat messages AND taskTrigger reviews) continues+one conversation. The node carries no runtime state and declares **no+parameters** — the connection is the whole configuration. Normative+reference: [agent_context_flow.md](../../agent_context_flow.md).++## Inputs (handles)++| Handle | Connection type | Required | Purpose |+|--------|-----------------|----------|---------|+| `output-context` → agent `input-context` | context | yes | Opts the agent into conversation persistence |++## Parameters++None (`AgentContextParams` is empty, `extra="forbid"`).++## Behavior++- **Descriptor** ([`_descriptor.py`](../../../server/nodes/context/_descriptor.py)):+ registered via `register_agent_context_builder`; emits `kind: "context"` ++ workflow/generation identity. Returns `None` for `generation <= 0`+ (manual canvas Runs persist nothing — only Start admits a generation).+- **Persistence** rides the agent pipeline, not this node:+ `agent.prepare_payload` loads (LOUD failures — `ConversationLoadFailed`+ retryable / `ConversationTooLarge` non-retryable at 1 MB),+ `agent.execute_llm_step` saves per turn best-effort; in-process via+ `_AgentContextRuntime` + the loop's `conversation_saver`; specialized+ providers via `SpecializedAgentContextBridge`.+- **Panel** (`isContextPanel` uiHint →+ [`ContextPanel.tsx`](../../../client/src/components/parameterPanel/ContextPanel.tsx)):+ shows the **live generation only** — role-tinted cards with per-message+ `ts` timestamps, themed JSON trees for tool payloads, a Raw tab with the+ stored wires verbatim, and an agent selector when several agents share+ the node. `refetchOnMount: 'always'`.+- **WS handlers** ([`_handlers.py`](../../../server/nodes/context/_handlers.py)):+ `get_agent_context` (live generation, ownership-authorized),+ `clear_agent_context` (narrowable delete + warm-claude fence ++ `context.updated` broadcast).+- **Workflow Reset**: `reset_execution_state` clears ALL of the workflow's+ stored conversations, terminates warm claude subprocesses, and broadcasts+ `context.updated` — the generation bump alone would leave the panel+ rendering the pre-Reset conversation as live.+- **Events**: one identity-only CloudEvent, `context.updated`+ ([`_events.py`](../../../server/nodes/context/_events.py)), fired from+ the store's save listener (`register_conversation_listener`); the+ frontend invalidates `['agentContext']`.++## Edge cases & known limits++- Two agents on one Context node keep separate conversations (the key is+ per agent node); the panel offers a selector.+- A plain Stop → Start starts a fresh conversation (new generation) and+ leaves prior rows as inert, non-browsable history until Reset or+ workflow delete.+- Attaching a Context node must never change what the agent sends —+ requests always build from `messages`; the key only says where to save+ (the original `context_ref` regression, locked by+ `tests/temporal/test_agent_workflow.py::TestConversationIdentity`).++## Related++- **Sibling**: `simpleMemory` ("Memory") — explicit durable facts, not+ conversation history.+- **Architecture docs**: [agent_context_flow.md](../../agent_context_flow.md),+ [TEMPORAL_ARCHITECTURE.md](../../TEMPORAL_ARCHITECTURE.md).diff --git a/docs-internal/node-logic-flows/ai_agents/simpleMemory.md b/docs-internal/node-logic-flows/ai_agents/simpleMemory.mdindex 553ec567..17de196e 100644--- a/docs-internal/node-logic-flows/ai_agents/simpleMemory.md+++ b/docs-internal/node-logic-flows/ai_agents/simpleMemory.md@@ -1,210 +1,102 @@-# Simple Memory (`simpleMemory`)+# Memory (`simpleMemory`)| Field | Value ||------|-------|-| **Category** | ai_agents / memory (group: `('tool', 'memory')`, `component_kind = "model"`) |-| **Backend handler** | [`server/nodes/skill/simple_memory/__init__.py`](../../../server/nodes/skill/simple_memory/__init__.py) — dispatched via `BaseNode.execute()` + the `@Operation("read")` method (`read`). Agent-side consumption via [`edge_walker.py::collect_agent_connections`](../../../server/services/plugin/edge_walker.py) / `_build_memory_entry`. |-| **Tests** | [`server/tests/nodes/test_ai_agents.py`](../../../server/tests/nodes/test_ai_agents.py) |-| **Skill (if any)** | n/a |-| **Dual-purpose tool** | no |+| **Category** | tool / memory (config node on `input-tools`) |+| **Backend handler** | [`server/nodes/tool/simple_memory/__init__.py::SimpleMemoryNode.memory`](../../../server/nodes/tool/simple_memory/__init__.py) |+| **Tests** | [`server/tests/services/memory/test_tool_store.py`](../../../server/tests/services/memory/test_tool_store.py), [`server/tests/nodes/test_tool_call_dispatch.py`](../../../server/tests/nodes/test_tool_call_dispatch.py) |+| **Skill (if any)** | - |+| **Dual-purpose tool** | ToolNode only — tool name `memory` |++> The wire type stays `simpleMemory` (stored verbatim in graphs, claude pool+> keys and migrations); only the display name is "Memory". The pre-RFC-0002+> markdown-transcript model this card once described is retired —+> conversation history lives in the plain conversation store (see the+> `context` card and [agent_context_flow.md](../../agent_context_flow.md)).## Purpose-`simpleMemory` is a **passive configuration node** that holds conversation-history for connected agents. It has no inputs and is not meant to be run on-its own — `ui_hints.hideRunButton` is set. When an `aiAgent` / `chatAgent`-(or any specialized agent) executes, `edge_walker.collect_agent_connections`-reads this node's saved parameters (`memory_content`, `window_size`,-`long_term_enabled`, etc.) via `_build_memory_entry` and forwards them to-`AIService.execute_agent` / `execute_chat_agent`. The service parses the-markdown into native provider-neutral `Message` values, feeds them to the-shared native agent loop, appends the new exchange, trims to window, and saves-the updated markdown back to the memory node through the atomic memory-persistence helper.--The plugin's own `@Operation("read")` method is only invoked when a user-explicitly hits Run (or via direct dispatch); it returns an inspector-style-snapshot of the `services.memory_store` in-memory session, **which is a-separate store from the markdown `memory_content` pipeline used by the-agents**. See "Edge cases" below.--## Workflow Reset semantics--`simpleMemory` configuration is durable, but its conversation state follows the-workflow generation. Resetting the Temporal workflow:--- archives the current memory parameters under the old generation;-- resets `memory_content`, `memory_jsonl`, `last_session_id`, and provider- continuation identifiers while preserving configuration such as window size;-- clears connected agent sessions, long-term vector caches, direct memory-store- sessions, conversation rows, and token/compaction counters;-- broadcasts the cleared node parameters so the open panel updates immediately;-- makes the next workflow generation start from an empty conversation.--The explicit **Clear Memory** action remains available for clearing memory-without resetting the whole workflow. Workflow Reset invokes the same-cross-store clear contract only after its archival write succeeds.--Implementation is plugin-owned: `SimpleMemoryNode.reset_execution_state`-implements the generic `BaseNode` lifecycle hook. The deployment/reset service-does not recognize the `simpleMemory` type or know its session topology.+Durable, explicitly-invoked long-term memory for agents: stable facts,+preferences and decisions the model chooses to `remember`, later retrieved+with `recall`/`list`/`get` and maintained with `update`/`forget`. It is NOT+conversation history (that is the Context node's store) and nothing is+injected automatically — retrieval is always a tool call. The LLM-facing+`tool_description` is deliberately imperative ("check memory before answering+anything about the user; never claim ignorance without checking") because+with passive wording models answered from priors while the answer sat one+recall away.## Inputs (handles)-_None._ `simpleMemory` has no incoming handles.+| Handle | Connection type | Required | Purpose |+|--------|-----------------|----------|---------|+| `output-tool` → agent `input-tools` | tools | yes | Exposes the `memory` tool to the connected agent |## Parameters-Source: `SimpleMemoryParams` in-[`simple_memory/__init__.py`](../../../server/nodes/skill/simple_memory/__init__.py).-All field names are snake_case (Pydantic params are the post-Wave-11 source of-truth; the old `memoryType` / `clearOnRun` / buffer-vs-window split was removed-— trimming is always windowed and the UI exposes a manual "Clear Memory"-button).--| Name | Type | Default | Required | displayOptions.show | Description |-|------|------|---------|----------|---------------------|-------------|-| `session_id` | string | `""` | no | - | Session override. Empty -> agent node_id is used by the agent-side collection; the `read` op resolves empty to `"default"`. |-| `window_size` | int | `100` | no | - | Message *pairs* to keep in short-term memory; 1-100. |-| `memory_content` | string (code editor, markdown, rows 15) | `# Conversation History\n\n*No messages yet.*\n` | no | - | Markdown body (`### **Human** (ts)` / `### **Assistant** (ts)` blocks). Edited in-place in the UI. |-| `long_term_enabled` | boolean | `false` | no | - | When true, trimmed messages are archived to a per-session `NativeMemoryVectorStore`. |-| `retrieval_count` | int | `3` | no | `long_term_enabled=[true]` | Relevant messages to retrieve at query time (1-10). |-| `embedding_provider` | options | `huggingface` | no | `long_term_enabled=[true]` | `huggingface`, `openai`, or `ollama`. |-| `embedding_model` | string | `""` | no | `long_term_enabled=[true]` | Empty selects the provider default (`BAAI/bge-small-en-v1.5`, `text-embedding-3-small`, or `nomic-embed-text`). |-| `embedding_endpoint` | string | `""` | no | `long_term_enabled=[true]` | Optional OpenAI base URL or Ollama host. Never contains credentials. |-| `last_session_id` | string (optional, **hidden**) | `None` | no | - | Internal/display-only: last Claude session UUID. `claude_code_agent` no longer reads it; cleared when memory is wiped. |--Parameters consumed when an agent pulls the memory:--| Name | Where it comes from | Where it is read |-|------|---------------------|------------------|-| `memory_content`, `window_size`, `long_term_enabled`, `retrieval_count`, `embedding_provider`, `embedding_model`, `embedding_endpoint`, `last_session_id` | `database.get_node_parameters(source_node_id)` inside `edge_walker._build_memory_entry` | Packed into the `memory_data` dict and forwarded to the agent runtime. |--Parameters consumed when the node is run directly (`@Operation("read")`):--| Name | Default | Description |-|------|---------|-------------|-| `session_id` | resolves to `"default"` when empty | Session key used for `services.memory_store.get_messages`. |-| `window_size` | `100` | Windowing applied to the message log. |--## Outputs (handles)--| Handle | Shape | Description |-|--------|-------|-------------|-| `output-memory` (output, top, role `memory`) | object | Snapshot of the in-memory session (see below). |--### Output payload (`SimpleMemoryOutput` from the `read` op)--```ts-{- memory_content?: string; // echoes the editable markdown param- message_count?: number;- session_id?: string;- messages?: any[]; // from services.memory_store.get_messages- window_size?: number;- // model_config extra="allow"-}-```--Serialized through `BaseNode._serialize_result` and wrapped in the standard-envelope: `{ success: true, result: <payload>, execution_time }`.--## Logic Flow--```mermaid-flowchart TD- subgraph passiveUse["Passive use (agent collection)"]- P1[edge_walker scans edges] --> P2{target=input-memory<br/>source type=simpleMemory?}- P2 -- yes --> P3[database.get_node_parameters source_id]- P3 --> P4[memory_session_id = node_id<br/>unless session_id explicit]- P4 --> P5[_build_memory_entry: memory_data dict<br/>memory_content/window_size/...]- P5 --> P6[Forward to AIService]- end-- subgraph directRun["Direct run (Operation read)"]- D1[read op] --> D2[session_id = session_id or default<br/>window_size]- D2 --> D5[memory_store.get_messages<br/>session_id window_size]- D5 --> D6[Return SimpleMemoryOutput envelope]- end-```--## Decision Logic--- **Passive collection session key**: if the memory node's `session_id` is- empty (or `"default"`), the agent's own `node_id` is used as the session key.- This is what makes two agents wired to the same memory node keep **separate**- histories unless the user explicitly overrides `session_id`.-- **Instruction source of truth**: `memory_content` in the DB is authoritative.- UI edits persist there via `save_node_parameters`. The agent side- re-serialises after each turn through- `services.memory.append_to_memory_markdown` + `trim_markdown_window`.-- **Window semantics**: `window_size` counts *pairs* (Human + Assistant), so- `trim_markdown_window` keeps `window_size * 2` blocks. Trimmed blocks are- returned as raw text for optional vector-store archival.-- **Long-term retrieval**: async- `services.memory.get_memory_vector_store(...)` creates a- `NativeMemoryVectorStore` backed by the selected direct SDK. OpenAI keys are- resolved from `AuthService`; cache keys retain only a credential- fingerprint. Missing optional `sentence-transformers` support returns- `None`, so the agent skips archival without failing.-- **Direct-run memory store is different**: the `read` op pulls from- `services.memory_store` (via `get_messages`), **not** from the markdown- `memory_content`. A user who clicks Run on a `simpleMemory` node actively- used by an agent sees the `memory_store` view, which may be empty even though- `memory_content` contains history.+| Name | Type | Default | Required | Description |+|------|------|---------|----------|-------------|+| `reset_policy` | `preserve` \| `clear` | `preserve` | no | Whether Workflow Reset clears this node's namespace. In `server_controlled_fields`, so the model cannot override it through tool arguments. |++`SimpleMemoryParams` uses `extra="ignore"` so leftover legacy keys+(`memory_content`, `session_id`, ...) on migrated graphs are inert.++## Tool input (`SimpleMemoryToolInput`, `tool_schema_locked = True`)++One locked multi-operation schema: `operation` ∈ `remember | recall | list |+get | update | forget`, plus `content`/`title`/`category`/`tags`/`expires_at`+(remember/update patch), `query`/`categories`/`limit`/`cursor`+(recall/list), `memory_id`/`expected_version` (get/update/forget). The lock+means the plugin's schema and description always win over stale `ToolSchema`+DB rows.++## Storage++`MemoryToolStore` ([`services/memory/tool_store.py`](../../../server/services/memory/tool_store.py)) —+namespaced by `MemoryScope(owner_id, workflow_id, memory_node_id)`+(`agent_memory_namespaces` / `agent_memory_items` tables + FTS index).+Neither the client nor the model can supply a namespace; the tool derives it+from `NodeContext`, the panel handlers derive it from the authenticated+socket + persisted graph.++## Execution paths++- **In-process agent**: `handlers/tools.py::execute_tool` →+ `execute_as_tool(tool_args, node_params, ctx)` (ToolInput validation).+- **Temporal agent**: the AgentWorkflow schedules `node.simpleMemory.v1`+ with the model's unmerged `tool_args` in the payload; the legacy handler+ routes ToolNodes through `execute_as_tool`. Without that, args validated+ against `Params` (`extra="ignore"`) and every `remember` silently degraded+ to a `list` (locked by `test_tool_call_dispatch.py`).+- **Panel**: WS handlers in+ [`_handlers.py`](../../../server/nodes/tool/simple_memory/_handlers.py)+ (`list_memory_items` / `get_memory_item` / `remember_memory` /+ `update_memory_item` / `forget_memory_item` / `clear_memory_items`),+ authorized against the persisted graph; external sockets only.## Side Effects-- **Database writes**: none in the `read` op. The agent pipeline writes the- updated markdown back to this node's `node_parameters` row via- `database.save_node_parameters` after each turn.-- **Broadcasts**: none. The node is passive.-- **External API calls**: none in the `read` op. Agent archival may call- OpenAI embeddings, Ollama, or load a local SentenceTransformer according to- the selected provider.-- **File I/O**: none after the embedding model has loaded. The native vector- index is not persisted to disk and is lost on process restart.-- **Subprocess**: none.--## External Dependencies--- **Credentials**: OpenAI long-term memory resolves the stored OpenAI key- through `AuthService`. Plaintext keys are not persisted in memory-node- parameters or vector-store cache keys.-- **Services**: `services.memory_store` (direct-run path), `AIService` (via- agents), `Database` (for parameter persistence).-- **Python packages**: `sentence-transformers` via the optional- `local-embeddings` extra (long-term vector store only).-- **Environment variables**: none.+- **Database writes**: `agent_memory_items` (+ namespace row, FTS).+- **Broadcasts**: every durable mutation (both writers) fires the+ identity-only `memory.updated` CloudEvent+ ([`_events.py`](../../../server/nodes/tool/simple_memory/_events.py));+ the frontend invalidates `['memoryItems']` / `['memoryItem']`.+- **Workflow Reset**: `reset_execution_state` honors `reset_policy` —+ `clear` wipes only this node's namespace.## Edge cases & known limits-- **Two storage systems for one node**. The markdown `memory_content` (used- by agents) and the `services.memory_store` session log (used by the- `read` op) are **independent**. Clicking Run on the node does not- reflect what the agents see, and vice-versa. This is a known architectural- seam noted in the CLAUDE.md overview.-- **Vector store is in-memory only**. Its cache is keyed by session, provider,- model, endpoint, and a non-secret credential fingerprint. A server restart- empties it; long-term memory is not actually durable without external- persistence.-- **Optional embedder import is silent-catch**. If `sentence-transformers` is- missing at runtime, `get_memory_vector_store` logs a warning and returns- `None`; the agent continues without archival and the user never learns.-- **No token budgeting**. `window_size` is a message-pair count, not a token- count. A long history below the window threshold can still exceed the- model's context window; see the "Prompt Too Long" note in CLAUDE.md.-- **Markdown parser is regex-based**. `parse_memory_markdown` matches- `### **Human**` / `### **Assistant**` exactly. If a user edits the UI- content to a non-conforming header the messages will silently be dropped.-- **`window_size` is Pydantic-clamped 1-100** by the field constraint; the- agent-side `trim_markdown_window` trusts whatever value is passed.-- **Passive node, no envelope on read paths**. When consumed by an agent,- this node never produces its own envelope - it only supplies parameters.+- Retrieval is lexical (FTS) with optional embedding projections; recall+ quality depends on the model writing useful `content`/`tags`.+- `update`/`forget` require the item's `expected_version` (optimistic+ concurrency) — a stale version returns a user-correctable error.+- The panel declares `refetchOnMount: 'always'` because the agent mutates+ memory while the panel is closed (see CLAUDE.md notes).## Related-- **Consumer nodes**: [`aiAgent`](./aiAgent.md), [`chatAgent`](./chatAgent.md),- every specialized agent that routes through `execute_chat_agent`.-- **Architecture docs**: [Memory Compaction](../../memory_compaction.md),- [Agent Architecture](../../agent_architecture.md)+- **Sibling**: the `context` node — conversation history (plain+ conversation store), deliberately separate from durable facts.+- **Architecture docs**: [agent_context_flow.md](../../agent_context_flow.md),+ [RFC-0002](../../../RFC-0002-AGENT-CONTEXT-AND-MEMORY.md) (Memory+ sections current; Context implementation superseded).diff --git a/docs-internal/status_broadcaster.md b/docs-internal/status_broadcaster.mdindex dda9311d..ea291813 100644--- a/docs-internal/status_broadcaster.md+++ b/docs-internal/status_broadcaster.md@@ -143,22 +143,23 @@ Broadcasts are sent to all connected clients without a request-response correlat| `token_usage_update` | AI execution updates token counters | `{session_id, data: {total, threshold, needs_compaction}}` || `compaction_starting` | Memory compaction begins | `{session_id, node_id}` || `compaction_completed` | Memory compaction ends | `{session_id, success, tokens_before, tokens_after}` |-| `context.updated` | `AgentContextStore` durably advanced a Context thread (journal append or pressure write) — emitted from the store's commit boundary via `register_context_commit_listener`, so every writer (in-process loop, Temporal LLM activity, CLI-agent bridge) is covered without call-site code. Frontend invalidates `['agentContext']`. | `{specversion: "1.0", id, source: "opencompany://nodes/context", type: "com.opencompany.context.updated", subject: context_node_id, time, data: {workflow_id, context_node_id, thread_id, epoch, revision, provider, active_token_count, sequence?}}` |-| `context.compacted` | Context checkpoint activated (in-process finalize) | as above plus `{strategy, covers_through_sequence}` |-| `context.epoch.started` | Epoch rotated — emitted by `start_epoch`'s **callers**, not the store, because only they know the `reason` (`clear` / `fork` / `workflow_reset`) | as above plus `{reason}` |--The three `context.*` events call `get_status_broadcaster().broadcast(...)`-directly rather than `services.events.dispatch.emit`. `emit` exists to reach-Temporal consumers and pays a Visibility `ListWorkflowExecutions` query to find-them; no node type registers a canary consumer for `com.opencompany.context.*`,-so that query can only ever match nothing — once per journal append. Same-pattern as `nodes/telegram/_events.py`. See+| `context.updated` | A conversation durably saved (`save_conversation` upsert), or cleared from the panel / workflow Reset — emitted from the store's save boundary via `register_conversation_listener`, so every writer (in-process loop, Temporal LLM activity, specialized-provider bridge) is covered without call-site code. Frontend invalidates `['agentContext']`. | `{specversion: "1.0", id, source: "opencompany://nodes/context", type: "com.opencompany.context.updated", subject: agent_node_id, time, data: {workflow_id, generation, agent_node_id, message_count}}` |+| `memory.updated` | A durable Memory mutation (remember / update / forget / clear) from either writer — the agent's tool call or the panel handlers. Frontend invalidates `['memoryItems']` + `['memoryItem']`. | `{specversion: "1.0", id, source: "opencompany://nodes/simple_memory", type: "com.opencompany.memory.updated", subject: memory_node_id, time, data: {workflow_id, memory_node_id, operation}}` |++`context.updated` and `memory.updated` call+`get_status_broadcaster().broadcast(...)` directly rather than+`services.events.dispatch.emit`. `emit` exists to reach Temporal consumers and+pays a Visibility `ListWorkflowExecutions` query to find them; no node type+registers a canary consumer for `com.opencompany.context.*` /+`com.opencompany.memory.*`, so that query can only ever match nothing — once+per save. Same pattern as `nodes/telegram/_events.py`. See[event_framework.md → UI-only lifecycle events](./event_framework.md).-Payloads are identity + revision only — no message bodies, no provider state —+Payloads are identity + count only — no message bodies, no item content —because `_broadcast_in_process` fans out to **every** connected socket with no-per-workflow filtering. The Context panel refetches through the authorized-`get_agent_context` handler, which is where ownership is enforced.+per-workflow filtering. The panels refetch through the authorized+`get_agent_context` / `list_memory_items` handlers, which is where ownership+is enforced.## Execution correlation IDsdiff --git a/docs-internal/theme_system.md b/docs-internal/theme_system.mdindex 8b3dc1e8..655a7a54 100644--- a/docs-internal/theme_system.md+++ b/docs-internal/theme_system.md@@ -245,6 +245,7 @@ the surrounding chrome. Every other surface uses Tailwind + tokens. New themes c- **Per-theme decorative CSS** (W16) — every per-component rule from `design_handoff_machinaos_themes/themes/*.css` is now ported into `client/src/themes/<theme>.css`. Each theme owns its panel textures, canvas decorations, node pseudo-element overlays, and keyframes. CSS bundle: 145 KB → 244 KB (+99 KB).- **Selection state** (W17, shipped as part of W15) — every canvas node component carries the `selected` co-class when React Flow's `selected` prop is true, activating per-theme selection effects (cyber-blink on Cyber sq-nodes, hanko seal on Edo sq-nodes, etc.).- **Sound event wiring** (W18) — 9 events (`click`, `hover`, `type`, `success`, `error`, `run`, `save`, `modalOpen`, `modalClose`) fire automatically across the React tree. See [Sound system → Event wiring](#event-wiring-w18).+- **Success is a moment, not a state** — terminal node statuses persist in `nodeStatusStore` until the next run, so the static `--success` ring/stroke on `.react-flow__node.completed` (base.css) and `.react-flow__edge.completed` (styles/canvasAnimations.ts) previously left every completed agent/tool node and traversed edge glowing green indefinitely. Both are now one-shot fades (`node-completed-fade` in animations.css / `edgeCompletedFade`): hold the success token briefly, then settle back to the resting border/stroke. `prefers-reduced-motion` keeps the static ring (legible outcome, no motion). Error states deliberately stay painted until acted on.- **Reduced-motion accessibility** (W19) — `@media (prefers-reduced-motion: reduce)` block in [client/src/themes/base.css](../client/src/themes/base.css) disables every keyframe across all themes. See [Reduced motion](#reduced-motion).- **Sound throttling** (W19) — `type` and `hover` events throttled to a 30 ms last-fire window inside the engine to prevent OscillatorNode flooding. See [Throttling](#throttling).- **Migrated chrome**: TopToolbar, WorkflowSidebar, ComponentPalette + ComponentItem + CollapsibleSection, ConsolePanel chrome, SettingsPanel, Modal, ParameterPanel modal title, AIResultModal title, OutputDisplayPanel title, InputSection title