smart_compact

package
v0.260124.900 Latest Latest
Warning

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

Go to latest
Published: Jan 23, 2026 License: MPL-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package smart_compact provides smart context compression for Anthropic requests.

The transformer removes thinking fields from non-current conversation rounds. MVP focuses on Anthropic v1 and v1beta APIs.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CompactTransformer

type CompactTransformer struct {
	protocol.Transformer

	KeepLastNRounds int // Number of recent rounds to preserve thinking blocks (min: 1)
	// contains filtered or unexported fields
}

CompactTransformer implements the Transformer interface.

func NewCompactTransformer

func NewCompactTransformer(keepLastNRounds int) *CompactTransformer

NewCompactTransformer creates a new smart_compact transformer instance.

The keepLastNRounds parameter controls how many recent conversation rounds should have their thinking blocks preserved. Higher values retain more reasoning context but save fewer tokens.

Recommendations:

  • keepLastNRounds=1: Default, preserves only the current request's thinking
  • keepLastNRounds=2-3: Suitable for multi-step reasoning, debugging, or document analysis
  • Minimum allowed value is 1 (current round's thinking is always preserved)

func (*CompactTransformer) HandleV1

HandleV1 compacts an Anthropic v1 request by removing thinking fields from non-current rounds.

func (*CompactTransformer) HandleV1Beta

HandleV1Beta compacts an Anthropic v1beta request by removing thinking fields from non-current rounds.

Jump to

Keyboard shortcuts

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