a2aproject / a2aproject/a2a-java

[Feat]: Simplification of the client API?

未关闭
#517 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
主要语言
Java
星标
490
派生
172
平均合并
1 天 6 小时
30 天内合并 PR
55

描述

### 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 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

- [x] I agree to follow this project's Code of Conduct

贡献指南

打开贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。