compactionpoint

package
v0.7.16 Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2026 License: Apache-2.0 Imports: 18 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package compactionpoint answers ONE question: at what provider-billed input does a conversation's own compaction mechanism act?

It is a separate package because two very different layers need the same answer and neither can own it. The GATE needs it to decide when to fire (components, through apply); the PANEL needs it to size an episode's attribution span (dash). A copy in each would be two tables to keep in agreement, which is the failure this repo has already had with cache TTLs and with token rulers.

It is NOT in internal/modelinfo, despite being keyed by model, because it is not a property of the model. It is a property of a (deployment, client, model) TRIPLE: the same model behind a different agent, or behind Claude Code with a different auto-compact threshold, acts somewhere else. modelinfo owns what the provider publishes; this owns what a client does.

Index

Constants

View Source
const (
	// FlagName is the cached server flag (Claude Code 2.1.334 bundle).
	FlagName = "tengu_glimmering_blanket"
	// DefaultN is the client's hard-coded N without server flags.
	DefaultN = 400_000
)
View Source
const (
	// MinLearned is the number of observations a learned value needs.
	MinLearned = 3
	// LearnedTTL is how long one observation counts.
	LearnedTTL = 7 * 24 * time.Hour
	// MinObserved is the smallest billed input that counts as an observation.
	MinObserved = 100_000
)
View Source
const BobDefaultThreshold = 0.5

BobDefaultThreshold is the client's default, `fla = .5` in the client.

View Source
const BobFallbackWindow = 200_000

BobFallbackWindow is the window Bob uses when its catalog has no max_input_tokens for a model.

View Source
const ClientToBilled = 1.0

ClientToBilled converts the client's own token count to provider-billed tokens. 1.0 means the threshold is taken as billed tokens.

NOT MEASURED AS A CONVERSION. The two data points disagree:

  • 13 real Claude Code sessions (#940) auto-compacted at 164k to 167k billed, which is the client threshold itself (W - 33k for a 200k window): a factor of about 1.0.
  • One haiku session (the table above) billed 199,184 when the client's own count read about 168,000: a factor of 1.186.

1.0 is the lower, so it makes C smaller. A smaller C is the conservative direction for the replay cap and for the summarize trigger (see THE STATISTIC above). Change this one constant when a measurement settles it.

View Source
const OffEnv = "CONTEXT_GURU_CLIENT_COMPACT_CONFIG"

OffEnv turns the start-up read off ("off", "0" or "false"). C then comes from the table.

View Source
const RereadAfter = 5 * time.Minute

RereadAfter is how old the last read may be before the next session reads again.

Variables

This section is empty.

Functions

func BobSystemSettingsPath

func BobSystemSettingsPath(getenv func(string) string, goos string) string

BobSystemSettingsPath is the client's own rule (getSystemSettingsPath in bob.js). goos is runtime.GOOS of the host.

func CleanBobWindows

func CleanBobWindows(windows map[string]int, max int) map[string]int

CleanBobWindows returns the catalog to store, or nil when nothing should be stored. An empty catalog, or one over max entries, stores nothing. The host passes the agent's own cap (bob.MaxModelWindows), so the cap has one definition. A window <= 0 is dropped. The result is a copy: the caller keeps no handle on the agent's map.

func IsClientSource

func IsClientSource(src string) bool

IsClientSource is the ONE rule for "this source carries an absolute C that a row stores". The request-row writer and the dash walks use it.

func LearnedDisagreements added in v0.7.16

func LearnedDisagreements() int64

LearnedDisagreements is the number of times a learned value differed from the user's setting by more than 10% (the setting won). It is for /stats and the metrics.

func ManagedSettingsDir added in v0.7.16

func ManagedSettingsDir(goos string) string

ManagedSettingsDir is the client's own rule for the managed folder (Claude Code 2.1.334).

func RouteOf added in v0.7.16

func RouteOf(provider, wire string) string

RouteOf is the route part of a LearnKey: the provider and the wire of the request.

Types

type Bob

type Bob struct {
	Read bool
	// Threshold is the raw model.compressionThreshold from the winning file, "" when not set.
	Threshold string
}

Bob is the auto-compact setting of Bob Shell (#963). A host fills it once, at start-up (compactionpoint.ReadBob). Read is true only when the host did the read (local mode, switch not off). The zero value changes nothing.

VERIFIED FROM THE SHIPPED CLIENT, Bob Shell 1.0.3 (bundle/bob.js, read only, not from memory):

  • KEY: `model.compressionThreshold` in settings.json (schema default 0.5, "the fraction of context usage at which to trigger context compression", restart required). Files: the user file ~/.bob/settings.json, the project file .bob/settings.json, and the system file (BOB_SHELL_CLI_SYSTEM_SETTINGS_PATH, else /Library/Application Support/Bob-Shell/settings.json on macOS, /etc/bob-shell/settings.json elsewhere). The merge order is system defaults, user, project (if the folder is trusted), system; the last one wins. There is no env override.
  • DECISION (class Eue, method compress): the client compacts before a turn when `getLastPromptTokenCount() >= T x ex(model)`, with T = `config.getCompressionThreshold() ?? 0.5`. getCompressionThreshold returns the user's value when it is truthy (so 0 means "not set"), else a server-side experiment flag (CONTEXT_COMPRESSION_THRESHOLD) when the flag is non-zero, else undefined, which gives the 0.5 above.
  • RULER: lastPromptTokenCount is set from `usageMetadata.promptTokenCount` of the last response, i.e. the PROVIDER-REPORTED prompt tokens. That is the same ruler as billed input (ClientToBilled = 1.0 is right here, not a guess). After a compaction the client seeds it with an estimate, JSON length / 4, until the next response. ex(model) is the model's context window from Bob's OWN gateway catalog, GET /inference/v1/model/info (or /v1/model/info), field data[].model_info.max_input_tokens, 200,000 when the field or the model is missing (getLiteLLMModels and the `contextWindow: a.max_input_tokens||2e5` line). So T is a fraction of the WHOLE window of THAT catalog, with no reserve.

WHICH WINDOW (review round 1). Bob's catalog window can differ from ours (ours is 1,000,000 for claude-opus-5; Bob's catalog may say 200,000). A C built on a window larger than Bob's is too high, the dangerous direction for this package. So Resolve takes min(our window, Bob's window): Bob's window is the max_input_tokens the proxy saw in the model/info response it passed through (BobWindow, a number for each model id); when the proxy has not seen it, Bob's own fallback 200,000 is used. A lower C is the conservative side.

NOT READ: the project file (the proxy does not know the directory), the old flat key `chatCompression` (the client migrates it), and the server-side experiment flag. If that flag is set for a user who changed nothing, the real default is not 0.5 and C is off. The PR says so.

func ReadBob

func ReadBob(getenv func(string) string, home, goos string, open Open) Bob

ReadBob reads Bob Shell's model.compressionThreshold (#963) from the user settings file ~/.bob/settings.json and the system settings file (BobSystemSettingsPath), which wins in the client's merge. goos is the host's runtime.GOOS. The project file is not read. Read is true whenever the read ran, so Bob's own default (0.5) applies when nothing is set. Same off switch as the others. It never fails.

func (Bob) Resolve

func (b Bob) Resolve(window, bobWindow int) (Point, bool)

Resolve gives C for Bob: the user's fraction of the window when set, else the client default. ok is false when nothing was read or the window is unknown: the caller then uses the table.

window is OUR window for the model (0 = unknown). bobWindow is Bob's own max_input_tokens for the model, seen in its model/info response (0 = not seen). The window used is min(window, bobWindow), or min(window, BobFallbackWindow) when bobWindow is not seen.

type ClaudeCode

type ClaudeCode struct {
	// Env values, raw: CLAUDE_CODE_AUTO_COMPACT_WINDOW, CLAUDE_AUTOCOMPACT_PCT_OVERRIDE,
	// DISABLE_AUTO_COMPACT, DISABLE_COMPACT.
	EnvWindow, EnvPct, EnvDisableAuto, EnvDisable string
	// Settings values, raw, already merged across the settings files by the host.
	SettingsWindow string
	// SettingsEnabled is "true", "false" or "" (not set).
	SettingsEnabled string
	// ModelWindows maps a model name from modelSettings to its autoCompactWindow, raw.
	ModelWindows map[string]string
	// Read is true when the reader ran (ReadClaudeIn, not switched off). Only then does the
	// assumption apply (assumed.go). A literal ClaudeCode with Read false gets no assumption.
	Read bool
	// NoServerFlags is true when an env var stops the client from using server flags (hint.go).
	NoServerFlags bool
	// FlagWindows holds the valid per-model windows of the cached server flag, and "default" (hint.go).
	FlagWindows map[string]int
}

ClaudeCode is what the user set to move Claude Code's own auto-compact point (#948). A host gets it from its env and the settings files (compactionpoint.ClaudeReader, #1629). Every field is the RAW text of the setting, so the parsing rules below live in one place, next to the client rules they copy.

WHERE EACH SETTING IS FROM. Read from the shipped client, `claude` 2.1.319 (its bundled JavaScript, `strings` on the binary), not from memory:

  • CLAUDE_CODE_AUTO_COMPACT_WINDOW (env): the window the client counts against, in tokens. Accepts `200000`, `200k`, `1m`. Below 100,000 it is raised to 100,000. Above 1,000,000 it is lowered to 1,000,000. Not a number: ignored. The effective window is min(model window, this).
  • `autoCompactWindow` (settings.json, top level) and `modelSettings.<model>.autoCompactWindow` (what `/autocompact` writes): the same, in tokens, or "auto" for the client default. The env var wins over both. A model entry wins over the top-level one.
  • CLAUDE_AUTOCOMPACT_PCT_OVERRIDE (env): a percent, 0 < p <= 100, of the effective window less the output reserve. It can only LOWER the threshold: the client takes the smaller of it and the default.
  • DISABLE_AUTO_COMPACT and DISABLE_COMPACT (env; the values 1, true, yes, on), and `autoCompactEnabled: false` (settings.json or ~/.claude.json): auto-compact is off.

THE THRESHOLD. With W the effective window, the client compacts when its token count reaches

T = (W - 20,000) - 13,000                         (the output reserve, then the buffer)
T = min(floor((W - 20,000) x pct / 100), T)       (when the percent override is set)

20,000 is min(model max output, 20,000); every current model has a larger maximum. These are constants in the client (AZr and the L4 function). Nothing is guessed from max_tokens.

func ReadClaude

func ReadClaude(getenv func(string) string, home string, open Open) ClaudeCode

ReadClaude reads Claude Code's auto-compact settings from env and the settings files (#948, #1629): user, managed, and no project files (no directory is given). It is ReadClaudeIn with an empty cwd and this host's OS. getenv, home and open are injected. It never fails.

func ReadClaudeIn added in v0.7.16

func ReadClaudeIn(getenv func(string) string, home, goos, cwd string, open Open) ClaudeCode

ReadClaudeIn reads the settings for a client that runs in cwd (empty = not known). See the file comment for the sources and their order. It never fails.

func (ClaudeCode) Assume added in v0.7.16

func (c ClaudeCode) Assume(model string, window int) (Point, bool)

Assume is C for a Claude Code model when the user changed nothing. ok is false when the assumption does not apply (see above): the caller then uses the old table.

func (ClaudeCode) Hint added in v0.7.16

func (c ClaudeCode) Hint(model string) Hint

Hint gives N for model. It never fails: with nothing to read it gives DefaultN.

func (ClaudeCode) Resolve

func (c ClaudeCode) Resolve(model string, window int) (p Point, ok bool)

Resolve gives C for the model when the user changed a setting. ok is false when nothing was changed or nothing is readable: the caller then uses For(model), which is the old behavior. window is the model's context window (0 = unknown).

type ClaudeReader added in v0.7.16

type ClaudeReader struct {
	// Getenv, Home and Open are the host's. A nil Open reads no file (a host with no client files).
	Getenv func(string) string
	Home   string
	// GOOS names the managed folder. Empty means runtime.GOOS.
	GOOS string
	Open Open
	// Now is the clock. Nil means time.Now. Tests inject one.
	Now func() time.Time
	// contains filtered or unexported fields
}

ClaudeReader gives the settings and reads them again only when the last read is older than RereadAfter (#1629). A burst of sessions causes one read. It is safe for concurrent use.

func (*ClaudeReader) Get added in v0.7.16

func (r *ClaudeReader) Get(cwd string) ClaudeCode

Get returns the settings for cwd (empty = not known), read again when the last read for that cwd is RereadAfter old or older. The read runs under the lock, so a burst waits for one read.

type Client

type Client string

Client names a client for the choice of C. ClientOf maps an agent.Client to it (from agent.Identify, which reads the headers), so this package parses no User-Agent.

const (
	ClientNone   Client = ""
	ClientClaude Client = "claude"
	ClientBob    Client = "bob"
	ClientCodex  Client = "codex"
)

func ClientOf added in v0.7.12

func ClientOf(cl agent.Client) Client

ClientOf maps the request's agent.Client (agent.Identify, from the headers) to the client the compaction point keys on. A client with no setting (Pi, OpenCode, any other) gives ClientNone: the table applies.

type Codex

type Codex struct {
	// Limit is the raw model_auto_compact_token_limit, "" when not set.
	Limit string
	// Scope and PostTurn are the raw values of the two settings above, "" when not set.
	Scope, PostTurn string
}

Codex is the user's own auto-compact setting of Codex CLI (#963). A host fills it once, at start-up (compactionpoint.ReadCodex). The zero value changes nothing.

VERIFIED FROM THE SHIPPED CLIENT'S SOURCE, github.com/openai/codex tag rust-v0.160.0 (read only; `codex --version` on the laptop says 0.160.0):

  • KEY: `model_auto_compact_token_limit` (integer tokens) at the top level of $CODEX_HOME/config.toml (default ~/.codex; codex-rs/utils/home-dir/src/lib.rs). No env override and no per-profile key exist in this version. Other layers exist (project config, managed config, `-c` on the command line); only the user file is read.
  • FORMULA (codex-rs/protocol/src/openai_models.rs ModelInfo::auto_compact_token_limit, and codex-rs/core/src/session/context_window.rs context_window_token_status_with_config): limit = min(configured limit or catalog limit, 0.9 x context_window); compact when active_context_tokens >= limit (+ a fallback buffer only when the token-budget feature is on).
  • RULER: active_context_tokens = the provider-reported total_tokens of the LAST response (input + output) plus estimates for items added after it. That is the next request's billed input within the size of the new items, so the factor to billed tokens is taken as 1.0.
  • THE LIMIT CLAMP uses Codex's own context_window (272,000 for the models in the bundled 0.160.0 catalog, models-manager/models.json, one at 372,000). That value is the CLIENT's catalog, not ours, so we clamp to 0.9 x OUR window only as a sanity bound.

WHAT IS NOT DONE, ON PURPOSE. The default (no key set) is 0.9 x the client's catalog window, which depends on a per-model catalog that changes with each release and that the user can replace (model_catalog_json). Our window for the same model differs (872,000 vs 272,000 for gpt-6-sol). No default is invented: the request stays on the table. Two settings change the meaning of the limit, and with either set no C is derived (fail open): `model_auto_compact_token_limit_scope = "body_after_prefix"` (the limit then counts only growth after a prefix) and `model_post_turn_compact_threshold_percent` > 0 (a second, lower trigger).

func ReadCodex

func ReadCodex(getenv func(string) string, home string, open Open) Codex

ReadCodex reads three top-level keys of $CODEX_HOME/config.toml (default ~/.codex) (#963): model_auto_compact_token_limit, model_auto_compact_token_limit_scope and model_post_turn_compact_threshold_percent. It is a small line scanner, not a TOML parser: it reads only `key = value` lines before the first [table] header, and skips anything it does not understand (fail open). Same off switch as the others.

func (Codex) Resolve

func (c Codex) Resolve(window int) (Point, bool)

Resolve gives C for Codex when the user set a limit. window is OUR window for the model (0 = unknown).

type Hint added in v0.7.16

type Hint struct {
	// N is the window cap the client most likely uses, in tokens.
	N int
	// FromFlag is true when N is a valid value of the cached server flag. False means the
	// hard-coded 400,000 (no server flags, or the flag gave nothing for this model).
	FromFlag bool
	// NoServerFlags is true when an env var stops the client from using server flags.
	NoServerFlags bool
}

Hint is what the cached flag and the env say about N for one model.

type KV added in v0.7.16

type KV interface {
	Put(key string, payload []byte)
	Get(key string) ([]byte, bool)
}

KV is the part of store.Store the learner uses.

type Kind added in v0.7.16

type Kind string

Kind says how a resolved C was stated.

const (
	// KindNone: no C was resolved (0 tokens).
	KindNone Kind = ""
	// KindAbsolute: a number of billed tokens (a client setting, a client default or an operator
	// statement). It does not depend on the window.
	KindAbsolute Kind = "absolute"
	// KindFractional: a fraction of the window (the built-in table, or the window itself).
	KindFractional Kind = "fractional"
)

type LearnKey added in v0.7.16

type LearnKey struct {
	Client  Client
	Model   string
	Route   string
	Version string // the client's version; empty means the record is neither read nor written
}

LearnKey names one learned record. Route is the host's short name for the way the request goes to the provider (for example the provider and the wire). The model is normalized here.

func LearnKeyFor added in v0.7.16

func LearnKeyFor(cl agent.Client, model, route string) LearnKey

LearnKeyFor is the key of a request: its client (agent.Identify), model and route. Only Claude Code is learned today (the approved scope). Any other client gives a key that is not ok, so nothing is read or written for it.

type Learner added in v0.7.16

type Learner struct {
	// Now is the clock. Nil means time.Now. Tests inject one.
	Now func() time.Time
}

Learner reads and writes the learned records. The zero value uses the real clock. It is safe for concurrent use: writes of one process take one lock.

func (Learner) NoteDisagreement added in v0.7.16

func (l Learner) NoteDisagreement(st KV, k LearnKey, setting Point)

NoteDisagreement counts and logs a learned value that is more than 10% off the setting that won. It changes nothing else.

func (Learner) Observe added in v0.7.16

func (l Learner) Observe(st KV, k LearnKey, billed int)

Observe records that the client compacted after a request that billed `billed` input tokens. It never fails the request: a bad key, a small count or a panic records nothing.

func (Learner) Point added in v0.7.16

func (l Learner) Point(st KV, k LearnKey, window int) (Point, bool)

Point is the learned C for k, as an absolute point, or ok false. window (0 = unknown) only fills Frac. A learned C at or above an exact window is dropped later, where the accountant takes it (Limits.ForAccountant).

type Limits added in v0.7.16

type Limits struct {
	// Tokens is C in provider-billed tokens. 0 = unknown.
	Tokens int
	// Source says where C came from.
	Source Source
	// Kind says whether C was an absolute number or a fraction of the window.
	Kind Kind
	// Window is the model's context window in tokens. 0 = unknown.
	Window int
	// WindowExact says Window is published for this model, not guessed.
	WindowExact bool
}

Limits is C for one request, as the library resolved it. A host copies it. It adds no rule. apply puts it on apply.Trace.Limits.

func LimitsOf added in v0.7.16

func LimitsOf(window int, exact bool, tokens int, src Source, kind Kind) Limits

LimitsOf builds Limits from the resolved values. kind is Point.Kind() of the point they came from. A C of 0 has no kind. An unknown kind with a C is read as fractional: the fraction rule is the careful one (it passes nothing with a guessed window).

func PointLimits added in v0.7.16

func PointLimits(window int, exact bool, p Point) Limits

PointLimits is LimitsOf for a Point and the window it was resolved against.

func (Limits) ForAccountant added in v0.7.16

func (l Limits) ForAccountant() (window, point int)

ForAccountant is the pair the accountant takes as RequestMeta.Window and RequestMeta.CompactionPoint. The accountant gets numbers only. The rules:

  • The window goes through only when exact. A guessed window gives 0.
  • An absolute C always passes. A fractional C passes only with an exact window: a fraction of a guess is a guess.
  • A C at or above an exact window adds nothing and is dropped (auto-compact off, or the table's 1.00 x window). The accountant caps at the lower of the two.

type Open

type Open func(path string) (fs.File, error)

Open opens a file by the OS path the library names. A host passes a function that calls os.Open, so each path means what it meant before: a relative path is relative to the working directory, a `.` or `..` element works, and a Windows drive path works. A test passes an in-memory one.

type Point

type Point struct {
	// Frac is C as a fraction of the model's context window, in provider-billed tokens.
	Frac float64
	// Abs, when > 0, is C in absolute billed tokens and wins over Frac in Tokens. It is set by a Configured,
	// ClientDefault or Operator point: the client's or operator's own number does not scale with OUR window,
	// and a round trip through a fraction of the window could lose a token to the float. 0 = use Frac.
	Abs    int
	Source Source
	// Note is why this value, in enough detail to tell whether it still holds.
	Note string
}

Point is one resolved C.

func AssumeHosted added in v0.7.16

func AssumeHosted(client Client, model string, window int) (Point, bool)

AssumeHosted is Assume for a host that has no reader and no client files (a hosted proxy). It sees no flag and no env, so N is the client's 400,000. The off switch (OffEnv) is a local env var and is not visible here: an operator turns the assumption off for a model by stating compaction_point for it, which wins. Only Claude Code (ClientClaude) is assumed.

func For

func For(model string) Point

For resolves a model's compaction point from the bootstrap table.

An unlisted model gets C == W. That is NOT conservative for the span -- too high makes the span too wide and OVER-reports -- and it is chosen anyway, because a fabricated lower bound would make every unlisted model's savings quietly smaller by an amount nobody chose, and an operator comparing two models would be reading a difference this table invented. C == W is transparently an absence of information rather than a guess pretending to be one, and the Source says so.

func Recorded

func Recorded(model string, abs int, src string) Point

Recorded rebuilds the Point a request row carries: the absolute C in billed tokens and the source it had when the row was written (#948, #963). A row with no recorded client value gets the table's answer for its model, so an old row reads as before. Only a Configured, ClientDefault, ClaudeAssumed row has an absolute C; the table value scales with the window and is better re-read from the table.

func Resolve

func Resolve(model string, tokens, window int) Point

Resolve is For with the operator's table in front. tokens is the operator's compaction_point for this model in billed input tokens (0 = none stated), window the model's context window (0 = unknown).

A stated value is used as it is, whatever the window: the window is the model's limit and this is where the CLIENT acts, and the two are not derived from each other. Frac is filled in when the window is known, for the callers (the dashboard span) that think in fractions; it is capped at 1.

func (Point) FromClient

func (p Point) FromClient() bool

FromClient reports whether the point came from the client itself (a user setting or the client's own default) and so carries an absolute C that a request row must store (#948, #963).

func (Point) Kind added in v0.7.16

func (p Point) Kind() Kind

Kind says how the point was stated: absolute when it carries Abs, else a fraction of the window. It is the one place that classifies a Point. A host copies the answer and does not derive it.

func (Point) Tokens

func (p Point) Tokens(window int) int

Tokens is C in absolute billed tokens for a given window. 0 when the window is unknown.

type Settings

type Settings struct {
	Claude ClaudeCode
	// ClaudeReader, when set, gives the Claude settings and replaces Claude. It re-reads at most
	// once in RereadAfter (#1629).
	ClaudeReader *ClaudeReader
	Bob          Bob
	Codex        Codex
}

Settings holds each client's own settings, read in local mode. The zero value changes nothing.

func (Settings) Assume added in v0.7.16

func (s Settings) Assume(client Client, model string, window int) (Point, bool)

Assume is C when the user changed nothing and the library can still tell what the client does (assumed.go). ok is false when it cannot: the caller then uses the old table. It is the last step before the table, after the user's setting (Pick), any learned value and the operator.

func (Settings) Pick

func (s Settings) Pick(client Client, model string, window int, bobWindow func(model string) int) (Point, bool)

Pick is C for a request from this client, from the user's own setting for that client, when it changes C. ok is false when the caller must use the operator's price table instead. A hosted proxy must not call Pick: it never has a user setting. bobWindow gives Bob's own window for the model (0 = not seen). It runs only for a Bob request.

type Source

type Source string

Source says where a resolved C came from, so a published figure can be read for what it is. The same measured/guessed discipline modelinfo.Exact keeps for windows.

const (
	// Measured: case 1 or 2 -- observed in billed tokens on a real run, or set by us.
	Measured Source = "measured"
	// Assumed: reported behaviour or a reasoned bound, not observed.
	Assumed Source = "assumed"
	// Configured: the user changed the client's own auto-compact setting, and the local proxy read it at start-up
	// (see ClaudeCode, Codex, Bob). The number is the client's own threshold, taken as billed tokens by
	// ClientToBilled. It beats the table.
	Configured Source = "configured"
	// ClientDefault: the user changed nothing, and the client's own VERIFIED default threshold is
	// used (see Bob, #963). Like Configured it is an absolute number in billed tokens and it is
	// stored on the request row.
	ClientDefault Source = "client_default"
	// Learned: the proxy saw this client compact, three times or more, at about this billed input (#1629). Like
	// Configured it is an absolute number in billed tokens and it is stored on the request row. It ranks
	// below a setting and above the operator's table (see Learner).
	Learned Source = "learned"
	// ClaudeAssumed: the user changed nothing, and the library assumes Claude Code 2.1.334's cap of a
	// native 1M window (N, 400,000 by default). It is an absolute number in billed tokens, and it is
	// stored on the request row like Configured. It is a guess, not a measurement (assumed.go).
	ClaudeAssumed Source = "claude_assumed"
	// Operator: the operator stated it per model in the MODEL_PRICES table (compaction_point, billed
	// tokens). It beats the bootstrap table. It is a statement, not an observation: the operator owns it.
	Operator Source = "operator"
	// WindowFallback: case 3 and case 4 together -- C == W, because either nothing compacts here
	// (a fact) or we have never seen this client compact (a guess). This package cannot yet tell
	// those apart, which is itself worth reporting rather than smoothing over.
	WindowFallback Source = "window_fallback"
)

Jump to

Keyboard shortcuts

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