ctxwindow

package
v0.1.8 Latest Latest
Warning

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

Go to latest
Published: Sep 21, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package ctxwindow resolves the context window of the model a session runs against, which is the denominator every compaction threshold is measured in.

It is deliberately separate from internal/autocompact, which consumes the number: resolving a window means asking internal/provider, and piagent is barred by TestPiagentStaysIsolated from reaching provider construction even transitively. Keeping the two apart lets piagent install the same compaction hook as the CLI without acquiring that dependency.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Resolve

func Resolve(ctx context.Context, cfg config.Config, info provider.Info, baseURL string) int64

Resolve reports the context window the running model actually has, in tokens. It starts from the embedded catalog and lets the two providers that can be asked at runtime — Ollama and OpenRouter — correct it.

A zero result means the window is unknown, and compaction then never fires: AutoCompactConfig.Decide treats an unknown window as CompactionNone rather than guessing a percentage of nothing. Setting context_window in config.json is the escape hatch, and it wins over every other source, because the embedded catalog does not cover every provider's models.

Types

This section is empty.

Jump to

Keyboard shortcuts

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