Alexis Rondeau

Newsfeed

Reply · Monday, February 16, 2026 · 19:48

1 like · 31 views
In reply to @RealistSec · Feb 16, 2026

And there lies the trap! 😂
It's because there isn't any proper auto-compacting for sessions.

Thus, if you create a tool in a session it is logged both to your
~/.openclaw/agents/main/sessions/sessions.json

AND will be linked as context via your current session's ~/.openclaw/agents/main/sessions/[UUID].jsonl
file - both of which are sent as context to the LLM inference API as context of the current chat/request.

So a simple, 'Hey' can actually contain the full build of your tool, and modifications of it, edits, uses, chats and versions and revisions of it, logged uses of it, + the session file + 'Hey'
= shedload of tokens!

Workarounds for building tools and in general:
1) Always use a subagent - just ask it to:
"use another agent to [do X,] and when done add it to 'memory' "
and it will be in a session file outside the main one,
1b) (make sure you have the memories skill enabled!)

2) When working on it for a while, and when done - before finishing the session use:
/compact slash command
to keep the tokens controlled, so even if it is referenced in the future it has been pruned.

3) When finished, run /new to clear the session/tokens and start out with just the base context/memories/last pruned session as context.

After a while though even memories etc can build up, that's when using lots of individual agents comes into it, the main agent becomes the orchestrator and only sends the relevant request and relevant context needed for it per task to the sub-agent.

Image from the post

Duuuude! Wow. Thank you so much for helping me understand this. That makes sense.

In Claude Code, for the exact same reason, we spent a bunch of time last year at work getting sub-agents to work reliably.

There it works well, I hadn't considered this is an option (or necessity) here.

Gonna read up on docs.openclaw.ai/tools/subagents and report back

Again, thank you for taking the time to write this up.

OpenClawSub-agents · OpenClawIndex of the OpenClaw sub-agent documentation, one page per reader job↗ docs.openclaw.ai