Repository navigation
Description
Permission service logs full ruleset on every tool call, causing 50GB+ log bloat
Bug Summary
The service=permission logger writes the entire permission ruleset (all rules, including every external_directory allow/ask entry) into every single log line at INFO level. With a moderate number of installed skills (~648), each permission log line balloons to ~148KB (148,601 characters). During an active session with Oh-My-OpenCode subagents, this produces ~29MB/min of logs per process, causing the log directory to grow to 50GB+ within hours.
Environment
| Component | Version/Value |
|---|---|
| OpenCode | 1.1.53 |
| OS | macOS (darwin-arm64) |
| Plugin | [email protected] |
| Installed Skills | 648 (via ~/.agents/skills/ + ~/.claude/skills/) |
| MCP Servers | 18 configured (shadcn, context7, grep, github, playwright, filesystem, memory, sequential-thinking, fetch, git, postgres, sqlite, redis, mongodb, cloudflare, supabase, neon, zai-mcp-server) |
Reproduction
Prerequisites
- Install 100+ skills (via
~/.agents/skills/or~/.claude/skills/) - Configure multiple MCP servers
- Optionally install oh-my-opencode plugin (amplifies the issue via subagent processes)
Steps
- Start OpenCode:
opencode - Send any message that triggers tool calls (e.g., "list files in current directory")
- Observe
~/.local/share/opencode/log/directory growth
Expected
Log directory grows at a reasonable rate (~1-10MB per session).
Actual
Log directory grows at ~29MB/min per active process. With oh-my-opencode spawning multiple subagent processes, total growth reaches hundreds of MB per minute.
Root Cause Analysis
Primary: Permission ruleset serialized into every log line
Every tool invocation triggers permission evaluation, which logs two lines to the session log:
Line 1 — Permission check (contains full ruleset):
INFO 2026-03-12T17:43:54 +1ms service=permission permission=bash pattern=echo "hello" ruleset=[{"permission":"*","pattern":"*","action":"allow"},{"permission":"doom_loop","pattern":"*","action":"ask"},{"permission":"external_directory","pattern":"*","action":"ask"},{"permission":"external_directory","pattern":"/Users/xuyu/.local/share/opencode/tool-output/*","action":"allow"},{"permission":"external_directory","pattern":"/Users/xuyu/.claude/skills/postgresql-code-review/*","action":"allow"},{"permission":"external_directory","pattern":"/Users/xuyu/.claude/skills/python-packaging/*","action":"allow"}, ... <1,278 rules total> ...]
Line 2 — Evaluation result (also contains full ruleset):
INFO 2026-03-12T17:43:54 +1ms service=permission permission=bash pattern=echo "hello" action={"permission":"*","pattern":"*","action":"allow"} evaluated
Each skill contributes ~2 external_directory rules. With 648 skills:
- 1,278 rules serialized per permission check
- Each rule ~116 characters
- Total ruleset string: ~148KB per log line
Quantified Impact
| Metric | Value |
|---|---|
| Rules per permission check | 1,278 |
| Characters per permission log line | 148,601 |
| Log lines per tool call | 2 (check + evaluate) |
| Bytes per tool call | ~296KB |
| Tool calls per minute (active session) | ~100+ |
| Log growth per minute (single process) | ~29MB |
| Log growth per minute (11 processes) | ~320MB |
| Log growth per hour (worst case) | ~19GB |
Evidence from real session
# Log file: only 200K lines but 24GB
$ wc -l 2026-03-12T165514.log
200047 # → avg 120KB per line!
# Active log: 7066 lines, 52% are permission checks
Total lines: 7,066
Permission lines: 3,709 (52.5%)
Bus publishing: 640
Message.part: 557
# Permission checks by tool type:
3200 permission=skill # skills loaded on every message
428 permission=bash # shell commands
119 permission=task # subagent delegation
# Single permission line size:
$ grep -m1 'service=permission' log | wc -c
148601
Secondary: Orphaned subagent processes
Oh-My-OpenCode spawns subagent processes (Sisyphus, Hephaestus, explore, librarian, etc.) that sometimes become orphaned (ppid=1) and continue running for 16+ hours, each maintaining their own log session:
# 10 orphaned processes found, all ppid=1
8697 1 Thu Mar/12 09:36:41 2026 opencode # 16 hours old!
8849 1 Thu Mar/12 09:36:49 2026 opencode
8991 1 Thu Mar/12 09:36:53 2026 opencode
9131 1 Thu Mar/12 09:36:59 2026 opencode
9135 1 Thu Mar/12 09:37:02 2026 opencode
10925 1 Thu Mar/12 09:43:07 2026 opencode
34325 1 Thu Mar/12 22:27:23 2026 opencode
80965 1 Thu Mar/12 23:00:09 2026 opencode
85117 1 Fri Mar/13 00:08:42 2026 opencode
86339 1 Fri Mar/13 00:55:13 2026 opencode
Tertiary: MCP "Method not found" error spam
Multiple MCP servers repeatedly log -32601: Method not found errors for prompts/list, adding noise:
ERROR service=mcp clientName=filesystem error=MCP error -32601: Method not found failed to get prompts
ERROR service=mcp clientName=sequential-thinking error=MCP error -32601: Method not found failed to get prompts
ERROR service=mcp clientName=mongodb error=MCP error -32601: Method not found failed to get prompts
ERROR service=mcp clientName=playwright error=MCP error -32601: Method not found failed to get prompts
ERROR service=mcp clientName=shadcn error=MCP error -32601: Method not found failed to get prompts
Tertiary: No log rotation or size limits
OpenCode has no built-in log rotation, maximum file size, or auto-cleanup mechanism. A single session log file can grow unboundedly.
Proposed Fixes
P0 — Critical (permission ruleset logging)
-
Do NOT serialize the full ruleset into log lines. The
ruleset=[...]field in permission logs is the single biggest contributor. Options:- Remove
rulesetfrom INFO-level logs entirely (move to DEBUG/TRACE) - Log only the matched rule, not the entire ruleset
- Log a ruleset hash/fingerprint instead of the full array
- Remove
-
Add a
logLevelconfiguration option that users can set inopencode.json:{ "logLevel": "warn" }
P1 — High (log management)
-
Implement log rotation: Max file size (e.g., 100MB per file) with automatic rotation and retention limit (e.g., keep last 5 files or 500MB total).
-
Auto-cleanup old logs: Delete log files older than N days (configurable, default 7 days).
P2 — Medium (subagent lifecycle)
- Ensure subagent processes terminate when parent session ends. Currently orphaned processes (ppid=1) accumulate and continue writing logs indefinitely. (This may be an oh-my-opencode plugin issue rather than core OpenCode.)
P3 — Low (MCP error noise)
- Suppress or rate-limit repeated MCP errors: The
-32601: Method not foundforprompts/listis expected for MCP servers that don't implement the prompts capability. Log once per server at WARN, not repeatedly at ERROR.
Workarounds
Until fixed, users can mitigate with:
# 1. Kill orphaned opencode processes
ps aux | grep opencode | grep -v grep | awk '{print $2}' | xargs kill
# 2. Delete large log files
find ~/.local/share/opencode/log -type f -size +500M -delete
# 3. Set up auto-cleanup cron (daily at 4:00 AM)
(crontab -l 2>/dev/null; echo "0 4 * * * find ~/.local/share/opencode/log -type f -mtime +3 -delete") | crontab -
(crontab -l 2>/dev/null; echo "30 4 * * * find ~/.local/share/opencode/log -type f -size +500M -delete") | crontab -
# 4. Reduce installed skills to decrease ruleset size
# Each skill removed saves ~232 bytes per log line (2 rules × 116 chars)Impact
- Disk exhaustion: 50GB+ log accumulation in hours on a 228GB disk
- Performance degradation: 11 orphaned processes consuming CPU/memory
- Silent failure: No warnings when logs consume excessive disk space
- Scales with skill count: More skills installed → exponentially worse logging overhead
Related
- Potentially related to log cleanup reverse-deletion bugs (where old logs are kept and new logs deleted)
- Oh-My-OpenCode subagent process lifecycle management
- MCP server capability negotiation (prompts/list on non-supporting servers)
Activity
github-actions commentedon Mar 12, 2026
This issue might be a duplicate of or related to existing issues. Please check:
--log-levelCLI flag not passed to Worker — log files are always written at INFO level regardless of flag, contributing to runaway log growthPlease review the above to determine if this should be consolidated with any of them, or if the specific root cause (permission ruleset serialized into every log line) is sufficiently distinct to warrant its own tracking.
htafolla commentedon Apr 13, 2026
Confirmed with smaller skill count (0xRay/StringRay plugin)
Seeing the same pattern with a much smaller setup — proving this isn't limited to high skill counts.
Environment
mode: subagent)Measurements (26-minute session)
Memory Impact
The permission ruleset is held in V8 memory as string history:
Key finding: sockets and handles are stable (not leaking). The memory growth correlates directly with log buffer accumulation — 87.8% of which is the permission ruleset being re-serialized on every
evaluatecall.Minimal Reproduction
Even with zero custom skills and only 7 MCP servers, the 14-rule default ruleset gets logged on every permission check. The bloat scales linearly with session activity — not skill count.
Suggested Fix
The
evaluatelog line should log only the pattern and action, not the full ruleset:This alone would cut log volume by ~90% and eliminate the sustained memory growth from permission log buffering.
boyingliu01 commentedon Apr 14, 2026
I just experienced the exact same issue - a single log file grew to 33GB within 23 hours of an OpenCode session running overnight.
My Case
Root Cause Confirmed
The log tail shows exactly the pattern described in this issue:
INFO 2026-04-13T15:35:13 +0ms service=permission permission=skill pattern=evomap-publish ruleset=[{...hundreds of rules...}] evaluate
Every permission check dumps the entire ruleset JSON array (~27KB in my case).
Impact
Workaround Applied
Added cron job for log cleanup:
This is a critical issue that can silently exhaust disk space and crash user systems. The proposed P0 fix (remove ruleset from INFO logs or log only matched rule) would completely solve this.
boyingliu01 commentedon Apr 14, 2026
Workaround Verified:
--log-level WARNEffectively Solves Log BloatAfter experiencing the same issue (50GB+ log accumulation within hours with ~100 skills installed), I verified that using
--log-level WARNcompletely eliminates the permission ruleset log bloat.Verification Results
Workaround Implementation
Created a wrapper script that always starts OpenCode with
--log-level WARN:Then added alias in shell config:
Key Observation
The
--log-levelCLI flag does work for the main process. The permission service logs (service=permission) at INFO level are suppressed when using WARN level.This suggests:
Suggested P0 Fix
Since the permission ruleset is logged at INFO level, changing the permission service logging to DEBUG or TRACE would solve this completely:
This would:
--log-level DEBUGto see full rulesetEnvironment: OpenCode 1.4.3, Linux, oh-my-openagent plugin, ~100 skills
boyingliu01 commentedon Apr 15, 2026
Windows Environment Reproduction
Confirmed the same issue on Windows 11 (WSL2 hybrid environment).
Environment
Findings
Log location: C:\Users\think.local\share\opencode\log
Log file sizes:
Permission log analysis:
Root Cause Confirmed
Temporary Workaround
Created wrapper script (oc.bat) to pass --log-level WARN:
@echo off C:\Users\think\scoop\apps\bun\current\bin\opencode.exe --log-level WARN %*Note: Only suppresses console - file logs still INFO due to #13158.
Suggested Fix
Affects all platforms with many skills.
nabeelio commentedon May 2, 2026
I closed my issue since it was a duplicate, but just adding some more datapoints: #25433
nabeelio commentedon May 2, 2026
It seems a top level
"logLevel": "WARN"in the opencode.jsonc dialed the log level down