Skip to content

fix: prefer sessionKey over label in sessions_send instead of rejecting both#41255

Closed
he-yufeng wants to merge 1 commit into
openclaw:mainfrom
he-yufeng:fix/sessions-send-dual-params
Closed

fix: prefer sessionKey over label in sessions_send instead of rejecting both#41255
he-yufeng wants to merge 1 commit into
openclaw:mainfrom
he-yufeng:fix/sessions-send-dual-params

Conversation

@he-yufeng

Copy link
Copy Markdown
Contributor

Summary

Fixes #41199 (sessions_send portion).

When an LLM calls sessions_send with both sessionKey and label parameters, the tool currently returns an error: "Provide either sessionKey or label (not both)." This breaks agent-to-agent communication because LLMs consistently fill both optional parameters — confirmed across GPT, Kimi, and DeepSeek models.

What changed

Instead of rejecting the call, prefer sessionKey when both are provided. The existing fallback logic at line 74 (if (!sessionKey && labelParam)) already handles the label-only path correctly, so when sessionKey is present, labelParam is naturally ignored.

This is the least invasive fix — strictly more permissive, no behavior change for single-param calls.

Note on Issue 2 (message tool poll params)

Issue #41199 also describes a similar problem with the message tool rejecting action: "send" when poll parameters are present. That fix involves a different trade-off (silently ignoring poll params vs auto-switching action) and is better addressed in a separate PR after discussion.

Test plan

  • sessions_send with only sessionKey → works as before
  • sessions_send with only label → works as before
  • sessions_send with both sessionKey and label → uses sessionKey, no error
  • Agent-to-agent communication works across multiple models

…ns_send

LLMs consistently provide both optional sessionKey and label params
when calling sessions_send, triggering an unnecessary "Provide either
sessionKey or label (not both)" error. This breaks agent-to-agent
communication across multiple models (GPT, Kimi, DeepSeek).

When both are provided, prefer sessionKey and ignore label — the
existing fallback logic already handles the label-only path correctly.

Fixes openclaw#41199 (sessions_send portion)
@greptile-apps

greptile-apps Bot commented Mar 9, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR removes the strict mutual-exclusivity check between sessionKey and label in sessions_send, replacing it with a simple preference: when both parameters are supplied, sessionKey wins and label is silently ignored. The motivation is solid — LLMs (GPT, Kimi, DeepSeek) reliably populate all optional parameters, causing spurious tool-call failures for agent-to-agent communication.

Key observations:

  • The change is minimal (7 lines removed, 4 added) and only affects the error-guard path; all existing single-parameter flows are unaffected.
  • The existing fallback if (!sessionKey && labelParam) already naturally handles the "label only" path, so the preference logic is implicit and correct.
  • agentId (used only in label resolution) is also silently ignored when sessionKey takes precedence, which is the right behavior.
  • No new error paths are introduced; the downstream if (!sessionKey) guard at line 149 still catches the case where neither parameter is provided.

Confidence Score: 5/5

  • This PR is safe to merge — it is a strictly additive, backward-compatible relaxation of an overly strict validation.
  • The diff is tiny (one removed guard block, one comment), the logic is straightforward, no existing behavior changes, and the downstream safety net (if (!sessionKey)) remains intact. All three original call patterns (key-only, label-only, both) are handled correctly.
  • No files require special attention.

Last reviewed commit: 5e5f3b8

@openclaw-barnacle

Copy link
Copy Markdown

This pull request has been automatically marked as stale due to inactivity.
Please add updates or it will be closed.

@openclaw-barnacle openclaw-barnacle Bot added the stale Marked as stale due to inactivity label Apr 26, 2026
@clawsweeper

clawsweeper Bot commented Apr 27, 2026

Copy link
Copy Markdown
Contributor

Codex automated review: keeping this open.

Keep open. Current main at a253660 still rejects sessions_send calls that include both sessionKey and label, so this PR's intended behavior is not implemented. The PR remains a plausible implementation candidate for the sessions_send portion of #41199, though it should gain a focused regression test or be superseded by one of the duplicate PRs that already includes coverage.

Best possible solution:

Keep this PR open as a valid implementation candidate until maintainers choose and merge one canonical sessions_send precedence fix. The best path is to land a narrow change that removes the dual-selector rejection, proves sessionKey wins when both selectors are present, preserves label-only behavior and missing-target errors, and then close duplicate PRs plus the sessions_send portion of #41199.

What I checked:

Remaining risk / open question:

  • This PR does not add a focused regression test for the sessionKey plus label path; a duplicate PR with equivalent behavior and coverage may be the better merge target.
  • The behavior intentionally becomes more permissive when callers pass mismatched sessionKey and label; maintainers should lock in and document that sessionKey is authoritative, while relying on the existing downstream visibility and A2A policy checks.

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

@openclaw-clownfish

Copy link
Copy Markdown
Contributor

Thanks @he-yufeng. I’m closing this as superseded by #39551 because both PRs target the same sessions_send mixed sessionKey/label rejection, and #39551 is now the maintained canonical contributor branch for the sessionKey-first fix.

Clownfish is keeping the canonical review path on #39551 so validation, follow-up, and contributor credit stay in one place. Credit for this narrow fix remains in this source PR. If this branch covers a distinct behavior that still reproduces 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.

Agent-to-Agent Communication Tools Have Parameter Conflicts

1 participant