Chat Memory

By default each AI Agent invocation is stateless — the model sees only the current message. Chat memory makes a service task part of an ongoing conversation: prior turns are replayed before each call, so a process can hold a multi-turn dialogue across BPMN steps — most often across a human-feedback user task.

Enabling memory

In the Memory group:

Field Parameter Default Notes
Use chat memory useChatMemory ${false} Set to ${true} to activate.
Memory ID memoryId new UUID Conversation identifier. Shown only when memory is on.
Chat memory max messages chatMemoryMaxMessages 20 Sliding window; older messages are dropped.

How memoryId behaves:

  • Leave it empty to start a new conversation. The connector generates a UUID and returns it via the ${memoryId} output — persist it into a process variable so you can pass it back later.
  • Set it (e.g. ${memoryId}) to continue a known conversation.
  • In a loop, use ${execution.getVariable('memoryId')}: it’s empty on the first iteration (new conversation, ID returned) and reuses the stored ID on later iterations.

Map the memory ID output (${memoryId} → e.g. memoryId) so the conversation can be resumed.

Human-in-the-loop pattern

The canonical use is a review loop:

  1. AI Agent task — useChatMemory = ${true}, memoryId = ${execution.getVariable('memoryId')}. Map ${output} and ${memoryId} to process variables.
  2. User task — a human reads the agent’s answer and supplies feedback into a variable.
  3. Gateway — loop back to the agent (feeding the feedback as the next message) until the human is satisfied, then continue.

Because the same memoryId is reused, the agent sees the whole prior exchange on each iteration and refines its answer rather than starting over. See the human-in-the-loop.bpmn demo in Examples.

Where the conversation is stored

By default each conversation is a process variable, cibseven-connect-ai-agent-memory_<memoryId>, stored with the process instance in the engine database. It survives an engine restart, and every node of a cluster sees it.

One conversation per process instance. A memoryId belongs to the process instance it was created in. A review loop inside one process keeps its conversation, also through embedded sub-processes. It starts over, without an error, when the agent sits in a called process (call activity), when the reply arrives as a new process instance (for example through a message start event), or when you pass the id to another process. To start a new conversation in the same process instance, give the next call a new id, for example by clearing the memoryId variable before the task; the old conversation stays until the instance ends.

It is saved with the task’s work. When the task fails and is retried, the turn is not kept, and the retry calls the model again with the conversation as it was. After the process instance ends, the conversation stays in the history at history level audit or full until history cleanup removes it; at level full, every save is also kept as a history entry.

Parallel branches must not share an id. Branches that run at the same time with one memoryId save the same variable, so one of them fails because the other saved first (OptimisticLockingException), and its task is retried, which calls the model again. Give parallel instances an id each, for example review-${loopCounter}. Branches that share one conversation have to run one after another, for example as a sequential multi-instance.

Size. A conversation larger than chatMemoryMaxPayloadBytes (1 MiB by default, about a million characters) fails the task after the model has answered. Retrying the incident usually fails again and calls the model each time. Lower chatMemoryMaxMessages, or with RAG maxRagResults, or ask the administrator to raise the limit where the database allows more. A warning appears in the server log once a conversation reaches 80 % of the limit.

The id is part of a variable name, so a memoryId may have at most 222 ASCII characters.

In Cockpit you see three related variables: cibseven-connect-ai-agent marks that the agent ran, cibseven-connect-ai-agent_<activityId>~<number> is its chat log, and cibseven-connect-ai-agent-memory_<memoryId> the conversation. Do not change or delete them.

On an agentic ad hoc sub-process, the sub-process sets useChatMemory and memoryId itself. Its agent keeps the conversation on the sub-process, where the sub-process’s activities can neither read nor change it, and Chat memory max messages sets the window. By default each entry into the sub-process starts a new conversation; with Conversation = Continue across entries it goes on.

Not recommended: conversations in the server's memory

With cibseven.connect.ai-agent.chatMemoryVariable.enabled=false (or the environment variable CIBSEVEN_CONNECT_AI_AGENT_CHAT_MEMORY_VARIABLE_ENABLED=false) the connector keeps conversations in the server’s memory instead, and logs a warning when it first uses it. Conversations are then lost on an engine restart and not shared across nodes, and the conversation of an agentic sub-process’s agent is no longer kept apart from its activities.

Keeping one conversation across process instances needs a store of your own, installed on the server by a developer, see Developer Guide. Deleting a conversation at once also needs Java code, AgentChatMemoryStore.clear(memoryId) in a process step; otherwise it goes with the process instance.

Note

If you don’t need conversation history, leave useChatMemory off — stateless invocations avoid the store entirely.

On this Page: