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:
Rodrigo Uroz
2026-02-15 12:46:14 -03:00
committed by GitHub
parent 75d22b2164
commit df95ddc771
4 changed files with 91 additions and 1 deletions

View File

@@ -285,6 +285,20 @@ describe("gateway server agent", () => {
expect(spy).not.toHaveBeenCalled();
});
test("agent rejects malformed agent-prefixed session keys", async () => {
setRegistry(defaultRegistry);
const res = await rpcReq(ws, "agent", {
message: "hi",
sessionKey: "agent:main",
idempotencyKey: "idem-agent-malformed-key",
});
expect(res.ok).toBe(false);
expect(res.error?.message).toContain("malformed session key");
const spy = vi.mocked(agentCommand);
expect(spy).not.toHaveBeenCalled();
});
test("agent forwards accountId to agentCommand", async () => {
setRegistry(defaultRegistry);
testState.allowFrom = ["+1555"];