fix: honor --to when agent is specified#42009
Conversation
Greptile SummaryThis PR fixes
Confidence Score: 4/5
Last reviewed commit: 48d19c2 |
There was a problem hiding this comment.
Pull request overview
This PR fixes a bug where openclaw agent --agent <id> --to <target> would ignore the --to flag and always collapse to the agent's main session key (agent:<id>:main). The root cause was that resolveSessionKeyForRequest() eagerly fell back to the agent main-session alias when --agent was present, before considering --to.
Changes:
- Refactored session key resolution in
resolveSessionKeyForRequest()to derive an agent-scoped session key from--towhen both--agentand--toare provided, while preserving explicit--session-keyprecedence - Added two regression tests covering the
--agent + --toderivation and the explicit--session-keyguardrail - Added an implementation plan document
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/commands/agent/session.ts | Refactored session key resolution to properly derive agent-scoped keys from --to instead of always collapsing to the main session |
| src/commands/agent/session.test.ts | Added two regression tests for --agent + --to and explicit --session-key precedence |
| docs/plans/2026-03-10-agent-to-session-routing.md | New implementation plan document describing the fix approach |
You can also share your feedback on Copilot code review. Take the survey.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 48d19c2907
ℹ️ About Codex in GitHub
Codex has been enabled to automatically 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 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 388eb52283
ℹ️ About Codex in GitHub
Codex has been enabled to automatically 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 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
11683f0 to
8ed941b
Compare
|
This pull request has been automatically marked as stale due to inactivity. |
|
Thanks for the context here. I swept through the related work, and this is now duplicate or superseded. Close as superseded: this PR targets a real session-routing bug, but the remaining work is now tracked by the open canonical issue and maintainer-owned implementation path, while this branch is conflicting and would regress current session-key contracts if merged as-is. Canonical path: Keep #73403 as the canonical implementation path and close this conflicting branch while preserving its discussion as context. So I’m closing this here and keeping the remaining discussion on #73403 and #41483. Review detailsBest possible solution: Keep #73403 as the canonical implementation path and close this conflicting branch while preserving its discussion as context. Do we have a high-confidence way to reproduce the issue? Yes. Source inspection on current main shows Is this the best way to solve the issue? No. The branch points at a valid bug, but the better solution is the canonical channel-aware resolver fix in #73403 because it covers gateway and embedded paths while preserving current default-agent and session-id contracts. Security review: Security review needs attention: The diff has no dependency or workflow changes, but its direct-target session-key path could persist raw recipient identifiers and should not be merged in this superseded form.
What I checked:
Likely related people:
Codex review notes: model gpt-5.5, reasoning high; reviewed against c93d6d8daa37. |
8ed941b to
09f09a2
Compare
|
Rebased and updated this PR against current main. Ported the routing fix to Verification run: |
09f09a2 to
99e5422
Compare
Summary
Root Cause
esolveSessionKeyForRequest() eagerly fell back to the agent main-session alias when --agent was present, so custom --to values like cw_111 were ignored and all runs reused �gent::main.
Testing
Transparency