From 5b6bebdcb7da46d1471b3aeacb28b54ba905b3b2 Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Mon, 19 Jan 2026 15:15:18 +0100 Subject: 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. --- pkg/aflow/func_tool.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'pkg/aflow/func_tool.go') diff --git a/pkg/aflow/func_tool.go b/pkg/aflow/func_tool.go index 48b47b1e5..dde359485 100644 --- a/pkg/aflow/func_tool.go +++ b/pkg/aflow/func_tool.go @@ -4,6 +4,8 @@ package aflow import ( + "errors" + "github.com/google/syzkaller/pkg/aflow/trajectory" "google.golang.org/genai" ) @@ -24,6 +26,17 @@ func NewFuncTool[State, Args, Results any](name string, fn func(*Context, State, } } +// BadCallError creates an error that means that LLM made a bad tool call, +// the provided message will be returned to the LLM as an error, +// instead of failing the whole workflow. +func BadCallError(message string) error { + return &badCallError{errors.New(message)} +} + +type badCallError struct { + error +} + type funcTool[State, Args, Results any] struct { Name string Description string -- cgit mrf-deployment