core

package
v0.1.17 Latest Latest
Warning

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

Go to latest
Published: Jan 20, 2026 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BaseTool

type BaseTool struct {
	ToolUnion        responses.ToolUnion
	RequiresApproval bool
}

func (*BaseTool) NeedApproval

func (t *BaseTool) NeedApproval() bool

func (*BaseTool) Tool added in v0.1.11

func (t *BaseTool) Tool(ctx context.Context) *responses.ToolUnion

type HistorySummarizer

type HistorySummarizer interface {
	// Summarize takes a list of messages and returns a summary result.
	// If summarization is not needed, returns a result with KeepFromIndex = -1.
	Summarize(ctx context.Context, msgIdToRunId map[string]string, messages []responses.InputMessageUnion, usage *responses.Usage) (*SummaryResult, error)
}

type RunState

type RunState struct {
	CurrentStep           Step                            `json:"current_step"`
	LoopIteration         int                             `json:"loop_iteration"`
	Usage                 responses.Usage                 `json:"usage"`
	PendingToolCalls      []responses.FunctionCallMessage `json:"pending_tool_calls,omitempty"`
	ToolsAwaitingApproval []responses.FunctionCallMessage `json:"tools_awaiting_approval,omitempty"`
}

RunState encapsulates the execution state of an agent run

func LoadRunStateFromMeta

func LoadRunStateFromMeta(meta map[string]any) *RunState

LoadRunStateFromMeta loads RunState from messages.meta

func NewRunState

func NewRunState() *RunState

NewRunState creates initial state for a fresh run

func (*RunState) ClearPendingTools

func (s *RunState) ClearPendingTools()

ClearPendingTools clears the pending tool calls

func (*RunState) HasToolsAwaitingApproval

func (s *RunState) HasToolsAwaitingApproval() bool

HasToolsAwaitingApproval returns true if there are tools waiting for approval

func (*RunState) IsComplete

func (s *RunState) IsComplete() bool

IsComplete returns true if the state is complete

func (*RunState) IsPaused

func (s *RunState) IsPaused() bool

IsPaused returns true if the state is awaiting approval

func (*RunState) NextStep

func (s *RunState) NextStep() Step

NextStep returns what the agent should do next

func (*RunState) PromoteAwaitingToApproval

func (s *RunState) PromoteAwaitingToApproval()

PromoteAwaitingToApproval moves tools awaiting approval to pending and transitions to await state

func (*RunState) ToMeta

func (s *RunState) ToMeta(traceid string) map[string]any

ToMeta converts RunState to a map for storage in messages.meta

func (*RunState) TransitionToAwaitApproval

func (s *RunState) TransitionToAwaitApproval(tools []responses.FunctionCallMessage)

TransitionToAwaitApproval moves to await approval step with the given tools

func (*RunState) TransitionToComplete

func (s *RunState) TransitionToComplete()

TransitionToComplete moves to the complete step and clears pending tools

func (*RunState) TransitionToExecuteTools

func (s *RunState) TransitionToExecuteTools(tools []responses.FunctionCallMessage)

TransitionToExecuteTools moves to tool execution step with the given tools

func (*RunState) TransitionToLLM

func (s *RunState) TransitionToLLM()

TransitionToLLM moves to the LLM call step and increments loop iteration

type RunStatus

type RunStatus string

RunStatus represents the overall status of a run

const (
	RunStatusInProgress RunStatus = "running"
	RunStatusPaused     RunStatus = "paused"
	RunStatusCompleted  RunStatus = "completed"
	RunStatusError      RunStatus = "error"
)

type Step

type Step string

Step represents the current step in the agent execution state machine

const (
	StepCallLLM       Step = "call_llm"
	StepExecuteTools  Step = "execute_tools"
	StepAwaitApproval Step = "await_approval"
	StepComplete      Step = "complete"
)

type StreamBroker added in v0.1.11

type StreamBroker interface {
	// Publish sends a response chunk to subscribers of the given channel.
	// The channel is typically the run ID or a unique identifier for the execution.
	Publish(ctx context.Context, channel string, chunk *responses.ResponseChunk) error

	// Subscribe returns a channel that receives response chunks for the given channel.
	// The returned channel will be closed when Close is called or the context is cancelled.
	Subscribe(ctx context.Context, channel string) (<-chan *responses.ResponseChunk, error)

	// Close signals that no more chunks will be published to the channel.
	// This should close all subscriber channels for the given channel.
	Close(ctx context.Context, channel string) error
}

StreamBroker provides an abstraction for streaming response chunks between activities/workers and clients. This enables streaming support for both Restate and Temporal runtimes.

type SummaryResult

type SummaryResult struct {
	Summary                 *responses.InputMessageUnion // The summary message
	MessagesToKeep          []responses.InputMessageUnion
	LastSummarizedMessageID string // ID of the last message that was summarized
	SummaryID               string // Unique ID for the summary (generated if empty)
}

SummaryResult contains the result of summarization including metadata needed for saving

type SystemPromptProvider

type SystemPromptProvider interface {
	GetPrompt(ctx context.Context, data map[string]any) (string, error)
}

type Tool

type Tool interface {
	Execute(ctx context.Context, params *responses.FunctionCallMessage) (*responses.FunctionCallOutputMessage, error)
	Tool(ctx context.Context) *responses.ToolUnion
	NeedApproval() bool
}

Jump to

Keyboard shortcuts

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