Skip to content

[BUG] Cyclic symlinks in global skills cause blank TUI and unbounded memory growth #42216

Description

@YoungSens

Description

A cyclic directory symlink inside a global skill causes OpenCode to remain on a completely blank TUI while skill discovery recursively follows the loop.

On macOS, the process stayed alive, logs stopped at message=init, and memory grew to approximately 7.3 GB. Sampling showed a Bun worker repeatedly performing openat calls.

Moving the cyclic symlinks out of ~/.agents/skills fixed the issue immediately. With the same OpenCode binary and project, skill initialization then completed in about one second and the TUI rendered normally.

This appears to be a more severe form of #27027. That report covers large symlink targets and slow startup; this case uses an actual symlink cycle and results in effectively unbounded traversal and memory growth. #27072 has a similar blank-TUI symptom but concerns project file scanning rather than skill discovery.

Expected behavior

OpenCode should detect an already visited directory by real path or filesystem identity, skip the cyclic edge, emit a warning containing the offending path, and continue rendering the TUI.

Actual behavior

  • TUI remains completely blank
  • logs stop at message=init
  • the process continuously traverses files
  • memory usage keeps growing
  • no actionable error identifies the cyclic skill path

Diagnostic result

Following the affected skill tree reproduced recursive path expansion. After removing 16 nested symlinks that formed self and cross-directory cycles, the followed traversal contained only 177 entries and OpenCode logged init count=10 before rendering the full welcome screen.

Plugins

None

OpenCode version

1.18.16, installed with Homebrew

Steps to reproduce

Warning: this can cause rapid memory growth. Run only in a disposable HOME and stop the process promptly.

TEST_HOME=$(mktemp -d)
mkdir -p "$TEST_HOME/.agents/skills/loop-skill"

cat > "$TEST_HOME/.agents/skills/loop-skill/SKILL.md" <<EOF
---
name: loop-skill
description: Reproduce cyclic skill symlink scanning
---
EOF

ln -s "$TEST_HOME/.agents/skills/loop-skill" \
  "$TEST_HOME/.agents/skills/loop-skill/self"

HOME="$TEST_HOME" opencode

The TUI remains blank while the process recursively follows self.

Remove the cyclic link and rerun:

unlink "$TEST_HOME/.agents/skills/loop-skill/self"
HOME="$TEST_HOME" opencode

The TUI renders normally.

Screenshot and/or share link

No screenshot. The blank screen contains no diagnostic text.

Operating System

macOS 26.5.2, Apple Silicon arm64

Terminal

iTerm2 3.6.11, also reproduced in an isolated PTY

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions