From e5fcd89942cef7006960459bbe0a8bec06dc13fb Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 23 Jul 2026 17:29:42 +0000 Subject: [PATCH 1/3] Initial plan From 9bcd294673c875e7417e0442bb9f8a5b5331b5a6 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 23 Jul 2026 17:33:36 +0000 Subject: [PATCH 2/3] Infer defineTool handler args from schema parameters Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com> --- README.md | 1 + skills/rig/SKILL.md | 1 + skills/rig/rig.ts | 5 +++++ src/rig.test.ts | 8 +++++--- 4 files changed, 12 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 32f7059..874a4ee 100644 --- a/README.md +++ b/README.md @@ -161,6 +161,7 @@ const triage = agent({ ``` Rig defaults agent tools to `skipPermission: true`, and you can also place plain tool objects in `tools`; rig will convert `s.*` parameter schemas into JSON Schema before creating the Copilot session. +When `parameters` uses `s.*` schemas, `handler` args are inferred automatically; for plain JSON Schema, pass an explicit generic like `defineTool<{ issue: string }>(...)`. ## Evaluating agentic performance diff --git a/skills/rig/SKILL.md b/skills/rig/SKILL.md index 84b8b1c..010b41a 100644 --- a/skills/rig/SKILL.md +++ b/skills/rig/SKILL.md @@ -170,6 +170,7 @@ s.nonEmptyArray(s.string) // string[] with at least one element ## Tools Register custom tools with `defineTool` using an SDK-neutral tool shape. Use `s.*` schemas for `parameters`. Rig defaults tools to `skipPermission: true`. +When `parameters` uses `s.*` schemas, `handler` args are inferred automatically; for plain JSON Schema, pass an explicit generic like `defineTool<{ issue: string }>(...)`. ```ts import { agent, defineTool, s } from "rig"; diff --git a/skills/rig/rig.ts b/skills/rig/rig.ts index 00746cd..d45867c 100644 --- a/skills/rig/rig.ts +++ b/skills/rig/rig.ts @@ -540,7 +540,12 @@ export type ToolConfig = { overridesBuiltInTool?: boolean; skipPermission?: boolean; }; +type InferToolArgs = TParameters extends Schema ? InferSchema : unknown; +export function defineTool( + name: string, + config: Omit>, "parameters"> & { parameters: TParameters }, +): Tool>; export function defineTool(name: string, config: ToolConfig): Tool { return { name, diff --git a/src/rig.test.ts b/src/rig.test.ts index 9a53d28..b302ad7 100644 --- a/src/rig.test.ts +++ b/src/rig.test.ts @@ -52,6 +52,7 @@ vi.mock("@github/copilot-sdk", () => ({ })); import { AgentError, PromptBuilder, agent, analyzeResponse, configureAgent, copilotEngine, defineTool, p, s, toJsonSchema } from "rig"; +import type { Tool } from "rig"; import { oncePerAgent, repair, steering, timeout } from "rig/addons"; beforeEach(() => { @@ -537,18 +538,19 @@ describe("agent invocation", () => { }); it("defines tools with rig schemas using the Copilot SDK helper shape", () => { - const handler = vi.fn(async ({ issue }: { issue: string }) => `Issue ${issue}`); const lookupIssue = defineTool("lookup_issue", { description: "Look up an issue by id.", parameters: s.object({ issue: s.string }), - handler, + handler: vi.fn(async ({ issue }) => `Issue ${issue}`), }); + const expectIssueTool = (_tool: Tool<{ issue: string }>) => true; + expect(expectIssueTool(lookupIssue)).toBe(true); expect(lookupIssue).toEqual({ name: "lookup_issue", description: "Look up an issue by id.", parameters: toJsonSchema(s.object({ issue: s.string })), - handler, + handler: expect.any(Function), skipPermission: true, }); }); From 822f67f2448689748056f7326675f4a1b6b37e95 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 23 Jul 2026 17:36:19 +0000 Subject: [PATCH 3/3] Fix defineTool overloads and infer args from schema Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com> --- skills/rig/rig.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/skills/rig/rig.ts b/skills/rig/rig.ts index d45867c..db0c02b 100644 --- a/skills/rig/rig.ts +++ b/skills/rig/rig.ts @@ -546,7 +546,8 @@ export function defineTool( name: string, config: Omit>, "parameters"> & { parameters: TParameters }, ): Tool>; -export function defineTool(name: string, config: ToolConfig): Tool { +export function defineTool(name: string, config: ToolConfig): Tool; +export function defineTool(name: string, config: ToolConfig): Tool { return { name, ...normalizeToolConfig(config),