When you run an AI agent as a LINE Bot, you'll eventually hit a problem: as conversations grow longer, the bot's "memory" drifts. It drags in old context, gives irrelevant answers, or gets stuck in an error state it can't escape.
This is a practical guide to resetting LINE Bot sessions running on OpenClaw.
The Problem: A LINE Bot Stuck in a Loop
We run a LINE Bot integrated with a wholesale ERP system. Staff use LINE to check inventory and query sales data.
One day, a specific user's conversation went haywire. No matter what they asked, the bot kept referencing a previous topic. It wasn't recognizing new conversations.
The cause: session contamination.
How OpenClaw Manages Sessions
OpenClaw manages sessions per agent (LLM-based bot). Each LINE user ID is tied to a session where conversation history (transcript) accumulates.
Transcript files are typically stored here:
~/.openclaw/sessions/<session-id>/transcript.json
This records recent conversations, used as context when processing the next message.
Since LLM context windows have limits, long conversations get compressed (compaction). When compaction is incomplete or error-state messages are mixed in, the bot starts misbehaving.
The Fix: Delete the Transcript File
The simplest solution is to delete the problematic session's transcript file.
# Find the session ID
openclaw sessions list
# Delete the transcript
rm ~/.openclaw/sessions/<session-id>/transcript.json
After deletion, the next message to the bot starts a fresh session. Context is reset.
What You Lose
Deleting the transcript means that conversation history is completely gone.
- Binding state (LINE ID ⇔ ERP user mapping) is stored in the DB, so it survives ✅
- In-progress tasks (e.g., "checking inventory...") get reset ⚠️
- All recent conversation context with the user is lost ⚠️
If you store auth info or business data only in session memory, you'll lose it on reset. Data that needs to persist belongs in a database — whether this rule is followed determines how safe a reset is.
Designing Safer Resets
Directly deleting transcripts is "surgery." It works for emergencies, but a better approach is providing reset functionality in the application itself.
For example, implementing a reset command in the LINE Bot:
// Inside the LINE webhook handler
if (message.text === 'リセット' || message.text === '/reset') {
await clearUserSession(event.source.userId);
await lineClient.replyMessage(event.replyToken, {
type: 'text',
text: 'Session reset. Please start your conversation again.',
});
return;
}
clearUserSession() calls the OpenClaw API or filesystem to delete the transcript. When users can reset themselves, admins don't need to touch files directly.
Summary
| Method | Ease | Risk | Use Case |
|---|---|---|---|
| Transcript file deletion | High | Medium (history loss) | Emergency fix |
| In-app reset command | Medium (needs implementation) | Low | Daily operations |
| Session TTL configuration | Low (config change) | Low | Prevention |
Whether it's a LINE Bot or any other AI agent, if you're running them long-term, session lifecycle management must be part of your design. "What do we do when it loops?" is too late to figure out after it happens.
Top comments (0)