[Feat]: Simplification of the client API?

Open
#517 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
65/100
Issue type
Refactor
Clarity
Clearly specified
Activity status
Stale
Tech stack
java
Domain
api

Research direction

Look at the client API in the spec module, focusing on methods that use XXXParams objects like TaskIdParams. Examine the existing sendMessage method as a reference for the pattern. Identify all methods that could be simplified, then create overloaded versions that accept primitive parameters and delegate to the existing implementations. Ensure backward compatibility and test changes.

Written by the indexing model from the issue text.

Description

Is your feature request related to a problem? Please describe.

The client API is a thin wrapper around the domain objects in the spec module.

I wonder if we could not make the API a bit simpler while retaining all the capabilities it exposes.

Describe the solution you'd like

For example, a lot of calls wrap their parameters in XXXParams object:

public Task cancelTask(TaskIdParams request)

but TaskIdParams is composed of a taskId and a metadata map.
Could the call simply be:

public Task cancelTask(String taskId, Map<String, Object> metadata) {
  return clientTransport.cancelTask(new TaskIdParams(taskId, metadata), request, context);
}

and a default method:

public default Task cancelTask(String taskId) {
    return cancelTask(taskId, emptyMap();
}

This way, the TaskIdParams does not leak to the Client API (making it bigger than it needs to be.

The API is already to that for its sendMessage methods that hides the internal MessageSendParams.
This is a pattern that should be applied to other methods as well

Describe alternatives you've considered

No response

Additional context

No response

Code of Conduct
  • I agree to follow this project's Code of Conduct
Dominant language
Java
Stars
514
Forks
200
Avg merge
1d 2h
Merged PRs (30d)
53

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from a2aproject/a2a-java

All issues in a2aproject/a2a-java

Similar issues

More Java issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.