Versions in this module Expand all Collapse all v0 v0.0.3 Mar 26, 2026 v0.0.1 Mar 24, 2026 Changes in this version + const CharsPerTokenEstimate + const DefaultQueueCap + const DefaultQueueDebounceMs + const DefaultQueueDrop + const DefaultQueueMode + const ImageCharEstimate + const SilentReplyToken + func BuildInboundMetaSystemPrompt(ctx InboundContext) string + func BuildInboundUserContextPrefix(ctx InboundContext) string + func BuildQueueSummaryLine(text string, limit int) string + func BuildToolPrunablePredicate(config *PruningConfig) func(toolName string) bool + func ContainsMessageIDHint(value string) bool + func ElideQueueText(text string, limit int) string + func EstimateMessageChars(msg openai.ChatCompletionMessageParamUnion) int + func ExtractAssistantContent(content openai.ChatCompletionAssistantMessageParamContentUnion) string + func ExtractDeveloperContent(content openai.ChatCompletionDeveloperMessageParamContentUnion) string + func ExtractMessageContent(msg openai.ChatCompletionMessageParamUnion) (content, role string) + func ExtractSystemContent(content openai.ChatCompletionSystemMessageParamContentUnion) string + func ExtractToolContent(content openai.ChatCompletionToolMessageParamContentUnion) string + func ExtractUserContent(content openai.ChatCompletionUserMessageParamContentUnion) string + func HasRenderableStreamingContent(result *StreamingDirectiveResult) bool + func IsAbortTriggerText(text string) bool + func IsSilentReplyPrefixText(text, token string) bool + func IsSilentReplyText(text, token string) bool + func LimitHistoryTurns(prompt []openai.ChatCompletionMessageParamUnion, limit int) []openai.ChatCompletionMessageParamUnion + func NormalizeHintMessageID(value string) string + func NormalizeInboundTextNewlines(input string) string + func NormalizeMessageID(value string) string + func PromptTextPayloads(prompt []openai.ChatCompletionMessageParamUnion) ([]string, int) + func PruneContext(prompt []openai.ChatCompletionMessageParamUnion, config *PruningConfig, ...) []openai.ChatCompletionMessageParamUnion + func ResolveQueueThreadKey(mode ThreadReplyMode, threadRootID, eventID string) string + func SanitizeChatMessageForDisplay(text string, isUser bool) string + func SmartTruncatePrompt(prompt []openai.ChatCompletionMessageParamUnion, targetReduction float64) []openai.ChatCompletionMessageParamUnion + func SoftTrimToolResult(content string, config *PruningConfig) string + func SplitTrailingDirective(text string) (string, string) + func StripEnvelope(text string) string + func StripMessageIDHintLines(text string) string + type CompactionDecision struct + Applied bool + DroppedCount int + FinalChars int + OriginalChars int + Reason string + type CompactionInput struct + MaxChars int + Messages []string + ProtectedTail int + type CompactionResult struct + Decision CompactionDecision + Messages []string + func ApplyCompaction(input CompactionInput) CompactionResult + type FailureClass string + const FailureClassAuth + const FailureClassContextOverflow + const FailureClassNetwork + const FailureClassProviderHard + const FailureClassRateLimit + const FailureClassTimeout + const FailureClassUnknown + func ClassifyFallbackError(err error) FailureClass + type FallbackAction string + const FallbackActionAbort + const FallbackActionFailover + const FallbackActionNone + const FallbackActionRetry + const FallbackActionTrimRetry + type FallbackDecision struct + Action FallbackAction + Class FailureClass + Reason string + ShouldRetry bool + StatusText string + func DecideFallback(err error) FallbackDecision + type InboundContext struct + Body string + BodyForAgent string + BodyForCommands string + ChatID string + ChatType string + CommandAuthorized bool + ConversationLabel string + MediaTypes []string + MediaURLs []string + MessageID string + MessageIDFull string + Provider string + RawBody string + ReplyToID string + SenderID string + SenderLabel string + Surface string + ThreadID string + ThreadStarterBody string + TimestampMs int64 + func FinalizeInboundContext(ctx InboundContext) InboundContext + type InlineDirectiveParseOptions struct + CurrentMessageID string + NormalizeWhitespace bool + SilentToken string + StripAudioTag bool + StripReplyTags bool + type InlineDirectiveParseResult struct + AudioAsVoice bool + HasAudioTag bool + HasReplyTag bool + IsSilent bool + ReplyToCurrent bool + ReplyToExplicitID string + ReplyToID string + Text string + func ParseInlineDirectives(text string, options InlineDirectiveParseOptions) InlineDirectiveParseResult + type OverflowCompactionInput struct + CompactionMode string + ContextWindowTokens int + CurrentPromptTokens int + KeepRecentTokens int + MaxHistoryShare float64 + MaxSummaryTokens int + Prompt []openai.ChatCompletionMessageParamUnion + ProtectedTail int + RefreshPrompt string + RequestedTokens int + ReserveTokens int + Summarization bool + type OverflowCompactionResult struct + Decision CompactionDecision + Prompt []openai.ChatCompletionMessageParamUnion + Success bool + func CompactPromptOnOverflow(input OverflowCompactionInput) OverflowCompactionResult + type OverflowFlushConfig struct + Enabled *bool + Prompt string + SoftThresholdTokens int + SystemPrompt string + type PruningConfig struct + CompactionMode string + CustomInstructions string + Enabled bool + HardClearEnabled *bool + HardClearPlaceholder string + HardClearRatio float64 + IdentifierInstructions string + IdentifierPolicy string + KeepLastAssistants int + KeepRecentTokens int + MaxHistoryShare float64 + MaxHistoryTurns int + MaxSummaryTokens int + MinPrunableChars int + Mode string + OverflowFlush *OverflowFlushConfig + PostCompactionRefresh string + ReserveTokens int + ReserveTokensFloor int + SoftTrimHeadChars int + SoftTrimMaxChars int + SoftTrimRatio float64 + SoftTrimTailChars int + SummarizationEnabled *bool + SummarizationModel string + TTL time.Duration + ToolsAllow []string + ToolsDeny []string + func ApplyPruningDefaults(config *PruningConfig) *PruningConfig + func DefaultPruningConfig() *PruningConfig + type QueueBehavior struct + BacklogAfter bool + Collect bool + Followup bool + Steer bool + func ResolveQueueBehavior(mode QueueMode) QueueBehavior + type QueueDecision struct + Action QueueDecisionAction + Reason string + func DecideQueueAction(mode QueueMode, hasActiveRun bool, isHeartbeat bool) QueueDecision + type QueueDecisionAction string + const QueueActionDrop + const QueueActionEnqueue + const QueueActionInterruptAndRun + const QueueActionRunNow + type QueueDropPolicy string + const QueueDropNew + const QueueDropOld + const QueueDropSummarize + func NormalizeQueueDropPolicy(raw string) (QueueDropPolicy, bool) + type QueueInlineOptions struct + Cap *int + DebounceMs *int + DropPolicy *QueueDropPolicy + type QueueMode string + const QueueModeBacklog + const QueueModeCollect + const QueueModeFollowup + const QueueModeInterrupt + const QueueModeSteer + const QueueModeSteerBacklog + func NormalizeQueueMode(raw string) (QueueMode, bool) + type QueueOverflowResult struct + ItemsToDrop int + KeepNew bool + ShouldSummarize bool + func ResolveQueueOverflow(capacity int, currentLen int, policy QueueDropPolicy) QueueOverflowResult + type QueueSettings struct + Cap int + DebounceMs int + DropPolicy QueueDropPolicy + Mode QueueMode + type ReplyDirectiveResult struct + AudioAsVoice bool + HasReplyTag bool + IsSilent bool + ReplyToCurrent bool + ReplyToExplicitID string + ReplyToID string + Text string + func ParseReplyDirectives(raw string, currentMessageID string) ReplyDirectiveResult + type ReplyPayload struct + AudioAsVoice bool + IsError bool + MediaURL string + MediaURLs []string + ReplyToCurrent bool + ReplyToID string + ReplyToTag bool + Text string + func ApplyReplyToMode(payloads []ReplyPayload, policy ReplyThreadPolicy) []ReplyPayload + type ReplyTargetDecision struct + Reason string + ReplyToID string + ThreadRoot string + func ResolveInboundReplyTarget(mode ThreadReplyMode, replyToID, threadRootID, eventID string) ReplyTargetDecision + type ReplyThreadPolicy struct + AllowExplicitWhenModeOff bool + Mode ReplyToMode + type ReplyToMode string + const ReplyToModeAll + const ReplyToModeFirst + const ReplyToModeOff + func NormalizeReplyToMode(raw string) ReplyToMode + type StreamingDirectiveAccumulator struct + func NewStreamingDirectiveAccumulator() *StreamingDirectiveAccumulator + func (acc *StreamingDirectiveAccumulator) Consume(raw string, final bool) *StreamingDirectiveResult + type StreamingDirectiveResult struct + AudioAsVoice bool + HasReplyTag bool + IsSilent bool + ReplyToCurrent bool + ReplyToExplicitID string + Text string + func ParseStreamingChunk(raw string) *StreamingDirectiveResult + type ThreadReplyMode string + const ThreadReplyModeAlways + const ThreadReplyModeInbound + const ThreadReplyModeOff + func NormalizeThreadReplyMode(raw string) ThreadReplyMode + type ToolApprovalDecision struct + CallID string + IsError bool + Reason string + State ToolApprovalState + Tool string + func DecideToolApproval(input ToolPolicyInput) ToolApprovalDecision + type ToolApprovalState string + const ToolApprovalApproved + const ToolApprovalDenied + const ToolApprovalPending + const ToolApprovalRequired + const ToolApprovalStale + const ToolApprovalTimedOut + type ToolPolicyInput struct + CallID string + RequireForMCP bool + RequiredTools map[string]struct{} + ToolKind string + ToolName string