fix: allow idle while delegated subagents run#1722
Conversation
There was a problem hiding this comment.
💡 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) { |
There was a problem hiding this comment.
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 }; |
There was a problem hiding this comment.
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 👍 / 👎.
Summary
Testing