Hi all,
We kept hitting the same problems with n8n agents, specifically with memory. The different types of memory seemed to break at different points: Simple Memory didn’t work in queue mode, Postgres would forget long chats, and a bad tool call could break the workflow. We just wanted agent memory that worked, regardless of where or for how long it needed to run.
While reading around for a solution, we realised we weren’t alone. There’s a lot of discussion about memory that’s “just gone” and agents that “lose conversation context and repeat questions”.
Because of this, we decided to turn our memory API into a node. The Twigg AI Agent fixes agent memory in the following ways:
- Conversations are stored server-side, so they survive restarts and updates
- Long conversations are compacted and old tool output trimmed, so memory can last for days or months without breaking
- Broken tool calls and invalid inputs are repaired automatically, so you don’t need to fix them by hand to get the workflow running again
- Works in queue mode: memory lives outside n8n, so every worker sees the same conversation, however many you run
- Choose between all the major and open-source models
If you already have a memory node connected, just plug it into the Twigg node and it will import each conversation the next time the workflow runs for it.
It’s a verified community node, so it’s available on n8n Cloud too: search for the Twigg AI Agent node, or install @twigg/n8n-nodes-twigg.
More info: Twigg for n8n
Disclosure: I’m one of the founders. Happy to help anyone set it up.
Related threads:
Memory that survives queue mode is a real gap, so this will help people. One question about compaction, from a booking agent I built. There I keep memory only for the thread of the conversation and never as the source of truth for anything the agent committed to. Availability, the hold, the amount and the payment status live in Postgres tables that the tools read on every turn.
When Twigg compacts a long conversation and trims old tool output, how do you keep the facts the agent already told the user, like a quoted price or a booking reference? If those can be trimmed, I’d suggest people store them in their own table and let memory carry only the dialogue.
Good question, and I do agree with your approach.
For me It depends on the workflow though. For my own long-running agents, I keep everything in Twigg. By the time a chat is long enough to be summarised, the trimmed parts are usually actions from weeks ago, like an email it sent, where the exact details don’t matter. Claude Code and other agents work the same way.
For bookings, I’d do what you do: keep prices, references and payment status in your own tables, and have the agent look them up each time. Two things in Twigg specifically help with that:
- Delete the chat when the flow finishes, so each run starts fresh but still works nicely in queue mode.
- Tell Twigg to replace specific tool responses with a “content removed” stub. It’s a nice feature we added in that forces the agents re re-fetch details as they see something was dropped. It means the agent keeps the flow of the conversation but has to look up details like booking numbers fresh, instead of quoting them from its history.
Hope that’s helpful. I do agree though, for fact critical flows, its usually good to have an external ‘facts’ table the agent can read from. In cases like that, our node exists to give a durable working memory that works in the cases the other memories fail, and not hold the source of truth.
2 Likes
The broken tool call repair is the part I’d want to understand. A call left without its result after compaction trims the history is what Anthropic and OpenAI reject with a 400, and the easy fix is to synthesize a result, which for a write that never ran tells the agent something that didn’t happen.
Do repairs show up anywhere in the execution data, so you can see which calls got touched?
1 Like
For the n8n implementation there are actually two steps. For a call left for a long time without a result, the next prompt or retry adds a tombstone to the chat history. This is a tool response that tells the LLM the previous call’s status is unknown, which prompts it to check before retrying. We do this so chat threads can’t be permanently bricked. Right now the repair shows up as a warning on Twigg’s side rather than in n8n’s execution data, but surfacing it in the node’s output is a good shout, so we’ll add it.
Since one of the big issues people have raised here is concurrency, the tombstone is only the fallback. When a thread is waiting on a tool call result (within a certain timeout) and another trigger tries to send a prompt to the same chat, it gets a wait_for_pending_tool_calls response, and the node backs off and retries once the other process has finished. Only if the pending call never completes within a set time does the tombstone kick in.
So you get self-fixing tool calls, without different processes muddying the same memory thread.
@matti_de_beer The case left is a write that finishes just after the timeout, when the tombstone has already told the agent the status is unknown. The real result can’t attach to the original call anymore, since it has to sit right after its call by id, so it either gets dropped or added as a new message. What does the node do with it today?
If it’s dropped, “check before retrying” only works when the tool can read the state back. For a sent email or a payment there is often nothing to read, so the retry would have to be idempotent, keyed by the original call.