Documentation
¶
Index ¶
- Constants
- func ContextFitsBudget(contextWindowTokenCount int, currentInputTokenCount int) bool
- func ContextInputBudget(contextWindowTokenCount int) int
- func EstimateContextTokenCount(text string) int
- func EstimateJSONTokenCount(v any) int
- func ShouldAutoCompact(estimatedInputTokenCount, effectiveBudget int) bool
- type AutoCompactionEvent
- type ContextBreakdown
- type ContextMessage
- type ContextToolDef
- type HistoricalToolActivity
- type Message
- type Role
- type StreamEvent
- type StreamEventType
- type StreamOptions
- type TokenUsage
- type ToolCall
- type TurnMemory
Constants ¶
View Source
const DefaultContextWindowTokenCount = 200000
Variables ¶
This section is empty.
Functions ¶
func ContextFitsBudget ¶
func ContextInputBudget ¶
func EstimateJSONTokenCount ¶
func ShouldAutoCompact ¶
Types ¶
type AutoCompactionEvent ¶
type AutoCompactionEvent struct {
Cancel func()
Replacement []Message
Usage *TokenUsage
Error error
}
type ContextBreakdown ¶
type ContextBreakdown struct {
SystemPromptTokens int
ToolDefinitionCount int
ToolDefTokens int
UserMessageTokens int
AssistantTokens int
ToolResultTokens int
TotalEstimated int
}
func EstimateContextBreakdown ¶
func EstimateContextBreakdown(systemPrompt string, toolDefs []ContextToolDef, messages []ContextMessage) ContextBreakdown
type ContextMessage ¶
type ContextMessage struct {
Role Role
Content string
ToolActivity []HistoricalToolActivity
}
type ContextToolDef ¶
type HistoricalToolActivity ¶
type HistoricalToolActivity struct {
TextOffset int `json:"text_offset"`
Tool string `json:"tool"`
Input map[string]any `json:"input,omitempty"`
Status string `json:"status"`
ExitCode *int `json:"exit_code,omitempty"`
HasRawOutput bool `json:"-"`
RawOutput any `json:"-"`
RetainedOutput any `json:"retained_output,omitempty"`
}
type Message ¶
type Message struct {
Role Role
Content string
TurnMemory *TurnMemory
}
func CloneMessage ¶
func CloneMessages ¶
type StreamEvent ¶
type StreamEvent struct {
Type StreamEventType
Content string
Error error
ToolCall *ToolCall
Usage *TokenUsage
Attempt int
AutoCompaction *AutoCompactionEvent
}
type StreamEventType ¶
type StreamEventType string
const ( StreamEventTypeChunk StreamEventType = "chunk" StreamEventTypeReasoningChunk StreamEventType = "reasoning_chunk" StreamEventTypeDone StreamEventType = "done" StreamEventTypeError StreamEventType = "error" StreamEventTypeToolStart StreamEventType = "tool_start" StreamEventTypeToolEnd StreamEventType = "tool_end" StreamEventTypeUsage StreamEventType = "usage" StreamEventTypeRetry StreamEventType = "retry" StreamEventTypeIncomplete StreamEventType = "incomplete" StreamEventTypeAutoCompactionStarted StreamEventType = "auto_compaction_started" StreamEventTypeAutoCompactionApplied StreamEventType = "auto_compaction_applied" StreamEventTypeAutoCompactionCancelled StreamEventType = "auto_compaction_cancelled" StreamEventTypeAutoCompactionFailed StreamEventType = "auto_compaction_failed" )
type StreamOptions ¶
type TokenUsage ¶
type TurnMemory ¶
type TurnMemory struct {
ToolActivity []HistoricalToolActivity `json:"tool_activity,omitempty"`
}
func CloneTurnMemory ¶
func CloneTurnMemory(memory *TurnMemory) *TurnMemory
func (*TurnMemory) IsEmpty ¶
func (m *TurnMemory) IsEmpty() bool
Click to show internal directories.
Click to hide internal directories.