docs: document common agent tool tests · openclaw/openclaw@56ae6d3
steipete
·
2026-06-05
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
|
| 1 | +// agents_list tests cover subagent discovery, runtime metadata, and legacy |
| 2 | +// runtime override handling. |
1 | 3 | import { beforeEach, describe, expect, it, vi } from "vitest"; |
2 | 4 | import type { OpenClawConfig } from "../../config/types.openclaw.js"; |
3 | 5 | import { createAgentsListTool } from "./agents-list-tool.js"; |
@@ -76,6 +78,8 @@ describe("agents_list tool", () => {
|
76 | 78 | }); |
77 | 79 | |
78 | 80 | it("does not advertise stale allowlist-only targets as spawnable agents", async () => { |
| 81 | +// Allowlist entries are permissions, not agent definitions; stale ids should |
| 82 | +// not be presented as runnable subagents. |
79 | 83 | loadConfigMock.mockReturnValue({ |
80 | 84 | agents: { |
81 | 85 | list: [ |
@@ -160,6 +164,8 @@ describe("agents_list tool", () => {
|
160 | 164 | }); |
161 | 165 | |
162 | 166 | it("ignores legacy env-forced plugin runtime selections", async () => { |
| 167 | +// Runtime selection now comes from config/model routing, not a process-wide |
| 168 | +// legacy env override. |
163 | 169 | vi.stubEnv("OPENCLAW_AGENT_RUNTIME", "codex"); |
164 | 170 | loadConfigMock.mockReturnValue({ |
165 | 171 | agents: { |
|
| Original file line number | Diff line number | Diff line change |
|---|
|
| 1 | +// Common tool helper tests cover shared parsing and media result shapes used by |
| 2 | +// multiple agent tools. |
1 | 3 | import { describe, expect, test } from "vitest"; |
2 | 4 | import { imageResult, parseAvailableTags } from "./common.js"; |
3 | 5 | |
@@ -31,6 +33,8 @@ describe("parseAvailableTags", () => {
|
31 | 33 | }); |
32 | 34 | describe("imageResult", () => { |
33 | 35 | test("stores media delivery in details.media instead of MEDIA text", async () => { |
| 36 | +// Binary media should travel through typed content/details, not a textual |
| 37 | +// MEDIA sentinel that providers can display or reinterpret. |
34 | 38 | const result = await imageResult({ |
35 | 39 | label: "test:image", |
36 | 40 | path: "/tmp/test.png", |
|
| Original file line number | Diff line number | Diff line change |
|---|
|
| 1 | +// Embedded gateway stub tests cover in-process gateway methods used by agent |
| 2 | +// tools when no external gateway transport is available. |
1 | 3 | import { beforeEach, describe, expect, it, vi } from "vitest"; |
2 | 4 | import { createEmbeddedCallGateway } from "./embedded-gateway-stub.js"; |
3 | 5 | |
@@ -101,6 +103,8 @@ describe("embedded gateway stub", () => {
|
101 | 103 | }); |
102 | 104 | |
103 | 105 | it("projects embedded chat history through the shared display projector", async () => { |
| 106 | +// Embedded history must use the same projection path as gateway history so |
| 107 | +// byte/message limits and display filtering stay aligned. |
104 | 108 | const rawMessages = [ |
105 | 109 | { role: "user", content: "hello" }, |
106 | 110 | { role: "assistant", content: "hi" }, |
@@ -148,6 +152,8 @@ describe("embedded gateway stub", () => {
|
148 | 152 | }); |
149 | 153 | |
150 | 154 | it("infers embedded global chat history scope from agent-prefixed aliases", async () => { |
| 155 | +// Agent-prefixed global aliases carry the target agent id even when the |
| 156 | +// caller does not pass agentId separately. |
151 | 157 | const callGateway = createEmbeddedCallGateway(); |
152 | 158 | await callGateway<{ messages: unknown[] }>({ |
153 | 159 | method: "chat.history", |
|
| Original file line number | Diff line number | Diff line change |
|---|
|
| 1 | +// Node utility tests cover node selection defaults and gateway fallback between |
| 2 | +// current and legacy node list methods. |
1 | 3 | import { beforeEach, describe, expect, it, vi } from "vitest"; |
2 | 4 | |
3 | 5 | const gatewayMocks = vi.hoisted(() => ({ |
@@ -43,6 +45,8 @@ describe("resolveNodeIdFromList defaults", () => {
|
43 | 45 | }); |
44 | 46 | |
45 | 47 | it("uses stable nodeId ordering when connectedAtMs is unavailable", () => { |
| 48 | +// Deterministic tie-breaking keeps repeated tool calls from bouncing |
| 49 | +// between connected nodes. |
46 | 50 | const nodes: NodeListNode[] = [ |
47 | 51 | node({ nodeId: "z-node", platform: "ios", connectedAtMs: undefined }), |
48 | 52 | node({ nodeId: "a-node", platform: "android", connectedAtMs: undefined }), |
@@ -54,6 +58,8 @@ describe("resolveNodeIdFromList defaults", () => {
|
54 | 58 | |
55 | 59 | describe("listNodes", () => { |
56 | 60 | it("falls back to node.pair.list only when node.list is unavailable", async () => { |
| 61 | +// Old gateways only expose node.pair.list; newer authorization failures |
| 62 | +// must still surface instead of being hidden by fallback. |
57 | 63 | gatewayMocks.callGatewayTool |
58 | 64 | .mockRejectedValueOnce(new Error("unknown method: node.list")) |
59 | 65 | .mockResolvedValueOnce({ |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。