manager

package
v1.5.3 Latest Latest
Warning

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

Go to latest
Published: Jul 1, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultMaxMessageRound   int = 10
	DefaultFullMessageRounds int = 1
	// CompressionThreshold defines the minimum maxMessageRounds required for
	// async compression. When maxMessageRounds is below this value, simple
	// truncation is used instead to avoid issues like empty user queries or
	// premature compression.
	CompressionThreshold int = 8
)

Variables

This section is empty.

Functions

This section is empty.

Types

type CompressionCompleteCallback

type CompressionCompleteCallback func([]*schema.Message) error

CompressionCompleteCallback is a callback function that is called after compression completes This allows the caller to persist the modified messages (full overwrite mode)

type Manager

type Manager struct {
	// contains filtered or unexported fields
}

Manager manages conversation context with intelligent context management capabilities

func NewManager

func NewManager(maxMessageRound int) *Manager

NewManager creates a new Manager instance

func (*Manager) AddMessage

func (m *Manager) AddMessage(ctx context.Context, message *schema.Message)

AddMessage adds a message to the context

func (*Manager) Clear

func (m *Manager) Clear()

Clear clears the context (preserves system messages)

func (*Manager) GetChatModel

func (m *Manager) GetChatModel() model.ToolCallingChatModel

func (*Manager) GetFullMessages

func (m *Manager) GetFullMessages() []*schema.Message

GetFullMessages retrieves all full messages in the current context This includes all original messages without any simplification. The returned messages are guaranteed to have proper tool_call / tool_result pairing.

func (*Manager) GetLastUserMessage

func (m *Manager) GetLastUserMessage() string

GetLastUserMessage returns the content of the last user message in the conversation. Returns empty string if no user message is found.

func (*Manager) GetMessageCount

func (m *Manager) GetMessageCount() int

GetMessageCount returns the total number of messages in the context

func (*Manager) GetMessages

func (m *Manager) GetMessages() []*schema.Message

GetMessages retrieves simplified messages in the current context Old rounds are simplified (first user message + last assistant response) The returned messages are guaranteed to have proper tool_call / tool_result pairing.

func (*Manager) GetSummary

func (m *Manager) GetSummary() string

GetSummary generates a summary of the conversation

func (*Manager) IncRound

func (m *Manager) IncRound()

func (*Manager) RemoveLastRound

func (m *Manager) RemoveLastRound()

RemoveLastRound removes the last round of messages from the context. This is used for regenerating a response - the last assistant response is removed so the user message can be re-processed.

func (*Manager) SetChatModel

func (m *Manager) SetChatModel(chatmodel model.ToolCallingChatModel)

SetChatModel sets the chat model for message compression

func (*Manager) SetCompressionCompleteCallback

func (m *Manager) SetCompressionCompleteCallback(cb CompressionCompleteCallback)

SetCompressionCompleteCallback sets the callback that is called after compression completes

func (*Manager) SetFullMessageRounds

func (m *Manager) SetFullMessageRounds(rounds int)

SetFullMessageRounds sets how many recent rounds to keep full messages

func (*Manager) SetPersistenceCallback

func (m *Manager) SetPersistenceCallback(cb PersistenceCallback)

SetPersistenceCallback sets the callback for auto-saving messages

type PersistenceCallback

type PersistenceCallback func(*schema.Message) error

PersistenceCallback is a callback function for single message persistence Each time a new message is added, this callback is invoked with that single message

Jump to

Keyboard shortcuts

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