outputpolicy

package
v1.157.0 Latest Latest
Warning

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

Go to latest
Published: Jul 10, 2026 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Overview

Package outputpolicy reduces the tokens a model *generates* (the output side of the bill, complementary to the input/context compression in cli/compress).

Two keyless levers, both standard practice:

  • Verbosity steering: a static, cache-friendly directive injected into the system prompt that tells the model to drop preamble, restatement and ceremony and lead with the answer/action. Levels: full (off), concise, minimal.
  • Effort right-sizing: a keyless complexity classifier so trivial requests don't burn extended-thinking/reasoning tokens. It only ever *lowers* effort for clearly-trivial prompts; it never forces more thinking, so it cannot degrade a hard task.

The package is a leaf (standard library only) so it can be imported by the agent loop and the chat pipeline without cycles. The directives are model-facing instructions and are intentionally hard-coded in English (the repo convention: models follow English directives most reliably).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Complexity

type Complexity int

Complexity is the classifier's verdict about a user prompt.

const (
	// ComplexityNormal is the default — no effort change.
	ComplexityNormal Complexity = iota
	// ComplexityTrivial is a short, conversational lookup that doesn't need
	// extended thinking.
	ComplexityTrivial
	// ComplexityComplex is a multi-step / design / debugging task.
	ComplexityComplex
)

func Classify

func Classify(prompt string) Complexity

Classify returns a keyless complexity verdict for a user prompt. It is used only to *lower* effort for trivial prompts; ComplexityComplex/Normal leave effort untouched, so misclassification never reduces thinking on a hard task.

func (Complexity) String

func (c Complexity) String() string

String renders the verdict.

type Verbosity

type Verbosity int

Verbosity selects how terse the model should be.

const (
	// VerbosityFull applies no steering — the model's natural verbosity.
	VerbosityFull Verbosity = iota
	// VerbosityConcise drops ceremony and restatement while keeping substance.
	// This is the recommended default.
	VerbosityConcise
	// VerbosityMinimal answers in the fewest correct tokens.
	VerbosityMinimal
)

func ParseVerbosity

func ParseVerbosity(s string) (Verbosity, bool)

ParseVerbosity maps a config/env string to a Verbosity. Unknown values fall back to VerbosityConcise (the recommended default) with ok=false.

func (Verbosity) Directive

func (v Verbosity) Directive() string

Directive returns the system-prompt steering text for v, or "" for VerbosityFull (no steering). The strings are static so the block stays in the provider's cached prefix.

func (Verbosity) String

func (v Verbosity) String() string

String renders the level for /config and logs.

Jump to

Keyboard shortcuts

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