Skip to content

test(java): add arity 0 and arity 2 coverage to ErgonomicToolDefinitionIT#1897

Merged
edburns merged 2 commits into
mainfrom
edburns/1810-additional-arity-tests
Jul 3, 2026
Merged

test(java): add arity 0 and arity 2 coverage to ErgonomicToolDefinitionIT#1897
edburns merged 2 commits into
mainfrom
edburns/1810-additional-arity-tests

Conversation

@edburns

@edburns edburns commented Jul 2, 2026

Copy link
Copy Markdown
Collaborator

Both the annotation-based (ErgonomicTestTools) and lambda-based (ToolDefinition.from()) APIs previously only exercised arity 1.

This commit adds:

  • ErgonomicTestTools.getStatus() — zero-parameter @copilotTool
  • ErgonomicTestTools.combineValues(String, String) — two-parameter @copilotTool
  • ergonomicToolArity0 / lambdaToolArity0 test methods (Supplier overload)
  • ergonomicToolArity2 / lambdaToolArity2 test methods (BiFunction overload)
  • test/snapshots/tools/ergonomic_tool_arity0.yaml
  • test/snapshots/tools/ergonomic_tool_arity2.yaml

…onIT

Both the annotation-based (ErgonomicTestTools) and lambda-based
(ToolDefinition.from()) APIs previously only exercised arity 1.

This commit adds:
- ErgonomicTestTools.getStatus() — zero-parameter @copilotTool
- ErgonomicTestTools.combineValues(String, String) — two-parameter @copilotTool
- ergonomicToolArity0 / lambdaToolArity0 test methods (Supplier overload)
- ergonomicToolArity2 / lambdaToolArity2 test methods (BiFunction overload)
- test/snapshots/tools/ergonomic_tool_arity0.yaml
- test/snapshots/tools/ergonomic_tool_arity2.yaml

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@edburns edburns marked this pull request as ready for review July 2, 2026 23:23
@edburns edburns requested a review from a team as a code owner July 2, 2026 23:23
Copilot AI review requested due to automatic review settings July 2, 2026 23:23

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Extends the Java E2E integration coverage for tool-definition ergonomics by exercising arity 0 and arity 2 tool handlers for both the annotation-based (@CopilotTool + ToolDefinition.fromObject) and lambda-based (ToolDefinition.from(...)) APIs, using replay-proxy snapshots under test/snapshots/tools/.

Changes:

  • Added new zero-arg and two-arg E2E test cases in ErgonomicToolDefinitionIT for both annotation-based and lambda-based tool definitions.
  • Added two new tool fixture methods (getStatus, combineValues) to ErgonomicTestTools to cover arity 0 and 2 for the annotation-based path.
  • Added new replay snapshots for the new arity scenarios.
Show a summary per file
File Description
java/src/test/java/com/github/copilot/e2e/ErgonomicToolDefinitionIT.java Adds arity 0 and arity 2 E2E coverage for both annotation-based and lambda-based tool definitions.
java/src/test/java/com/github/copilot/e2e/ErgonomicTestTools.java Adds @CopilotTool methods to exercise zero-parameter and two-parameter annotation-based tools.
test/snapshots/tools/ergonomic_tool_arity0.yaml New replay snapshot for the arity-0 tool invocation flow (get_status).
test/snapshots/tools/ergonomic_tool_arity2.yaml New replay snapshot for the arity-2 tool invocation flow (combine_values).

Review details

  • Files reviewed: 4/4 changed files
  • Comments generated: 0
  • Review effort level: Low

@github-actions

This comment has been minimized.

…CopilotToolMeta

The hand-written ErgonomicTestTools$$CopilotToolMeta.java fixture only
defined set_current_phase and search_items, but the ergonomicToolArity0
and ergonomicToolArity2 tests expect get_status and combine_values to be
registered. This caused the replay proxy to fail with "Tool does not
exist" errors in CI.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@github-actions

github-actions Bot commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

Cross-SDK Consistency Review ✅

This PR adds arity 0 and arity 2 test coverage to the Java ErgonomicToolDefinitionIT — all changes are test-only (Java E2E test files + two new shared replay snapshots).

No cross-SDK consistency issues found. Here's why:

Java-specific APIs being tested

The @CopilotTool annotation ergonomic API and the overloaded ToolDefinition.from() variants (Supplier for arity 0, BiFunction for arity 2) are Java-idiomatic features. Equivalent "arity" concepts don't apply to the other SDKs in the same way:

SDK Arity handling
Java Explicit overloads: from(Supplier), from(Param, Function), from(Param, Param, BiFunction)
Python Function introspection at decoration time — 0-param, 1-param, and 2-param all resolved via inspect.signature
Go Struct-based params in DefineTool[T, U] — arity emerges from struct fields, no explicit overloads needed
.NET Delegate + reflection via AIFunctionFactory.Create — any arity is handled uniformly

Snapshots

The two new YAML snapshots (ergonomic_tool_arity0.yaml, ergonomic_tool_arity2.yaml) follow the existing snapshot conventions correctly and are usable by any SDK test that exercises zero- or two-param tools against the replay proxy.

No action needed in other SDK implementations.

Generated by SDK Consistency Review Agent for issue #1897 · sonnet46 1.2M ·

@edburns edburns merged commit 2766820 into main Jul 3, 2026
46 of 47 checks passed
@edburns edburns deleted the edburns/1810-additional-arity-tests branch July 3, 2026 03:29
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.

2 participants