Skip to content

[Java] Tool-as-lambda 4.2: Implement ToolDefinition from*/fromAsync* overloads #1840

Description

@edburns

Requirement: When you open the PR, the very first thing you put in the description must be Fixes #1840 where the issue number is this issue for which the PR aims to implement the work.

Overview

Implement Phase 4.2 of #1810: add typed ToolDefinition overloads for inline lambda-defined tools.

Before coding

  • Do not start any implementation work until this issue is explicitly assigned to the coding agent.
  • Base branch for this work:
    edburns/1810-java-tool-ergonomics-tool-as-lambda.
  • Read this plan file on the branch before coding:
    1810-java-tool-ergonomics-tool-as-lambda-remove-before-merge/1810-ignorance-reduction-for-implementation-plan.md

Ordering rule (important)

This issue starts only after 4.1 is merged; all Phase 4 issues are completed in listed order.

Relevant Phase 3 resolutions to apply

  • 3.1 API shape: implement v1 overload families and arity decisions from the plan.
  • 3.2 ambiguity avoidance: separate sync/async by method families (from* vs fromAsync*) and use JDK functional interfaces.
  • 3.4 behavior parity: support the same parameter-type surface as existing Java tool schema pipeline.
  • 3.5 coercion policy: reuse existing ObjectMapper-based conversion behavior.
  • 3.6 options flags: options are set via existing immutable fluent modifiers on ToolDefinition (overridesBuiltInTool, skipPermission, defer) rather than a new options object.
  • 3.7 validation boundaries: fail fast with precise IllegalArgumentException messages.

Scope / deliverables

  1. Update java/src/main/java/com/github/copilot/rpc/ToolDefinition.java with the resolved from* overloads.
  2. Wire overloads to invocation adapter logic so sync/async and context-aware handlers behave correctly.
  3. Ensure constructed definitions preserve existing runtime contract (String passthrough, void -> "Success", JSON serialization for non-String, async support).

Gating criteria

  • Overloads compile cleanly and are unambiguous at common lambda call sites.
  • Invocation paths are ready for unit tests in 4.4.

Constraints

IMPORTANT: you must run mvn spotless:apply in the java directory before every commit.

  • Keep this issue focused on overload implementation and wiring.
  • No unrelated refactors.

Completion bookkeeping

When complete, update the checkbox for Phase 4.2 in:
1810-java-tool-ergonomics-tool-as-lambda-remove-before-merge/1810-ignorance-reduction-for-implementation-plan.md

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions