batch

package
v0.0.0-beta Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 30, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package batch provides a meta-tool that executes multiple independent tool calls concurrently.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Inputs

type Inputs struct {
	Calls []SubCall `` /* 140-byte string literal not displayed */
}

Inputs defines the JSON schema for the Batch tool parameters.

type RunFunc

type RunFunc func(ctx context.Context, toolName string, args map[string]any) (string, error)

RunFunc executes a single sub-tool call through the assistant's minimal pipeline.

type SubCall

type SubCall struct {
	Name      string         `json:"name"      jsonschema:"required,description=Name of the tool to execute"`
	Arguments map[string]any `json:"arguments" jsonschema:"required,description=Arguments for the tool"`
}

SubCall represents a single tool invocation within a batch.

type Tool

type Tool struct {
	tool.Base

	// Run is set by the wiring layer after construction. Nil = tool returns an error.
	Run RunFunc

	// IsParallel reports whether a tool is safe for concurrent execution.
	// When nil, all tools are dispatched concurrently (test compatibility).
	// When set, tools returning false are executed sequentially after parallel ones complete.
	IsParallel func(name string) bool
}

Tool lets the LLM dispatch multiple independent tool calls in parallel.

func New

func New() *Tool

New creates a Batch tool. The Run callback must be set separately before the tool is usable.

func (*Tool) Execute

func (t *Tool) Execute(ctx context.Context, params map[string]any) (string, error)

Execute validates input, dispatches sub-calls with a two-pass pattern: parallel-safe tools run concurrently, then non-parallel tools run sequentially.

func (*Tool) Name

func (t *Tool) Name() string

Name returns the tool's identifier.

func (*Tool) Sandboxable

func (t *Tool) Sandboxable() bool

Sandboxable returns false — sub-calls handle their own sandboxing individually.

func (*Tool) Schema

func (t *Tool) Schema() tool.Schema

Schema returns the provider-agnostic tool definition.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL