docs: document sessions tools tests · openclaw/openclaw@0f73e09
steipete
·
2026-06-05
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
|
| 1 | +// Sessions access tests cover session-tool visibility policy, sandbox clamps, |
| 2 | +// and agent-to-agent allow rules. |
1 | 3 | import { describe, expect, it, vi } from "vitest"; |
2 | 4 | import type { OpenClawConfig } from "../../config/config.js"; |
3 | 5 | import { |
@@ -168,6 +170,8 @@ describe("createAgentToAgentPolicy", () => {
|
168 | 170 | }); |
169 | 171 | |
170 | 172 | it("handles multiple wildcards without polynomial backtracking", () => { |
| 173 | +// Allow patterns use segment matching rather than a greedy regex so |
| 174 | +// adversarial agent ids cannot cause slow policy checks. |
171 | 175 | const policy = createAgentToAgentPolicy({ |
172 | 176 | tools: { |
173 | 177 | agentToAgent: { |
|
| Original file line number | Diff line number | Diff line change |
|---|
|
| 1 | +// sessions_history tool tests cover recall redaction and input validation for |
| 2 | +// session transcript history returned to models. |
1 | 3 | import fs from "node:fs"; |
2 | 4 | import os from "node:os"; |
3 | 5 | import path from "node:path"; |
@@ -58,6 +60,8 @@ describe("sessions_history redaction", () => {
|
58 | 60 | }); |
59 | 61 | |
60 | 62 | it("redacts recalled session text even when log redaction is disabled", async () => { |
| 63 | +// Recalled transcript content is model-visible, so it is always redacted |
| 64 | +// even when normal logging redaction is configured off. |
61 | 65 | useLoggingConfig("redaction-off.json", { redactSensitive: "off" }); |
62 | 66 | const tool = createHistoryToolWithMessage("OPENROUTER_API_KEY=sk-or-v1-abcdef0123456789"); |
63 | 67 | |
|
| Original file line number | Diff line number | Diff line change |
|---|
|
| 1 | +// Sessions resolution tests cover alias mapping, session-id lookup, visibility |
| 2 | +// verification, and requester-spawned access checks. |
1 | 3 | import { beforeAll, beforeEach, describe, expect, it, vi } from "vitest"; |
2 | 4 | import type { OpenClawConfig } from "../../config/config.js"; |
3 | 5 | const callGatewayMock = vi.fn(); |
@@ -218,6 +220,8 @@ describe("resolved session visibility checks", () => {
|
218 | 220 | }); |
219 | 221 | |
220 | 222 | it("does not hide an exact spawned target behind the sessions.list visibility cap", async () => { |
| 223 | +// Exact spawned-session resolution should not depend on a truncated list |
| 224 | +// response; otherwise high-volume session stores hide valid children. |
221 | 225 | callGatewayMock.mockImplementation( |
222 | 226 | async (request: { method?: string; params?: { key?: string } }) => { |
223 | 227 | if (request.method === "sessions.resolve") { |
|
| Original file line number | Diff line number | Diff line change |
|---|
|
| 1 | +// sessions_send helper tests cover session-key target parsing and ping-pong |
| 2 | +// turn limits for agent-to-agent announce flows. |
1 | 3 | import { beforeEach, describe, expect, it } from "vitest"; |
2 | 4 | import { setActivePluginRegistry } from "../../plugins/runtime.js"; |
3 | 5 | import { createSessionConversationTestRegistry } from "../../test-utils/session-conversation-registry.js"; |
@@ -40,6 +42,8 @@ describe("resolveAnnounceTargetFromKey", () => {
|
40 | 42 | }); |
41 | 43 | |
42 | 44 | it("preserves colon-delimited matrix ids for channel and thread targets", () => { |
| 45 | +// Matrix room/thread ids can contain colons, so parsing must split only on |
| 46 | +// known wrappers instead of generic colon segments. |
43 | 47 | expect( |
44 | 48 | resolveAnnounceTargetFromKey( |
45 | 49 | "agent:main:matrix:channel:!room:example.org:thread:$AbC123:example.org", |
|
| Original file line number | Diff line number | Diff line change |
|---|
|
| 1 | +// sessions_send A2A tests cover announce delivery, same-session replies, delayed |
| 2 | +// reply baselines, and channel target/account routing. |
1 | 3 | import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; |
2 | 4 | import type { CallGatewayOptions } from "../../gateway/call.js"; |
3 | 5 | import { setActivePluginRegistry } from "../../plugins/runtime.js"; |
@@ -196,6 +198,8 @@ describe("runSessionsSendA2AFlow announce delivery", () => {
|
196 | 198 | }); |
197 | 199 | |
198 | 200 | it("does not direct-deliver a delayed same-session reply without a baseline", async () => { |
| 201 | +// Without a baseline fingerprint, a delayed assistant reply may be stale; |
| 202 | +// avoid direct delivery unless freshness is provable. |
199 | 203 | vi.mocked(readLatestAssistantReplySnapshot).mockResolvedValueOnce({ |
200 | 204 | text: "Maybe stale channel reply", |
201 | 205 | fingerprint: "maybe-stale-channel-reply", |
|
| Original file line number | Diff line number | Diff line change |
|---|
|
| 1 | +// Sessions tool tests cover list/send helpers, transcript path reporting, |
| 2 | +// announce-target resolution, and assistant-visible text sanitization. |
1 | 3 | import os from "node:os"; |
2 | 4 | import path from "node:path"; |
3 | 5 | import { MAX_TIMER_TIMEOUT_MS } from "@openclaw/normalization-core/number-coercion"; |
@@ -236,6 +238,7 @@ async function withStubbedStateDir<T>(
|
236 | 238 | |
237 | 239 | describe("sanitizeTextContent", () => { |
238 | 240 | it("strips minimax tool call XML and downgraded markers", () => { |
| 241 | +// Session recall should not replay provider/tool markup as assistant text. |
239 | 242 | const input = |
240 | 243 | 'Hello <invoke name="tool">payload</invoke></minimax:tool_call> ' + |
241 | 244 | "[Tool Call: foo (ID: 1)] world"; |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。