Bug: release_agent_slot not called in nohup subshell #44

Closed
opened 2026-03-31 11:58:51 +02:00 by shoko · 3 comments
Owner

Bug

release_agent_slot is a bash function in kugetsu, but cmd_delegate runs:

nohup sh -c "opencode run ...; release_agent_slot"

sh -c spawns a new shell where release_agent_slot is not defined.

Symptom

Agent count increments but never decrements after task completes.

Fix

Change sh -c to bash -c and source kugetsu before calling release_agent_slot.

## Bug release_agent_slot is a bash function in kugetsu, but cmd_delegate runs: ``` nohup sh -c "opencode run ...; release_agent_slot" ``` sh -c spawns a new shell where release_agent_slot is not defined. ## Symptom Agent count increments but never decrements after task completes. ## Fix Change `sh -c` to `bash -c` and source kugetsu before calling release_agent_slot.
Author
Owner

Test Results

Fix verified: Changed sh -c to bash -c and added source $(which kugetsu) before release_agent_slot.

Test: 3 quick delegates, count went 0 -> 3 -> 0 after ~10-15 seconds. Release works correctly now.

Note: There is a ~10-15 second delay before release happens because sourcing the full kugetsu script takes time. Could optimize by extracting release_agent_slot to a separate lightweight script.

## Test Results Fix verified: Changed `sh -c` to `bash -c` and added `source $(which kugetsu)` before `release_agent_slot`. Test: 3 quick delegates, count went 0 -> 3 -> 0 after ~10-15 seconds. Release works correctly now. Note: There is a ~10-15 second delay before release happens because sourcing the full kugetsu script takes time. Could optimize by extracting `release_agent_slot` to a separate lightweight script.

I heard that changing sh -c to bash -c introduce a new error. can you check?

I heard that changing sh -c to bash -c introduce a new error. can you check?
Author
Owner

Investigation Result

The release-slot.sh script still exists and is called by cmd_delegate (line 576), but:

  1. cmd_delegate uses acquire_agent_slot() + release-slot.sh (old slot mechanism)
  2. cmd_start uses count_active_dev_sessions() (new session-counting)

These are inconsistent - delegate is still using the broken slot approach while start uses proper session-counting.

Recommendation

Remove slot-based counting from cmd_delegate since:

  • Session-counting is the proper approach (enforced in cmd_start)
  • Delegate creates PM agent sessions which are already counted
  • PM agent spawning dev agents adds to session count naturally

This may be why #63 seemed partially fixed but issues persisted.

## Investigation Result The `release-slot.sh` script still exists and is called by `cmd_delegate` (line 576), but: 1. **cmd_delegate** uses `acquire_agent_slot()` + `release-slot.sh` (old slot mechanism) 2. **cmd_start** uses `count_active_dev_sessions()` (new session-counting) These are **inconsistent** - delegate is still using the broken slot approach while start uses proper session-counting. ## Recommendation Remove slot-based counting from `cmd_delegate` since: - Session-counting is the proper approach (enforced in cmd_start) - Delegate creates PM agent sessions which are already counted - PM agent spawning dev agents adds to session count naturally This may be why #63 seemed partially fixed but issues persisted.
shoko closed this issue 2026-04-01 12:02:28 +02:00
Sign in to join this conversation.
2 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: shoko/kugetsu#44