Skip to content

[Java] Add Param<T> public API type for lambda-defined tools#1845

Merged
edburns merged 14 commits into
edburns/1810-java-tool-ergonomics-tool-as-lambdafrom
copilot/edburns1810-java-tool-ergonomics-tool-as-lambda
Jun 30, 2026
Merged

[Java] Add Param<T> public API type for lambda-defined tools#1845
edburns merged 14 commits into
edburns/1810-java-tool-ergonomics-tool-as-lambdafrom
copilot/edburns1810-java-tool-ergonomics-tool-as-lambda

Conversation

Copilot AI commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

Phase 4.1 of #1810: introduces the runtime parameter metadata class needed by the upcoming ToolDefinition.from(...) lambda overloads.

Changes

  • Param<T> (com.github.copilot.tool) — immutable, fluent parameter descriptor with construction-time validation:
    • Rejects blank name/description
    • Rejects required=true combined with a non-empty defaultValue
    • Validates defaultValue against declared Class<T> (String, numeric primitives/boxed, Boolean, enums; unsupported types throw)
  • ParamTest — 27 unit tests covering factory methods, fluent mutators, all validation rules, and equality semantics
  • Plan file — Phase 4.1 checkbox marked complete

Usage

// Required param, no default
Param<String> query = Param.of(String.class, "query", "Search query text");

// Optional param with validated default
Param<Integer> limit = Param.of(Integer.class, "limit", "Max results", false, "10");

// Fluent mutation (returns new instance)
Param<String> renamed = query.name("search_query");
Param<String> optional = query.defaultValue("*"); // implicitly sets required=false

No changes to module-info.java needed — com.github.copilot.tool is already exported.

edburns and others added 11 commits June 29, 2026 20:43
Your branch is up to date with 'upstream/edburns/1810-java-tool-ergonomics-tool-as-lambda'.

Changes to be committed:
  (use "git restore --staged <file>..." to unstage)
	modified:   1810-java-tool-ergonomics-tool-as-lambda-remove-before-merge/1810-ignorance-reduction-for-implementation-plan.md
	modified:   1810-java-tool-ergonomics-tool-as-lambda-remove-before-merge/20260628-prompts.md
	new file:   1810-java-tool-ergonomics-tool-as-lambda-remove-before-merge/20260629-prompts.md

Signed-off-by: Ed Burns <edburns@microsoft.com>
…Phase 03.

modified:   1810-java-tool-ergonomics-tool-as-lambda-remove-before-merge/1810-ignorance-reduction-for-implementation-plan.md
modified:   1810-java-tool-ergonomics-tool-as-lambda-remove-before-merge/20260629-prompts.md

Signed-off-by: Ed Burns <edburns@microsoft.com>
modified:   1810-java-tool-ergonomics-tool-as-lambda-remove-before-merge/1810-ignorance-reduction-for-implementation-plan.md

- Check off the things already done.

modified:   1810-java-tool-ergonomics-tool-as-lambda-remove-before-merge/20260629-prompts.md

- GUTDODP
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI added 2 commits June 30, 2026 00:50
Introduce `com.github.copilot.tool.Param<T>` — an immutable, fluent
runtime parameter metadata class for inline/lambda tool definitions.

Validation behavior:
- Rejects blank name/description
- Rejects required=true with non-empty defaultValue
- Validates default values against declared Class<T>

Includes comprehensive unit tests (ParamTest, 24 cases).
Updates Phase 4.1 checkbox in the implementation plan.
Copilot AI changed the title [WIP] Add public API types for lambda-defined tools [Java] Add Param<T> public API type for lambda-defined tools Jun 30, 2026
Copilot AI requested a review from edburns June 30, 2026 00:53
@github-actions

This comment has been minimized.

@edburns edburns force-pushed the edburns/1810-java-tool-ergonomics-tool-as-lambda branch from fb4049f to 4b9c143 Compare June 30, 2026 16:01
…copilot/edburns1810-java-tool-ergonomics-tool-as-lambda
@github-actions

Copy link
Copy Markdown
Contributor

SDK Consistency Review ✅

Reviewed cross-SDK consistency for the Param<T> type introduced in this PR.

Finding: No consistency issues — Java-specific gap fill

The Param<T> class is a legitimate Java-specific type that fills a gap in Java's tool definition API. Every other SDK already addresses the same underlying need through its own language-native idiom:

SDK How individual parameter metadata (name, description, type, required, default) is carried
Node.js/TS Zod fluent API: z.string().describe("..."), .optional(), .default(...)
Python Pydantic BaseModel fields: Field(description="..."), Optional[T], Field(default=...)
Go Struct tags: json:"name", jsonschema:"description", *T for optional
.NET [Description("...")] attribute + C# nullable/default params via AIFunctionFactory reflection
Rust /// doc comments + schemars derive + Option<T> for optional
Java (this PR) Param<T> with factory methods and fluent mutators

Java lacks any of the other languages' built-in mechanisms for attaching per-parameter metadata inline (no Zod, no Pydantic, no struct tags, no C# attributes for a lambda/method-reference style call). The Param<T> class is the Java equivalent — it gives the upcoming ToolDefinition.from(...) lambda overloads (Phase 4.2) a way to carry the same rich metadata the other SDKs already have.

API shape mirrors existing @CopilotToolParam

The five attributes on Param<T> (type, name, description, required, defaultValue) map exactly to the four elements of the existing @CopilotToolParam annotation (+ the Java type token, which annotations can't carry as a runtime generic). Good internal consistency within Java.

No action required in other SDKs

This PR completes parity (each SDK can now fully describe tool parameters); it does not introduce new behaviour that needs to be mirrored elsewhere.

Generated by SDK Consistency Review Agent for issue #1845 · sonnet46 2.9M ·

@edburns edburns merged commit c9faaf9 into edburns/1810-java-tool-ergonomics-tool-as-lambda Jun 30, 2026
12 of 14 checks passed
@edburns edburns deleted the copilot/edburns1810-java-tool-ergonomics-tool-as-lambda branch June 30, 2026 17:52
@edburns edburns restored the copilot/edburns1810-java-tool-ergonomics-tool-as-lambda branch June 30, 2026 17:52
@edburns edburns deleted the copilot/edburns1810-java-tool-ergonomics-tool-as-lambda branch July 2, 2026 22:55
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.

[Java] Tool-as-lambda 4.1: Add public API types for lambda-defined tools

2 participants