Rename Param annotation to CopilotToolParam in Java SDK#1838
Conversation
Rename the class `com.github.copilot.tool.Param` to `com.github.copilot.tool.CopilotToolParam` to free the `Param` name for the tool-as-lambda API variant. Updates all imports, usages (@Param → @CopilotToolParam), reflection references (Param.class → CopilotToolParam.class), error messages in CopilotToolProcessor, Javadoc, test fixtures, README, and ADR documentation. Closes #1837 Co-authored-by: edburns <75821+edburns@users.noreply.github.com>
Co-authored-by: edburns <75821+edburns@users.noreply.github.com>
Param annotation to CopilotToolParam in Java SDK
This comment has been minimized.
This comment has been minimized.
I attempted to run |
modified: src/main/java/com/github/copilot/tool/CopilotTool.java modified: src/main/java/com/github/copilot/tool/CopilotToolParam.java modified: src/main/java/com/github/copilot/tool/CopilotToolProcessor.java modified: src/test/java/com/github/copilot/rpc/fixtures/OptionalParamTools.java modified: src/test/java/com/github/copilot/rpc/fixtures/SimpleTools.java modified: src/test/java/com/github/copilot/tool/CopilotToolAnnotationTest.java
I ran spotless locally and many files were changed. I pushed 890bd8b . Not sure why you could not run spotless. |
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Pull request overview
Renames the Java SDK tool-parameter annotation from @Param to @CopilotToolParam to free up the Param name for the upcoming tool-as-lambda API, and updates Java tests/docs/processor messaging to match.
Changes:
- Replaces
@Paramusages across Java unit tests, fixtures, and E2E test tools with@CopilotToolParam. - Updates the annotation processor and schema generation code paths to look up
CopilotToolParaminstead ofParam, including updated diagnostics. - Updates Java documentation (README + ADR) and Javadoc examples to reference
@CopilotToolParam.
Show a summary per file
| File | Description |
|---|---|
| java/src/test/java/com/github/copilot/tool/CopilotToolProcessorTest.java | Updates in-memory test sources and expected diagnostics to use @CopilotToolParam. |
| java/src/test/java/com/github/copilot/tool/CopilotToolAnnotationTest.java | Updates reflection-based annotation tests to reference CopilotToolParam. |
| java/src/test/java/com/github/copilot/rpc/fixtures/StaticTools.java | Renames fixture annotations/imports to CopilotToolParam. |
| java/src/test/java/com/github/copilot/rpc/fixtures/StaticInvocationTools.java | Renames fixture annotations/imports to CopilotToolParam. |
| java/src/test/java/com/github/copilot/rpc/fixtures/SimpleTools.java | Renames fixture annotations/imports to CopilotToolParam. |
| java/src/test/java/com/github/copilot/rpc/fixtures/OverrideTools.java | Renames fixture annotations/imports to CopilotToolParam. |
| java/src/test/java/com/github/copilot/rpc/fixtures/OptionalParamTools.java | Renames fixture annotations/imports to CopilotToolParam. |
| java/src/test/java/com/github/copilot/rpc/fixtures/InvocationAwareTools.java | Renames fixture annotations/imports to CopilotToolParam. |
| java/src/test/java/com/github/copilot/rpc/fixtures/DefaultValueTools.java | Renames fixture annotations/imports to CopilotToolParam. |
| java/src/test/java/com/github/copilot/rpc/fixtures/DateTimeTools.java | Renames fixture annotations/imports to CopilotToolParam. |
| java/src/test/java/com/github/copilot/rpc/fixtures/ArgCoercionTools.java | Renames fixture annotations/imports to CopilotToolParam. |
| java/src/test/java/com/github/copilot/e2e/ErgonomicTestTools.java | Renames E2E tool fixture annotations/imports to CopilotToolParam. |
| java/src/main/java/com/github/copilot/tool/SchemaGenerator.java | Updates required-parameter logic to look up CopilotToolParam annotations. |
| java/src/main/java/com/github/copilot/tool/CopilotToolProcessor.java | Updates processor validation and error messages to reference @CopilotToolParam. |
| java/src/main/java/com/github/copilot/tool/CopilotToolParam.java | Renames the annotation type itself and updates its Javadoc examples. |
| java/src/main/java/com/github/copilot/tool/CopilotTool.java | Updates Javadoc examples to use @CopilotToolParam. |
| java/README.md | Updates user-facing examples to use @CopilotToolParam. |
| java/docs/adr/adr-005-tool-definition.md | Updates ADR examples/text to use @CopilotToolParam (including record component example). |
Review details
Comments suppressed due to low confidence (1)
java/src/main/java/com/github/copilot/tool/CopilotToolParam.java:36
@CopilotToolParamis currently only targetable onPARAMETER, but the Java docs/ADR show it being used on record components (e.g.,record Args(@CopilotToolParam ... )). To make that usage compile, includeElementType.RECORD_COMPONENTin the annotation target (keepingPARAMETERfor method params).
- Files reviewed: 18/18 changed files
- Comments generated: 2
- Review effort level: Low
| Define a record for the tool's arguments, annotate its components with `@CopilotToolParam`, and use a generic factory method to auto-generate the schema from the record's `RecordComponent[]` metadata: | ||
|
|
||
| ```java | ||
| record PhaseArgs(@Param("The phase to transition to") Phase phase) {} | ||
| record PhaseArgs(@CopilotToolParam("The phase to transition to") Phase phase) {} | ||
|
|
…components The Option 2 code example incorrectly placed @CopilotToolParam on a record component. Since @CopilotToolParam targets ElementType.PARAMETER only (method parameters), this is not valid Java. - Remove @CopilotToolParam from the PhaseArgs record component - Update the prose to explain the PARAMETER-only target constraint - Add a Drawbacks bullet noting per-field descriptions are unsupported in Option 2 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Cross-SDK Consistency Review ✅All 18 changed files are scoped to the Java SDK ( The
No cross-SDK naming alignment is required — this rename is internal to Java's annotation-based tool API and does not affect the API surface of any other SDK. No consistency issues found.
|
Fixes #1837 .
Renames
com.github.copilot.tool.Param→CopilotToolParamto free theParamname for the upcoming tool-as-lambda API variant (#1810).Changes
Param.java→CopilotToolParam.java@Param(…)annotations,Param.classreflection references, variable type declarations@CopilotToolParamCopilotTool.javaAfter