You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Compaction throws TypeError when another plugin has already removed event.tools #668
delete event.tools.compress throws when another plugin has already removed event.tools
Version:@tarquinen/opencode-dcp 3.2.0 OpenCode: V2 (2.2.5) on Windows 11 Related plugin:opencode-runtime-fallback 0.3.1
Summary
When DCP's compaction handler runs after a plugin that clears event.tools, DCP throws a TypeError and the whole compaction fallback is aborted.
Where
dist/index.js, lines ~8363 and ~8366 (3.2.0 build):
deleteevent.tools.compress;
If a preceding context/compaction hook mutated the event and set event.tools to undefined, the delete expression dereferences undefined and throws:
TypeError: Cannot convert undefined or null to object
at deleteProperty ...
Result in the OpenCode server log:
level=ERROR message="Failed to drain Session"
Compaction fallback failed
Why it happens here
opencode-runtime-fallback 0.3.1 registers a context/compaction hook that does:
deleteevent.tools;
Hook order is not guaranteed, so DCP can receive an event whose tools field no longer exists.
Minimal fix
if(event.tools)deleteevent.tools.compress;
or, keeping it one line:
deleteevent.tools?.compress;
(delete on undefined?.x is valid and a no-op.)
Why it matters
It is a hard failure, not a graceful degradation: the fallback compaction pass never completes and the session stays over the context limit. Any plugin that touches event.tools can trigger it, not only the fallback plugin.
Priority
Low code complexity, but it turns a benign plugin interaction into a broken session. Defensive guard seems worth adding.
Activity
Tarquinen commentedon Nov 16, 2026
Fixed in #678 (merged into dev). It will ship in the next release.