0xPlaygrounds / 0xPlaygrounds/rig

bug: Malformed tool call params kill the whole agent run

Abierto
#2,447 23 comentarios 0 reacciones 0 asignados Ver en GitHub
bug
Lenguaje dominante
Rust
Estrellas
8.6k
Forks
960
Merge medio
4 h 18 min
PR fusionados (30 d)
124

Descripción

- [x] I have looked for existing issues (including closed) about this

## Bug Report

Malformed JSON in a streamed tool call terminates the entire agent run. This prevents the error being returned to the model so it can retry the call.

In Rig 0.42, [`[parts.rs](https://github.com/0xPlaygrounds/rig/blob/v0.42.0/crates/rig-core/src/streaming/parts.rs#L693-L697)`](https://github.com/0xPlaygrounds/rig/blob/v0.42.0/crates/rig-core/src/streaming/parts.rs#L693-L697) returns a terminal error:

```rust
UnparseableToolInput::Error => {
return Err(CompletionError::ResponseError(format!(
"tool call `{name}` arrived with malformed JSON input: {err}"
)));
}
```

This behaviour is also present on the current `main` branch.

A real example is documented in [[bionic-gpt/bionic-gpt#1041](https://github.com/bionic-gpt/bionic-gpt/issues/1041)](https://github.com/bionic-gpt/bionic-gpt/issues/1041).

## Reproduction

Use an OpenAI-compatible streaming provider and have it return a completed tool call with malformed arguments:

```text
tool: run_bash
arguments: {"command":"printf '\x'"}
finish_reason: tool_calls
```

Rig returns:

```text
tool call `run_bash` arrived with malformed JSON input
```

The agent run then ends.

## Expected behavior

The malformed call must not be executed, but the agent should be able to return a structured failure to the model and allow a bounded retry.

The failure should preserve:

* Tool-call ID
* Tool name
* Raw arguments
* Parse error

Strict completion users could retain the current fail-fast behaviour.

Related work:

* [[#2095](https://github.com/0xPlaygrounds/rig/issues/2095)](https://github.com/0xPlaygrounds/rig/issues/2095) requests bounded model retries for failed tool calls.
* [[#2118](https://github.com/0xPlaygrounds/rig/issues/2118)](https://github.com/0xPlaygrounds/rig/issues/2118) includes making provider failures available to retry policies.

## Screenshots

Not applicable.

## Additional context

Observed with Rig 0.42 using an OpenAI-compatible streaming endpoint. Catching the current `ResponseError` in the application is brittle because the failure is reduced to an error string.

Guía de contribución

Abrir la guía de contribución

Línea de trabajo

El error está en crates/rig-core/src/streaming/parts.rs alrededor de las líneas 693-697, donde UnparseableToolInput::Error desencadena un CompletionError terminal. Comience leyendo el módulo streaming para entender cómo se analizan las llamadas a herramientas y cómo se propagan los errores. La solución debe cambiar el manejo de errores para preservar la ID de la llamada a herramienta, el nombre, los argumentos sin procesar y el error de análisis para un reintento del modelo, en lugar de terminar la ejecución. Consulte los issues relacionados #2095 y #2118 para obtener contexto sobre las políticas de reintento. Ejecute pruebas para asegurarse de que el agente ahora pueda devolver un fallo estructurado.

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

Evaluación

Área
ai-infra-agents
Tipo de issue
Error
Dificultad
3/5
Tiempo estimado
1-2 días
Estado de actividad
Activo
Claridad
Bien especificado
Aptitud para principiantes
65/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.