fix(sessions_send): prefer sessionKey over label when both are present (AI-assisted)#56203
fix(sessions_send): prefer sessionKey over label when both are present (AI-assisted)#56203RevisitMoon wants to merge 4 commits into
Conversation
Greptile SummaryThis PR removes a strict mutual-exclusion guard in Key points:
Confidence Score: 5/5Safe to merge — the fix is correct, the security model is unchanged, and regression coverage is in place. All findings are P2 (a single wording nit in a comment). The core behavioral change is sound: the label-resolution block is only entered when sessionKey is absent, the cross-agent visibility guard is applied unconditionally, and the new test locks in the preference ordering. No correctness, data-integrity, or security concerns were identified. No files require special attention.
|
| Filename | Overview |
|---|---|
| src/agents/tools/sessions-send-tool.ts | Removes the hard-fail guard for simultaneous sessionKey + label, instead silently preferring sessionKey. Cross-agent visibility guard (createSessionVisibilityGuard) is still applied on the resolved key, so the security model is intact. |
| src/agents/tools/sessions.test.ts | Adds a focused regression test covering the sessionKey-wins-over-label path; asserts sessions.resolve is never called and the full send/wait/history flow completes normally. |
Prompt To Fix All With AI
This is a comment left during a code review.
Path: src/agents/tools/sessions-send-tool.ts
Line: 98-99
Comment:
**Minor wording nit in comment**
The phrase `"sessionKey is the less ambiguous selector"` is technically correct English ("less ambiguous" = "more precise"), but it reads a bit awkwardly in context—"the more explicit selector" or "the unambiguous selector" would match the PR description's own phrasing and be immediately clear at a glance.
```suggestion
// Be tolerant when upstream adapters or model tool-call layers redundantly send both.
// sessionKey is the more explicit selector, so prefer it and ignore label when present.
```
How can I resolve this? If you propose a fix, please make it concise.Reviews (1): Last reviewed commit: "fix(sessions_send): prefer sessionKey ov..." | Re-trigger Greptile
| // Be tolerant when upstream adapters or model tool-call layers redundantly send both. | ||
| // sessionKey is the less ambiguous selector, so prefer it and ignore label when present. |
There was a problem hiding this comment.
The phrase "sessionKey is the less ambiguous selector" is technically correct English ("less ambiguous" = "more precise"), but it reads a bit awkwardly in context—"the more explicit selector" or "the unambiguous selector" would match the PR description's own phrasing and be immediately clear at a glance.
| // Be tolerant when upstream adapters or model tool-call layers redundantly send both. | |
| // sessionKey is the less ambiguous selector, so prefer it and ignore label when present. | |
| // Be tolerant when upstream adapters or model tool-call layers redundantly send both. | |
| // sessionKey is the more explicit selector, so prefer it and ignore label when present. |
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/agents/tools/sessions-send-tool.ts
Line: 98-99
Comment:
**Minor wording nit in comment**
The phrase `"sessionKey is the less ambiguous selector"` is technically correct English ("less ambiguous" = "more precise"), but it reads a bit awkwardly in context—"the more explicit selector" or "the unambiguous selector" would match the PR description's own phrasing and be immediately clear at a glance.
```suggestion
// Be tolerant when upstream adapters or model tool-call layers redundantly send both.
// sessionKey is the more explicit selector, so prefer it and ignore label when present.
```
How can I resolve this? If you propose a fix, please make it concise.Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
|
This fix directly resolves a critical failure path in multi-agent orchestration workflows where the Verified against our internal agent coordination pipeline — the change is minimal (+47/-7), semantically correct, and has solid test coverage. A clear Requesting maintainer review. Thanks! |
|
Thanks @RevisitMoon. I’m closing this as superseded by #39551 because both PRs implement the same Clownfish is keeping review and validation on #39551. The regression coverage and discussion here remain credited source PR context for the canonical path. If this still covers a distinct reproduction after #39551 lands, please reply and we can reopen or split it back out. |
Summary
sessions_sendexposed bothsessionKeyandlabelin its tool schema, but hard-failed when both were present.sessionKeyis a precise target.sessions_sendnow preferssessionKeywhen both fields are present and only falls back tolabelresolution whensessionKeyis absent.Change Type (select all)
Scope (select all touched areas)
Linked Issue/PR
Root Cause / Regression History (if applicable)
sessions_sendaccepted bothsessionKeyandlabelin its schema but treated their coexistence as an error, even though upstream tool-call adapters / hook-based param merging can legitimately surface both.git blame, prior PR, issue, or refactor if known): not fully traced to a single introducing change; reviewed currentsessions_sendimplementation plus surrounding tool adapter / before_tool_call paths.sessionKeyintolabel; the failure appears to come from interface fragility rather than one single injector.Regression Test Plan (if applicable)
src/agents/tools/sessions.test.tssessionKeyandlabelare both present,sessions_sendshould prefersessionKey, skipsessions.resolve, and complete normallysessionKey-only andlabel-only flows, but not coexistenceUser-visible / Behavior Changes
sessions_sendno longer errors withProvide either sessionKey or label (not both)when both fields are present.sessionKeywins.labelremains supported as a fallback targeting mechanism whensessionKeyis absent.Diagram (if applicable)
Security Impact (required)
No)No)No)Yes)No)Yes, explain risk + mitigation:This changes tool execution behavior for
sessions_sendconflict handling.Risk: callers that relied on the previous strict error could now proceed.
Mitigation: the new behavior prefers the more explicit selector (
sessionKey) and preserves all existing visibility, agent-to-agent policy, and label-only resolution checks.Repro + Verification
Environment
ai/gpt-5.4exploretomainSteps
sessions_sendwith bothsessionKeyandlabelmainExpected
sessionKeylabelis also presentsessionKeyis absentActual
Provide either sessionKey or label (not both)sessionKeyEvidence
Evidence gathered:
src/agents/tools/sessions.test.ts→ 19 passedsrc/agents/openclaw-tools.sessions.test.ts→ 24 passedsrc/gateway/server.sessions-send.test.ts→ 2 passedRuntime validation:
sessions_sendfromexplore -> mainfailed withProvide either sessionKey or label (not both)timeoutSeconds=10→ reached send/wait flow, returnedtimeouttimeoutSeconds=30→ returnedstatus: "ok", reply: "收到2"This confirms the original parameter-conflict bug is fixed.
Human Verification (required)
src/agents/tools/sessions-send-tool.tssessionKeyonly still workslabelonly still workssessionKey + labelnow usessessionKeypnpm checkpnpm testReview Conversations
Compatibility / Migration
Yes)No)No)Risks and Mitigations
Risk:
sessionKeyis the more explicit selector, so preferring it is deterministic and safer than failing on redundant input.Risk: