Skip to content

fix: allow idle while delegated subagents run#1722

Merged
Yeachan-Heo merged 1 commit intodevfrom
fix/issue-1721-hook-isolation
Mar 17, 2026
Merged

fix: allow idle while delegated subagents run#1722
Yeachan-Heo merged 1 commit intodevfrom
fix/issue-1721-hook-isolation

Conversation

@Yeachan-Heo
Copy link
Owner

Summary

  • allow the skill-active stop hook to skip reinforcement while delegated subagents are still running
  • preserve skill-active state and reinforcement counters so enforcement resumes after agents finish
  • cover the regression in skill-state, persistent-mode integration, and persistent-mode.cjs script tests

Testing

  • npm test -- --run src/hooks/skill-state/tests/skill-state.test.ts src/hooks/persistent-mode/tests/skill-state-stop.test.ts src/hooks/persistent-mode/stop-hook-blocking.test.ts
  • npm run build
  • npm run lint

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 5ec0aada52

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

// Orchestrators are allowed to go idle while delegated work is still active.
// Do not consume a reinforcement here; the skill is still active and should
// resume enforcement only after the running subagents finish.
if (getActiveAgentCount(directory) > 0) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Scope subagent bypass to the current session

This new bypass disables skill stop-enforcement whenever getActiveAgentCount(directory) > 0, but that count is repo-global (subagent-tracking.json) and not tied to sessionId. In a project with concurrent sessions, a running subagent from session B will make session A skip blocking even while A’s skill is still active, so the active skill can be stopped prematurely. The bypass needs session-aware filtering (or equivalent ownership checks) before returning.

Useful? React with 👍 / 👎.

// Do not consume a reinforcement here; the skill is still active and should
// resume enforcement only after the running subagents finish.
if (getActiveAgentCount(directory) > 0) {
return { shouldBlock: false, message: '', skillName: state.skill_name };

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Refresh heartbeat before returning for running subagents

The early return for running subagents skips updating last_checked_at, but staleness is evaluated first on every call. If delegated agents run longer than stale_ttl_ms, the next stop check clears skill-active-state as stale and enforcement never resumes after those agents finish, which contradicts the intended “pause and resume” behavior. Update last_checked_at (without incrementing reinforcements) before this return to preserve state through long delegations.

Useful? React with 👍 / 👎.

@Yeachan-Heo Yeachan-Heo merged commit aced09d into dev Mar 17, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant