Documentation
¶
Index ¶
- Constants
- Variables
- func CleanupTurn(turnID string)
- func ContextRecoveryModeFromContext(ctx context.Context) (string, bool)
- func ConversationIDFromContext(ctx context.Context) string
- func MergeDiscoveryMode(ctx context.Context, update DiscoveryMode) context.Context
- func ModelMessageIDFromContext(ctx context.Context) string
- func RequestModeFromContext(ctx context.Context) string
- func SetTurnModelMessageID(turnID, msgID string)
- func SetTurnTrace(turnID, traceID string)
- func ToolMessageIDFromContext(ctx context.Context) string
- func TurnModelMessageID(turnID string) string
- func TurnTrace(turnID string) string
- func WithContextRecoveryMode(ctx context.Context, mode string) context.Context
- func WithConversationID(ctx context.Context, conversationID string) context.Context
- func WithDiscoveryMode(ctx context.Context, mode DiscoveryMode) context.Context
- func WithModelCompletionMeta(ctx context.Context, meta ModelCompletionMeta) context.Context
- func WithRequestMode(ctx context.Context, mode string) context.Context
- func WithRunMeta(ctx context.Context, meta RunMeta) context.Context
- func WithToolMessageID(ctx context.Context, messageID string) context.Context
- func WithTurnMeta(ctx context.Context, meta TurnMeta) context.Context
- type DiscoveryMode
- type EmbedFunc
- type ModelCompletionMeta
- type RunMeta
- type TurnMeta
Constants ¶
const ( ContextRecoveryCompact = "compact" ContextRecoveryPruneCompact = "pruneCompact" )
Variables ¶
var ConversationIDKey = conversationIDKey("conversationID")
var ModelMessageIDKey = modelMessageIDKey("modelMessageID")
var ToolMessageIDKey = toolMessageIDKey("toolMessageID")
Functions ¶
func CleanupTurn ¶
func CleanupTurn(turnID string)
CleanupTurn removes all in-memory state for the given turn. Call this when the turn completes or is canceled to prevent memory leaks.
func ConversationIDFromContext ¶
ConversationIDFromContext return conversation id from context
func MergeDiscoveryMode ¶
func MergeDiscoveryMode(ctx context.Context, update DiscoveryMode) context.Context
MergeDiscoveryMode merges an update into existing discovery mode and stores the resulting value in context.
func RequestModeFromContext ¶ added in v0.1.5
RequestModeFromContext returns the current generate/stream mode when present.
func SetTurnModelMessageID ¶
func SetTurnModelMessageID(turnID, msgID string)
SetTurnModelMessageID stores the current model call's assistant message ID.
func SetTurnTrace ¶
func SetTurnTrace(turnID, traceID string)
SetTurnTrace stores a provider trace/anchor id for the given turn id.
func TurnModelMessageID ¶
TurnModelMessageID returns the most recent assistant message ID for this turn.
func WithContextRecoveryMode ¶
func WithConversationID ¶
WithConversationID create context with conversation id
func WithDiscoveryMode ¶
func WithDiscoveryMode(ctx context.Context, mode DiscoveryMode) context.Context
WithDiscoveryMode stores discovery mode in context.
func WithModelCompletionMeta ¶
func WithModelCompletionMeta(ctx context.Context, meta ModelCompletionMeta) context.Context
WithModelCompletionMeta stores completion metadata on the context.
func WithRequestMode ¶ added in v0.1.5
WithRequestMode stores the current generate/stream mode (chat/plan/summary/chain).
func WithRunMeta ¶
WithRunMeta stores run metadata on the context for downstream persistence.
func WithToolMessageID ¶
Types ¶
type DiscoveryMode ¶
DiscoveryMode controls how tool discovery behaves for the current request.
func DiscoveryModeFromContext ¶
func DiscoveryModeFromContext(ctx context.Context) (DiscoveryMode, bool)
DiscoveryModeFromContext returns discovery mode when set.
type EmbedFunc ¶
EmbedFunc defines a function that creates embeddings for given texts. It should return one embedding per input text.
type ModelCompletionMeta ¶
type ModelCompletionMeta struct {
Content string
Preamble string
FinalResponse bool
FinishReason string
}
ModelCompletionMeta carries LLM response data through context so that emitCanonicalModelEvent can include all data points in a single model_completed event (content, preamble, finalResponse, finish reason).
func ModelCompletionMetaFromContext ¶
func ModelCompletionMetaFromContext(ctx context.Context) (ModelCompletionMeta, bool)
ModelCompletionMetaFromContext returns completion metadata if present.
type TurnMeta ¶
type TurnMeta struct {
TurnID string
Assistant string
ConversationID string
ParentMessageID string // last user message id (or tool message when parenting final)
}
TurnMeta captures minimal per-turn context for downstream persistence. Prefer passing a single TurnMeta instead of scattering separate keys.