Repository navigation
Fix /subagents list requester resolution for native commands - #33579
liuxiaopai-ai wants to merge 1 commit into
Conversation
Greptile SummaryThis PR fixes a session-resolution bug in the Key changes:
Notable observation: The other run-targeting actions ( Confidence Score: 4/5
Last reviewed commit: 5de5247 |
| const requesterKey = resolveRequesterSessionKey(params, { | ||
| preferCommandTarget: action === "spawn", | ||
| preferCommandTarget: action === "spawn" || action === "list", | ||
| }); |
There was a problem hiding this comment.
Other mutating actions may have the same session-resolution gap
list now correctly prefers CommandTargetSessionKey for native routing, but ctx.runs is built from requesterKey and shared by every action in the switch. When kill, info, log, send, steer, focus, and unfocus are invoked natively (i.e., CommandTargetSessionKey is present but preferCommandTarget is still false for them), requesterKey resolves to the transient slash-command session. Any index-based targeting (e.g., /subagents kill 1) would then search against that wrong run list and likely fail to find the intended subagent.
Consider extending the preferCommandTarget guard to all actions that operate on specific runs, or extracting a helper that maps action → preferCommandTarget to make future additions explicit:
const preferCommandTarget =
action === "spawn" ||
action === "list" ||
action === "kill" ||
action === "info" ||
action === "log" ||
action === "send" ||
action === "steer" ||
action === "focus" ||
action === "unfocus";If there is a deliberate reason to keep those actions on the slash-command session, a brief comment here would help future reviewers understand the intent.
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/auto-reply/reply/commands-subagents.ts
Line: 50-52
Comment:
**Other mutating actions may have the same session-resolution gap**
`list` now correctly prefers `CommandTargetSessionKey` for native routing, but `ctx.runs` is built from `requesterKey` and shared by every action in the switch. When `kill`, `info`, `log`, `send`, `steer`, `focus`, and `unfocus` are invoked natively (i.e., `CommandTargetSessionKey` is present but `preferCommandTarget` is still `false` for them), `requesterKey` resolves to the transient slash-command session. Any **index-based targeting** (e.g., `/subagents kill 1`) would then search against that wrong run list and likely fail to find the intended subagent.
Consider extending the `preferCommandTarget` guard to all actions that operate on specific runs, or extracting a helper that maps action → `preferCommandTarget` to make future additions explicit:
```ts
const preferCommandTarget =
action === "spawn" ||
action === "list" ||
action === "kill" ||
action === "info" ||
action === "log" ||
action === "send" ||
action === "steer" ||
action === "focus" ||
action === "unfocus";
```
If there is a deliberate reason to keep those actions on the slash-command session, a brief comment here would help future reviewers understand the intent.
How can I resolve this? If you propose a fix, please make it concise.There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 5de52479b9
ℹ️ 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".
|
|
||
| const requesterKey = resolveRequesterSessionKey(params, { | ||
| preferCommandTarget: action === "spawn", | ||
| preferCommandTarget: action === "spawn" || action === "list", |
There was a problem hiding this comment.
Align native subagent requester resolution across actions
/subagents list now resolves runs from CommandTargetSessionKey, but follow-up management commands (/kill, /steer, /subagents info, etc.) still resolve from the transient command session because only action === "list" was added to preferCommandTarget. In native slash flows where SessionKey and CommandTargetSessionKey differ (for example src/slack/monitor/slash.ts sets SessionKey to slash:<user> and CommandTargetSessionKey to the routed conversation), users can list target-session runs but immediately fail to act on them via index/id in the next command, since those commands query a different requester scope.
Useful? React with 👍 / 👎.
Summary
CommandTargetSessionKeyfor/subagents listrequester resolution (matching existing/subagents spawnnative routing behavior)/subagents listregression coverage to assert target-session runs are listed instead of transient slash-session runs2026.3.3fixes for Native /subagents list resolves requester to slash session instead of CommandTargetSessionKey #33508Testing
pnpm vitest src/auto-reply/reply/commands.test.ts src/auto-reply/reply/commands-subagents-spawn.test.tspnpm format:checkCloses #33508