a2aproject / a2aproject/a2a-go
[Feature] Support Method Extensions (Extended Skills) - RequestHandler to handle custom RPC methods
- 主要言語
- Go
- スター
- 460
- フォーク
- 93
- 平均マージ
- 2日 21時間
- マージ済み PR(30日)
- 9
説明
### Is your feature request related to a problem? Please describe.
`a2a-go` does not support method extensions (extension skills) as outlined in the A2A protocol document.
https://a2a-protocol.org/latest/topics/extensions/
>Method Extensions (Extended Skills): Adding entirely new RPC methods beyond the core set defined by the protocol. An Extended Skill refers to a capability or function an agent gains or exposes specifically through the implementation of an extension that defines new RPC methods. For example, a task-history extension might add a tasks/search RPC method to retrieve a list of previous tasks, effectively providing the agent with a new, extended skill.
https://github.com/a2aproject/a2a-go/blob/main/a2asrv/jsonrpc.go#L109
The JSON-RPC handler uses a fixed switch statement that returns ErrMethodNotFound for methods outside the core set, and the RequestHandler interface does not provide a mechanism for implementing custom RPC methods defined by extensions. This makes it difficult for developers to implement the extensions outlined in the protocol specification.
### Describe the solution you'd like
To support custom RPC methods defined by extensions, we propose adding a new optional interface that RequestHandler implementations can optionally implement. For example:
```go
// Handler for arbitrary RPC methods defined by extensions.
// Receives the method name and params, and returns a result or error.
// Returns ErrMethodNotFound if the method is not supported.
// Does not affect existing RequestHandler implementations.
type ExtendedMethodHandler interface {
OnExtendedMethod(ctx context.Context, method string, params json.RawMessage) (any, error)
}
```
Modify the default clause in jsonrpcHandler.handleRequest as follows, so that if the registered RequestHandler implements ExtendedMethodHandler, its method will be called:
```go
default:
if ext, ok := h.handler.(ExtendedMethodHandler); ok {
result, err = ext.OnExtendedMethod(ctx, req.Method, req.Params)
} else {
err = a2a.ErrMethodNotFound
}
```
This change enables handling of extension methods without any breaking changes to existing developer. If necessary, similar hooks can be added to the gRPC transport layer to ensure all transports support extension methods.
### 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
コントリビューションガイド
調査の方向性
The issue points to the JSON-RPC handler in a2asrv/jsonrpc.go line 109. Start by examining the existing switch statement and the RequestHandler interface. The change involves adding a new ExtendedMethodHandler interface and modifying the default clause to call it. Check for any existing tests around JSON-RPC handling to understand the current behavior. 'Done' means the handler correctly routes unknown methods to the new interface if implemented, without breaking existing functionality.
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- go
- 領域
- backend-api-design
- issue の種類
- 機能追加
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 活発さ
- 停滞
- 明瞭さ
- 明確に書かれている
- 初心者へのやさしさ
- 55/100