Skip to content

fix(permission): forward permission requests from subagent sessions (#129)#131

Merged
grinev merged 1 commit into
grinev:mainfrom
MysticCoss:fix/subagent-permission-129
May 18, 2026
Merged

fix(permission): forward permission requests from subagent sessions (#129)#131
grinev merged 1 commit into
grinev:mainfrom
MysticCoss:fix/subagent-permission-129

Conversation

@MysticCoss
Copy link
Copy Markdown
Contributor

Fixes #129.

Problem

When a sub-agent (Task tool / ULW delegation) requests permission for a
write/edit/bash call, the bot never showed the approval prompt and the
sub-agent hung until OpenCode timed it out.

Root cause

Two sessionID !== currentSessionId filters dropped the event:

  1. summary/aggregator.tshandlePermissionAsked ignored all events
    whose sessionID wasn't the current root session.
  2. bot/index.ts — the setOnPermission callback re-applied the same
    strict check before showing the Telegram message.

A sub-agent runs in its own child session (session.created with
parentID = root), so its sessionID never matched.

Fix

  • aggregator: handlePermissionAsked now also accepts events from
    tracked child sessions (the pattern already used by
    handleSessionIdle / handleSessionError). Adds public
    isSubagentSession(id) for consumers.
  • bot: setOnPermission callback accepts the current session or any
    tracked sub-agent session.
  • Reply path was already session-agnostic (uses requestID +
    directory), no change needed there.

Tests

Two new regression tests in tests/summary/aggregator.test.ts:

  • forwards permission.asked from a tracked subagent child session
  • still ignores permission.asked from unrelated sessions

Full suite: 916/916 passing. tsc --noEmit clean.

…rinev#129)

Permission requests from sub-agent (child) sessions were dropped by two
session-ID filters, so the user never saw the approval prompt and the
sub-agent hung until OpenCode timed it out.

- aggregator: handlePermissionAsked now accepts events from tracked
  child sessions, matching the existing pattern in handleSessionIdle
  and handleSessionError. Exposes isSubagentSession() for consumers.
- bot: setOnPermission callback no longer requires sessionID to equal
  the current root session; tracked sub-agent sessions are accepted.
- tests: regression coverage for both the subagent-permission path and
  the unrelated-session rejection path.
@grinev
Copy link
Copy Markdown
Owner

grinev commented May 18, 2026

@MysticCoss thanks for contribution!

@grinev grinev merged commit a9b185a into grinev:main May 18, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: sub-agent can not write to file due to lack of permission

2 participants