Skip to content

Infer defineTool handler args from parameters schema#68

Merged
pelikhan merged 3 commits into
mainfrom
copilot/rig-tasks-daily-evaluation-2026-07-23-one-more-time
Jul 23, 2026
Merged

Infer defineTool handler args from parameters schema#68
pelikhan merged 3 commits into
mainfrom
copilot/rig-tasks-daily-evaluation-2026-07-23-one-more-time

Conversation

Copilot AI commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Daily rig evaluation surfaced a recurring defineTool usability failure: handlers that destructure args required duplicate explicit generics despite parameters already carrying type information. This change makes defineTool infer handler arg types from rig s.* schemas while preserving existing behavior for tools without parameters and plain JSON Schema configs.

  • API typing update

    • Added a schema-aware defineTool overload that maps parameters to handler arg types via InferSchema.
    • Kept a fallback overload so existing calls like defineTool("x", { handler }) and explicit generic usage continue to typecheck.
  • Regression coverage

    • Updated tool-definition tests to validate inferred destructured handler args without manual annotation.
    • Added a type-level assertion that inferred tool types match expected handler arg shape.
  • Docs clarity

    • Updated README.md and skills/rig/SKILL.md to document:
      • inference when using rig s.* schemas
      • explicit generic guidance for plain JSON Schema
const lookupIssue = defineTool("lookup_issue", {
  parameters: s.object({ issue: s.string }),
  handler: async ({ issue }) => `Issue ${issue}`, // issue inferred as string
});

// For plain JSON Schema:
const tool = defineTool<{ issue: string }>("lookup_issue", {
  parameters: { type: "object", properties: { issue: { type: "string" } } },
  handler: async ({ issue }) => `Issue ${issue}`,
});

Copilot AI and others added 2 commits July 23, 2026 17:33
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix OpenAPI spec validator in daily rig evaluation Infer defineTool handler args from parameters schema Jul 23, 2026
Copilot AI requested a review from pelikhan July 23, 2026 17:36
@pelikhan
pelikhan marked this pull request as ready for review July 23, 2026 19:38
@pelikhan
pelikhan merged commit 4df3cd2 into main Jul 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[rig-tasks] Daily rig evaluation — 2026-07-23 — 5/5 passed

2 participants