Skip to content

fix(tools): tolerate duplicate sessionKey/label in sessions_send#64846

Closed
Yanhu007 wants to merge 1 commit into
openclaw:mainfrom
Yanhu007:fix/sessions-send-dedup-key-label
Closed

fix(tools): tolerate duplicate sessionKey/label in sessions_send#64846
Yanhu007 wants to merge 1 commit into
openclaw:mainfrom
Yanhu007:fix/sessions-send-dedup-key-label

Conversation

@Yanhu007

Copy link
Copy Markdown
Contributor

Summary

When calling sessions_send, LLMs and UI layers (ClawX, Control UI) sometimes mirror the same value into both sessionKey and label. 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

  • When sessionKey and label are the same → uses sessionKey, no error
  • When sessionKey and label differ → still rejects with existing error
  • When only one is provided → unchanged behavior

Fixes #64699

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
@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: XS labels Apr 11, 2026
@greptile-apps

greptile-apps Bot commented Apr 11, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

Relaxes the sessions_send mutual-exclusion guard so that providing equal sessionKey and label values is no longer treated as an error — the call is routed through the sessionKey path instead. This cleanly handles the case where LLMs or UI layers (ClawX, Control UI) mirror the same value into both fields unintentionally. Differing values continue to reject as before.

Confidence Score: 5/5

Safe 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 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.

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) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 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.

Suggested change
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.

@clawsweeper

clawsweeper Bot commented Apr 27, 2026

Copy link
Copy Markdown
Contributor

Codex automated review: keeping this open.

Keep open. Current main still has the exact unconditional sessions_send rejection for any call containing both sessionKey and label, while this PR is a narrow implementation candidate for the linked open bug #64699. The PR is not obsolete or unsafe on the inspected surface, but it should gain focused regression tests and be reconciled with overlapping open attempts before landing.

Best possible solution:

Keep this PR open as a valid implementation candidate for #64699. The best landed fix should update src/agents/tools/sessions-send-tool.ts to treat equal trimmed sessionKey and label values as a sessionKey route, continue rejecting differing values, and add focused regression coverage in the agent tool tests. Maintainers should consolidate this with the overlapping open sessions_send PRs before merge.

What I checked:

Remaining risk / open question:

  • The PR currently has no regression test for equal duplicated values or still-rejected differing values.
  • There are overlapping open sessions_send PRs in the provided related-item context, so maintainers should choose one canonical patch rather than merge competing variants independently.

Codex Review notes: model gpt-5.5, reasoning high; reviewed against 52249927ac2d.

@openclaw-clownfish

Copy link
Copy Markdown
Contributor

Thanks @Yanhu007. I’m closing this as superseded by #39551 because both PRs address the same sessions_send mixed sessionKey/label failure, and #39551 is now the maintained canonical branch for the broader sessionKey-first rule.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling size: XS

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: sessions_send unexpectedly injects label, causing mutual-exclusion error with sessionKey

1 participant