call

package
v0.0.0 Latest Latest
Warning

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

Go to latest
Published: Apr 9, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package call defines the tool call type used in LLM messages.

Index

Constants

View Source
const (
	MaxArgsLen   = 400
	MaxResultLen = 400
)

Display length limits.

Variables

This section is empty.

Functions

This section is empty.

Types

type Call

type Call struct {
	// ID uniquely identifies this tool call (from LLM response).
	ID string `json:"id"`
	// Name is the tool function name.
	Name string `json:"name"`
	// Arguments contains the tool parameters (raw data for API calls).
	Arguments map[string]any `json:"arguments,omitempty"`
	// ArgumentsDisplay is the pre-formatted argument string for UI display.
	ArgumentsDisplay string `json:"-"`
	// Preview is the truncated tool result for UI display (not the full output).
	Preview string `json:"-"`
	// FullOutput stores the untruncated tool result for pager access.
	FullOutput string `json:"-"`
	// State indicates the current execution state.
	State State `json:"-"`
	// Error is set if State == Error.
	Error error `json:"-"`
	// ResultTokens is the rough token estimate of the full (untruncated) result.
	ResultTokens int `json:"-"`
}

Call represents a tool invocation request from the LLM and its result.

func (*Call) Complete

func (c *Call) Complete(result string, resultTokens int)

Complete marks the call as successfully completed with a truncated result. resultTokens is the pre-computed token estimate of the full result.

func (Call) DisplayFull

func (c Call) DisplayFull() (header, args string)

DisplayFull returns the tool name header and arguments as separate strings, allowing callers to format them on separate lines.

func (Call) DisplayHeader

func (c Call) DisplayHeader() string

DisplayHeader returns the tool call header for UI display (e.g. "[Tool: name] args").

func (Call) DisplayResult

func (c Call) DisplayResult() string

DisplayResult returns the formatted result or error string for UI display.

func (*Call) Fail

func (c *Call) Fail(err error, resultTokens int)

Fail marks the call as failed with the given error. resultTokens is the pre-computed token estimate of the error message.

func (Call) ForLog

func (c Call) ForLog() string

ForLog returns a formatted string for log file output.

func (Call) ForTranscript

func (c Call) ForTranscript() string

ForTranscript returns a compact representation for compaction transcripts.

func (*Call) MarkRunning

func (c *Call) MarkRunning()

MarkRunning marks the call as currently executing.

func (*Call) SetArgs

func (c *Call) SetArgs(args map[string]any)

SetArgs formats and stores the argument display string from raw arguments.

type State

type State string

State represents the execution state of a tool call.

const (
	Pending  State = "pending"
	Running  State = "running"
	Complete State = "complete"
	Error    State = "error"
)

Jump to

Keyboard shortcuts

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