0xPlaygrounds / 0xPlaygrounds/rig

bug: Malformed tool call params kill the whole agent run

Offen
#2,447 23 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
bug
Vorherrschende Sprache
Rust
Sterne
8.6k
Forks
959
Ø Merge
4 Std. 32 Min.
Gemergte PRs (30 T.)
117

Beschreibung

- [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.

Beitragsleitfaden

Beitragsleitfaden öffnen

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.