Bug: opencode session list does not show forked sessions created by kugetsu init #38

Closed
opened 2026-03-31 06:29:18 +02:00 by shoko · 0 comments
Owner

Problem

After running kugetsu init, BOTH kugetsu status AND kugetsu delegate report failure even though the PM agent is fully functional.

Root Cause

kugetsu uses opencode session list --format json | grep to verify if a session exists before using it. However, forked sessions created via opencode run --fork --session do not appear in opencode session list output at all — regardless of format (table or JSON).

This breaks both kugetsu status AND kugetsu delegate because both functions call check_opencode_session_exists() before proceeding.

The sessions ARE accessible and fully functional via opencode run --continue --session <session_id> directly, but session list does not return them.

Reproduction (Minimal)

# 1. Initialize kugetsu
kugetsu init

# 2. Check status immediately after
kugetsu status
# Expected: ok
# Actual: pm_agent_expired

# 3. Try to delegate — also broken
kugetsu delegate "ping"
# Error: PM agent session has expired. Run kugetsu init again.

# 4. But the PM agent IS alive and working when called directly
opencode run --continue --session $(cat ~/.kugetsu/sessions/pm-agent.json | python3 -c "import sys,json; print(json.load(sys.stdin)[opencode_session_id])") "ping"
# Returns valid response from PM agent

Extended Verification

# Sessions exist in kugetsu state
cat ~/.kugetsu/sessions/base.json
cat ~/.kugetsu/sessions/pm-agent.json

# But they do not appear in opencode session list
opencode session list --format json | grep <pm_session_id>
# Returns nothing — yet the session works!

Environment

  • opencode: (latest, includes --format json)
  • kugetsu: latest from git (main branch)
  • OS: Linux

Fix Options

Option A (kugetsu): Replace existence check with a no-op run call:

opencode run --continue --session <id> "echo" 2>/dev/null && echo "alive" || echo "dead"

Option B (opencode): Include forked sessions in opencode session list output.

Workaround

Call opencode run --continue --session <id> directly instead of using kugetsu delegate. The PM agent is alive and functional — only the existence check is broken.

## Problem After running `kugetsu init`, BOTH `kugetsu status` AND `kugetsu delegate` report failure even though the PM agent is fully functional. ## Root Cause `kugetsu` uses `opencode session list --format json | grep` to verify if a session exists before using it. However, forked sessions created via `opencode run --fork --session` do not appear in `opencode session list` output at all — regardless of format (table or JSON). This breaks both `kugetsu status` AND `kugetsu delegate` because both functions call `check_opencode_session_exists()` before proceeding. The sessions ARE accessible and fully functional via `opencode run --continue --session <session_id>` directly, but `session list` does not return them. ## Reproduction (Minimal) ```bash # 1. Initialize kugetsu kugetsu init # 2. Check status immediately after kugetsu status # Expected: ok # Actual: pm_agent_expired # 3. Try to delegate — also broken kugetsu delegate "ping" # Error: PM agent session has expired. Run kugetsu init again. # 4. But the PM agent IS alive and working when called directly opencode run --continue --session $(cat ~/.kugetsu/sessions/pm-agent.json | python3 -c "import sys,json; print(json.load(sys.stdin)[opencode_session_id])") "ping" # Returns valid response from PM agent ``` ## Extended Verification ```bash # Sessions exist in kugetsu state cat ~/.kugetsu/sessions/base.json cat ~/.kugetsu/sessions/pm-agent.json # But they do not appear in opencode session list opencode session list --format json | grep <pm_session_id> # Returns nothing — yet the session works! ``` ## Environment - opencode: (latest, includes --format json) - kugetsu: latest from git (main branch) - OS: Linux ## Fix Options **Option A (kugetsu):** Replace existence check with a no-op run call: ```bash opencode run --continue --session <id> "echo" 2>/dev/null && echo "alive" || echo "dead" ``` **Option B (opencode):** Include forked sessions in `opencode session list` output. ## Workaround Call `opencode run --continue --session <id>` directly instead of using `kugetsu delegate`. The PM agent is alive and functional — only the existence check is broken.
shoko closed this issue 2026-03-31 07:33:34 +02:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: shoko/kugetsu#38