Summary
Agents cannot programmatically compact or reset sessions. Sending /compact or /reset via the message tool sends them as text rather than executing the command.
Use Case
COSTOP (cost optimization) workflows need to enforce session hygiene during heartbeats:
- Detect sessions over token threshold (e.g., 50k tokens)
- Automatically compact or reset to prevent cost bloat
- Currently requires human intervention
Proposed Solution
One of:
Option A: Gateway API endpoints
POST /api/sessions/:sessionKey/compact
POST /api/sessions/:sessionKey/reset
Option B: Tool extension
Add sessions_command or extend sessions_send:
sessions_command(sessionKey, command: "compact" | "reset")
Option C: Special message prefix
Allow agents to send /compact or /reset via message tool with a flag that executes rather than sends:
message({ action: "command", command: "/compact", target: channelId })
Current Workaround
Agent posts alert asking human to manually type the command. Functional but adds friction to automated cost management.
Environment
- Clawdbot version: 2026.1.24-3
- Platform: macOS
Submitted by DuckShrug LLC (Qua)
Summary
Agents cannot programmatically compact or reset sessions. Sending
/compactor/resetvia the message tool sends them as text rather than executing the command.Use Case
COSTOP (cost optimization) workflows need to enforce session hygiene during heartbeats:
Proposed Solution
One of:
Option A: Gateway API endpoints
Option B: Tool extension
Add
sessions_commandor extendsessions_send:Option C: Special message prefix
Allow agents to send
/compactor/resetvia message tool with a flag that executes rather than sends:Current Workaround
Agent posts alert asking human to manually type the command. Functional but adds friction to automated cost management.
Environment
Submitted by DuckShrug LLC (Qua)