Skip to content

Commit f64fcca

Browse files
committed
fix(agents): keep wave-1 contract schemas module-local and type-exact
1 parent e4a183b commit f64fcca

10 files changed

Lines changed: 18 additions & 18 deletions

‎config/knip.config.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ const rootEntries = [
102102
"src/agents/compaction-planning.worker.ts!",
103103
"scripts/print-cli-backend-live-metadata.ts!",
104104
"scripts/repro/code-mode-namespace-live.ts!",
105+
"scripts/repro/tool-schema-hint-bench.ts!",
105106
"scripts/repro/tool-surface-live-bench.ts!",
106107
// Workflow/package-script entrypoints are not imported from production modules.
107108
"scripts/openclaw-cross-os-release-checks.ts!",

‎scripts/repro/tool-schema-hint-bench.ts‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,13 +80,15 @@ function buildCatalogTools(): AnyAgentTool[] {
8080
const tools: AnyAgentTool[] = [];
8181
for (let index = 0; index < CATALOG_TOOL_COUNT; index += 1) {
8282
const declareOutput = index % 3 === 0;
83+
const name = `bench_tool_${String(index).padStart(2, "0")}`;
8384
const tool = {
84-
name: `bench_tool_${String(index).padStart(2, "0")}`,
85+
name,
86+
label: name,
8587
description: `Benchmark tool ${index} exercising catalog compaction cost.`,
8688
parameters: TypicalInputSchema,
8789
...(declareOutput ? { outputSchema: TypicalOutputSchema } : {}),
88-
execute: async () => jsonResult({ ok: true }),
89-
} as AnyAgentTool;
90+
execute: async (_toolCallId: string, _params: unknown) => jsonResult({ ok: true }),
91+
} satisfies AnyAgentTool;
9092
setPluginToolMeta(tool, { pluginId: "bench-hints", optional: true });
9193
tools.push(tool);
9294
}

‎src/agents/tools/openclaw-delegate-tool.test.ts‎

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,7 @@ import { beforeEach, describe, expect, it, vi } from "vitest";
33
import { GATEWAY_OWNER_ONLY_CORE_TOOLS } from "../../security/dangerous-tools.js";
44
import { compactToolOutputHint } from "../tool-schema-hints.js";
55
import { callInProcessGatewayTool } from "./in-process-gateway.js";
6-
import {
7-
createOpenClawDelegateToolsForRun,
8-
OpenClawDelegateOutputSchema,
9-
} from "./openclaw-delegate-tool.js";
6+
import { createOpenClawDelegateToolsForRun } from "./openclaw-delegate-tool.js";
107

118
vi.mock("./in-process-gateway.js", () => ({
129
callInProcessGatewayTool: vi.fn(),
@@ -52,7 +49,7 @@ describe("openclaw delegation tool", () => {
5249
needsApproval: true,
5350
proposalId: "system-agent:proposal-1",
5451
});
55-
expect(tool.outputSchema).toBe(OpenClawDelegateOutputSchema);
52+
expect(tool.outputSchema).toBeDefined();
5653
expect(Value.Check(tool.outputSchema!, result.details)).toBe(true);
5754
expect(compactToolOutputHint(tool.outputSchema)).toBe(
5855
"{ reply: string; action?: string; needsApproval?: true; proposalId?: string }",

‎src/agents/tools/openclaw-delegate-tool.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const OpenClawDelegateSchema = Type.Object({
1010
sessionId: Type.Optional(Type.String({ description: "Continue prior OpenClaw talk." })),
1111
});
1212

13-
export const OpenClawDelegateOutputSchema = Type.Object(
13+
const OpenClawDelegateOutputSchema = Type.Object(
1414
{
1515
reply: Type.String(),
1616
action: Type.Optional(Type.String()),

‎src/agents/tools/sessions-search-tool.test.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { afterEach, describe, expect, it } from "vitest";
44
import type { callGateway as gatewayCall } from "../../gateway/call.js";
55
import { sessionVisibilityGatewayTesting } from "../../plugin-sdk/session-visibility.js";
66
import { compactToolOutputHint } from "../tool-schema-hints.js";
7-
import { createSessionsSearchTool, SessionsSearchOutputSchema } from "./sessions-search-tool.js";
7+
import { createSessionsSearchTool } from "./sessions-search-tool.js";
88

99
type CallGatewayRequest = Parameters<typeof gatewayCall>[0];
1010

@@ -92,7 +92,7 @@ describe("sessions_search tool", () => {
9292
sessionKey: "01234567-89ab-4def-8123-456789abcdef",
9393
});
9494

95-
expect(tool.outputSchema).toBe(SessionsSearchOutputSchema);
95+
expect(tool.outputSchema).toBeDefined();
9696
expect(Value.Check(tool.outputSchema!, success.details)).toBe(true);
9797
expect(error.details).toMatchObject({ status: "error", error: expect.any(String) });
9898
expect(Value.Check(tool.outputSchema!, error.details)).toBe(true);

‎src/agents/tools/sessions-search-tool.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ const SessionsSearchHitSchema = Type.Object(
5656
{ additionalProperties: false },
5757
);
5858

59-
export const SessionsSearchOutputSchema = Type.Union([
59+
const SessionsSearchOutputSchema = Type.Union([
6060
Type.Object(
6161
{
6262
results: Type.Array(SessionsSearchHitSchema),

‎src/agents/tools/task-suggestion-tools.test.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Value } from "typebox/value";
22
import { describe, expect, it, vi } from "vitest";
33
import { compactToolOutputHint } from "../tool-schema-hints.js";
4-
import { createTaskSuggestionTools, SpawnTaskOutputSchema } from "./task-suggestion-tools.js";
4+
import { createTaskSuggestionTools } from "./task-suggestion-tools.js";
55

66
function createTools(gatewayCall = vi.fn()) {
77
return {
@@ -43,7 +43,7 @@ describe("task suggestion tools", () => {
4343
expect(result?.content).toEqual([
4444
{ type: "text", text: JSON.stringify({ task_id: "task_123" }, null, 2) },
4545
]);
46-
expect(spawnTask?.outputSchema).toBe(SpawnTaskOutputSchema);
46+
expect(spawnTask?.outputSchema).toBeDefined();
4747
expect(Value.Check(spawnTask!.outputSchema!, result?.details)).toBe(true);
4848
expect(compactToolOutputHint(spawnTask?.outputSchema)).toBe("{ task_id: string }");
4949
expect(tools.find((tool) => tool.name === "dismiss_task")?.outputSchema).toBeUndefined();

‎src/agents/tools/task-suggestion-tools.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ const SpawnTaskToolSchema = Type.Object(
4040
{ additionalProperties: false },
4141
);
4242

43-
export const SpawnTaskOutputSchema = Type.Object(
43+
const SpawnTaskOutputSchema = Type.Object(
4444
{ task_id: Type.String() },
4545
{ additionalProperties: false },
4646
);

‎src/agents/tools/terminal-tool.test.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import type { spawnTerminalPty } from "../../process/terminal-pty.js";
66
import { GATEWAY_OWNER_ONLY_CORE_TOOLS } from "../../security/dangerous-tools.js";
77
import { compactToolOutputHint } from "../tool-schema-hints.js";
88
import type { InProcessGatewayCaller } from "./in-process-gateway.js";
9-
import { createTerminalTool, TerminalToolOutputSchema } from "./terminal-tool.js";
9+
import { createTerminalTool } from "./terminal-tool.js";
1010

1111
type TerminalPtyHandle = Awaited<ReturnType<typeof spawnTerminalPty>>;
1212

@@ -91,7 +91,7 @@ describe("terminal tool", () => {
9191
callGateway,
9292
getGatewayContext: () => makeContext(manager),
9393
});
94-
expect(tool.outputSchema).toBe(TerminalToolOutputSchema);
94+
expect(tool.outputSchema).toBeDefined();
9595
expect(compactToolOutputHint(tool.outputSchema)).toBe(
9696
"{ sessions: Array<{ agentId: string; attached: boolean; createdAtMs: number; cwd: string; owner: string; sessionId: string; shell: string }> } | { agentId: string; cwd: string; ok: true; sessionId: string; shell: string } | { sessionId: string; text: string } | { ok: boolean }",
9797
);

‎src/agents/tools/terminal-tool.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ const TerminalListSessionSchema = Type.Object(
4949
{ additionalProperties: false },
5050
);
5151

52-
export const TerminalToolOutputSchema = Type.Union([
52+
const TerminalToolOutputSchema = Type.Union([
5353
Type.Object({ sessions: Type.Array(TerminalListSessionSchema) }, { additionalProperties: false }),
5454
Type.Object(
5555
{

0 commit comments

Comments
 (0)