mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 17:28:28 +00:00
Fix/agent session key normalization (openclaw#15707) thanks @rodrigouroz
Verified: - pnpm build - pnpm check - pnpm test:macmini Co-authored-by: rodrigouroz <384037+rodrigouroz@users.noreply.github.com> Co-authored-by: Tak Hoffman <781889+Takhoffman@users.noreply.github.com>
This commit is contained in:
@@ -16,7 +16,7 @@ import {
|
||||
resolveAgentDeliveryPlan,
|
||||
resolveAgentOutboundTarget,
|
||||
} from "../../infra/outbound/agent-delivery.js";
|
||||
import { normalizeAgentId } from "../../routing/session-key.js";
|
||||
import { classifySessionKeyShape, normalizeAgentId } from "../../routing/session-key.js";
|
||||
import { defaultRuntime } from "../../runtime.js";
|
||||
import { normalizeInputProvenance, type InputProvenance } from "../../sessions/input-provenance.js";
|
||||
import { resolveSendPolicy } from "../../sessions/send-policy.js";
|
||||
@@ -273,6 +273,20 @@ export const agentHandlers: GatewayRequestHandlers = {
|
||||
typeof request.sessionKey === "string" && request.sessionKey.trim()
|
||||
? request.sessionKey.trim()
|
||||
: undefined;
|
||||
if (
|
||||
requestedSessionKeyRaw &&
|
||||
classifySessionKeyShape(requestedSessionKeyRaw) === "malformed_agent"
|
||||
) {
|
||||
respond(
|
||||
false,
|
||||
undefined,
|
||||
errorShape(
|
||||
ErrorCodes.INVALID_REQUEST,
|
||||
`invalid agent params: malformed session key "${requestedSessionKeyRaw}"`,
|
||||
),
|
||||
);
|
||||
return;
|
||||
}
|
||||
let requestedSessionKey =
|
||||
requestedSessionKeyRaw ??
|
||||
resolveExplicitAgentSessionKey({
|
||||
@@ -601,6 +615,17 @@ export const agentHandlers: GatewayRequestHandlers = {
|
||||
const sessionKeyRaw = typeof p.sessionKey === "string" ? p.sessionKey.trim() : "";
|
||||
let agentId = agentIdRaw ? normalizeAgentId(agentIdRaw) : undefined;
|
||||
if (sessionKeyRaw) {
|
||||
if (classifySessionKeyShape(sessionKeyRaw) === "malformed_agent") {
|
||||
respond(
|
||||
false,
|
||||
undefined,
|
||||
errorShape(
|
||||
ErrorCodes.INVALID_REQUEST,
|
||||
`invalid agent.identity.get params: malformed session key "${sessionKeyRaw}"`,
|
||||
),
|
||||
);
|
||||
return;
|
||||
}
|
||||
const resolved = resolveAgentIdFromSessionKey(sessionKeyRaw);
|
||||
if (agentId && resolved !== agentId) {
|
||||
respond(
|
||||
|
||||
Reference in New Issue
Block a user