diff options
| author | Dmitry Vyukov <dvyukov@google.com> | 2026-01-19 15:15:18 +0100 |
|---|---|---|
| committer | Dmitry Vyukov <dvyukov@google.com> | 2026-01-20 21:12:57 +0000 |
| commit | 5b6bebdcb7da46d1471b3aeacb28b54ba905b3b2 (patch) | |
| tree | d60fdce83c9b47fb39327f0bdc40b734a7213985 /pkg/aflow/schema.go | |
| parent | 8088ac4199a6e947c38db669c11d4441a9d59581 (diff) | |
pkg/aflow: add BadCallError
The error allows tools to communicate that an error is not an infrastructure error
that must fail the whole workflow, but rather a bad tool invocation by an LLM
(e.g. asking for a non-existent file contents).
Previously in the codesearcher tool we used a separate Missing bool
to communicate that. With the error everything just becomes cleaner and nicer.
The errors also allows all other tools to communicate any errors to the LLM
when the normal results cannot be provided and don't make sense.
Diffstat (limited to 'pkg/aflow/schema.go')
| -rw-r--r-- | pkg/aflow/schema.go | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/pkg/aflow/schema.go b/pkg/aflow/schema.go index 2b2d77f76..0b0eb8994 100644 --- a/pkg/aflow/schema.go +++ b/pkg/aflow/schema.go @@ -63,7 +63,7 @@ func convertFromMap[T any](m map[string]any, strict, tool bool) (T, error) { f, ok := m[name] if !ok { if tool { - return val, &toolArgsError{fmt.Errorf("missing argument %q", name)} + return val, BadCallError(fmt.Sprintf("missing argument %q", name)) } else { return val, fmt.Errorf("field %q is not present when converting map to %T", name, val) } @@ -79,8 +79,8 @@ func convertFromMap[T any](m map[string]any, strict, tool bool) (T, error) { field.Set(reflect.ValueOf(f)) } else { if tool { - return val, &toolArgsError{fmt.Errorf("argument %q has wrong type: got %T, want %v", - name, f, field.Type().Name())} + return val, BadCallError(fmt.Sprintf("argument %q has wrong type: got %T, want %v", + name, f, field.Type().Name())) } else { return val, fmt.Errorf("field %q has wrong type: got %T, want %v", name, f, field.Type().Name()) @@ -93,8 +93,6 @@ func convertFromMap[T any](m map[string]any, strict, tool bool) (T, error) { return val, nil } -type toolArgsError struct{ error } - // foreachField iterates over all public fields of the struct provided in data. func foreachField(data any) iter.Seq2[string, reflect.Value] { return func(yield func(string, reflect.Value) bool) { |
