a2aproject / a2aproject/a2a-go

[Feature] Support Method Extensions (Extended Skills) - RequestHandler to handle custom RPC methods

Abierto
#129 5 comentarios 0 reacciones 0 asignados Ver en GitHub
Lenguaje dominante
Go
Estrellas
460
Forks
93
Merge medio
2 d 21 h
PR fusionados (30 d)
9

Descripción

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

Guía de contribución

Abrir la guía de contribución

Línea de trabajo

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.

Escrito por el modelo de indexación a partir del texto del issue.

Evaluación

Stack tecnológico
go
Área
backend-api-design
Tipo de issue
Nueva funcionalidad
Dificultad
3/5
Tiempo estimado
1-2 días
Estado de actividad
Estancado
Claridad
Bien especificado
Aptitud para principiantes
55/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.