fix(tools): tolerate duplicate sessionKey/label in sessions_send#64846
fix(tools): tolerate duplicate sessionKey/label in sessions_send#64846Yanhu007 wants to merge 1 commit into
Conversation
LLMs and UI layers (ClawX, Control UI) sometimes mirror the same value into both `sessionKey` and `label` when calling `sessions_send`. This triggers the mutual-exclusion guard even though the intent is unambiguous. Relax the check: only reject when both params are provided AND they differ. When they are equal, treat the call as sessionKey-only (the more specific routing path). Fixes openclaw#64699
Greptile SummaryRelaxes the Confidence Score: 5/5Safe to merge — the change is minimal, well-scoped, and preserves existing rejection behavior for the differing-values case. Only a P2 style observation about asymmetric normalization between sessionKeyParam and labelParam in the equality check; no correctness or behavioral regressions identified. No files require special attention. Prompt To Fix All With AIThis is a comment left during a code review.
Path: src/agents/tools/sessions-send-tool.ts
Line: 109
Comment:
**Asymmetric normalization in equality check**
`sessionKeyParam` is the raw value from `readStringParam` (not trimmed), while `labelParam` passes through `normalizeOptionalString` which calls `.trim()`. A caller that sends the same logical value with incidental whitespace in the `sessionKey` field (e.g. LLM-generated padding) will still hit the error even though the intent matches. Applying the same normalization to both sides before comparison would make the guard consistent.
```suggestion
if (sessionKeyParam && labelParam && sessionKeyParam.trim() !== labelParam) {
```
How can I resolve this? If you propose a fix, please make it concise.Reviews (1): Last reviewed commit: "fix(tools): tolerate duplicate sessionKe..." | Re-trigger Greptile |
| // When sessionKey and label are both provided but equal, treat it as | ||
| // sessionKey-only. LLMs / UI layers sometimes mirror the value into | ||
| // both fields unintentionally (see #64699). | ||
| if (sessionKeyParam && labelParam && sessionKeyParam !== labelParam) { |
There was a problem hiding this comment.
Asymmetric normalization in equality check
sessionKeyParam is the raw value from readStringParam (not trimmed), while labelParam passes through normalizeOptionalString which calls .trim(). A caller that sends the same logical value with incidental whitespace in the sessionKey field (e.g. LLM-generated padding) will still hit the error even though the intent matches. Applying the same normalization to both sides before comparison would make the guard consistent.
| if (sessionKeyParam && labelParam && sessionKeyParam !== labelParam) { | |
| if (sessionKeyParam && labelParam && sessionKeyParam.trim() !== labelParam) { |
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/agents/tools/sessions-send-tool.ts
Line: 109
Comment:
**Asymmetric normalization in equality check**
`sessionKeyParam` is the raw value from `readStringParam` (not trimmed), while `labelParam` passes through `normalizeOptionalString` which calls `.trim()`. A caller that sends the same logical value with incidental whitespace in the `sessionKey` field (e.g. LLM-generated padding) will still hit the error even though the intent matches. Applying the same normalization to both sides before comparison would make the guard consistent.
```suggestion
if (sessionKeyParam && labelParam && sessionKeyParam.trim() !== labelParam) {
```
How can I resolve this? If you propose a fix, please make it concise.|
Codex automated review: keeping this open. Keep open. Current main still has the exact unconditional Best possible solution: Keep this PR open as a valid implementation candidate for #64699. The best landed fix should update What I checked:
Remaining risk / open question:
Codex Review notes: model gpt-5.5, reasoning high; reviewed against 52249927ac2d. |
|
Thanks @Yanhu007. I’m closing this as superseded by #39551 because both PRs address the same Clownfish is keeping #64699 linked as validation context, and this source PR keeps credit for the duplicate-value reproduction. If maintainers decide the narrower equal-values-only behavior is still needed after #39551 lands, please reply and we can reopen or split it back out. |
Summary
When calling
sessions_send, LLMs and UI layers (ClawX, Control UI) sometimes mirror the same value into bothsessionKeyandlabel. This triggers the mutual-exclusion guard even though the intent is unambiguous.Changes
Relax the check: only reject when both params are provided AND they differ. When they are equal, treat the call as sessionKey-only (the more specific routing path).
Testing
sessionKeyandlabelare the same → uses sessionKey, no errorsessionKeyandlabeldiffer → still rejects with existing errorFixes #64699