Documentation
¶
Overview ¶
Package compaction provides deterministic native Google ADK request estimation and durable context compaction callbacks.
Index ¶
Constants ¶
const ( // BytesPerToken is the fixture-pinned raw UTF-8 estimator ratio. BytesPerToken = 4 // Structural overheads are tokens added after the raw byte estimate. They // model native request framing without pretending to be a provider tokenizer. ContentOverheadTokens = 4 PartOverheadTokens = 1 FunctionOverheadTokens = 8 BinaryOverheadTokens = 16 ToolDeclarationOverheadTokens = 12 // ElisionMarker is the stable replacement for an eligible tool-response body. ElisionMarker = "[elided]" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
Policy config.Compaction
Store *sessionstore.Store
Budget *outputlimit.Budget
WarningSink warning.Warner
}
Config supplies the validated policy and Harness-owned durability resources.
type Estimate ¶
type Estimate struct {
CanonicalBytes int `json:"canonicalBytes"`
RawTokens int `json:"rawTokens"`
Contents int `json:"contents"`
Parts int `json:"parts"`
Functions int `json:"functions"`
Binaries int `json:"binaries"`
ToolDeclarations int `json:"toolDeclarations"`
OverheadTokens int `json:"overheadTokens"`
Tokens int `json:"tokens"`
}
Estimate is the deterministic breakdown for one native model request.
func EstimateRequest ¶
func EstimateRequest(request *model.LLMRequest) (Estimate, error)
EstimateRequest estimates the complete model-facing request. LLMRequest.Tools is intentionally excluded because ADK marks it as runtime-only and projects its declarations into Config.Tools before the model call.
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager owns native before-model and after-model compaction state.
func New ¶
New constructs a callback manager. A zero context budget leaves both callbacks installed as deterministic no-ops.
func (*Manager) AfterModel ¶
func (m *Manager) AfterModel(ctx agent.Context, response *model.LLMResponse, responseError error) (*model.LLMResponse, error)
AfterModel calibrates future estimates from native prompt usage.
func (*Manager) BeforeModel ¶
func (m *Manager) BeforeModel(ctx agent.Context, request *model.LLMRequest) (*model.LLMResponse, error)
BeforeModel compacts one assembled native ADK request in place.