Interface FunctionTool<TContext,TInput,TOutput>

All Superinterfaces:
Tool<TContext>

public interface FunctionTool<TContext,TInput,TOutput> extends Tool<TContext>
FunctionTool

Function-based tool that can be called by the model.

Source: https://github.com/openai/openai-agents-js/blob/main/packages/agents-core/src/tool.ts

  • Method Details

    • getParameters

      Object getParameters()
    • isStrict

      boolean isStrict()
    • invoke

      CompletableFuture<TOutput> invoke(RunContext<TContext> context, TInput input)
    • needsApproval

      boolean needsApproval(RunContext<TContext> context, TInput input)
    • isEnabled

      boolean isEnabled(RunContext<TContext> context)
    • errorFunction

      default String errorFunction(RunContext<TContext> context, Throwable error)
      Transforms tool execution errors into user-visible error messages.

      This method is called when invoke() throws an exception or returns a failed CompletableFuture. Return a helpful error message string that will be sent back to the model.

      Default implementation returns the exception message. Override to provide custom error messages for specific failure cases.

      Parameters:
      context - The run context
      error - The exception that occurred
      Returns:
      User-visible error message