facts

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2026 License: MIT Imports: 8 Imported by: 0 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 facts derives what the policy needs from one Responses request: the prompt and recent dialogue for the classifier, a repeated tool-failure signature, the activity the tools show, whether a verification passed, and a context size estimate. Pure: request in, Facts out; no text is kept beyond the clipped dialogue. Ported from claude-model-router lib/facts.mjs.

Index

Constants

View Source
const FailureWindow = 40

FailureWindow is how many trailing items a repeated failure is looked for in.

Variables

This section is empty.

Functions

This section is empty.

Types

type Facts

type Facts struct {
	Prompt       string
	Dialogue     []Turn
	Continuation bool
	Failure      *Failure
	Observed     Observed
	Verified     bool
	ApproxTokens int
	Items        int
}

Facts is the policy input derived from a request.

func Extract

func Extract(req *responses.Request, opts Options) Facts

Extract derives Facts from one request. Pure; only the clipped prompt and dialogue keep any text.

type Failure

type Failure struct {
	Signature string
	Index     int
}

Failure is a tool error seen twice with an edit attempt in between.

type Observed

type Observed string

Observed is the activity bucket a turn's tool calls show.

const (
	ObservedCode Observed = "code"
	ObservedDocs Observed = "docs"
	ObservedOps  Observed = "ops"
	ObservedRead Observed = "read"
	ObservedTalk Observed = "talk"
)

type Options

type Options struct {
	RecentTurns  int
	MaxTextChars int
	ObservedFrom int
	VerifiedFrom int
}

Options bound the dialogue sent to the classifier and set where the observed activity and the verification check start. RecentTurns ≤ 0 sends no dialogue; MaxTextChars ≤ 0 clips every text to empty. ObservedFrom is the first input index whose tool calls count for Observed (never before the turn's prompt); VerifiedFrom is the first index a verification is looked for from, such as Items at the last model change.

type Turn

type Turn struct {
	Role string
	Text string
}

Turn is one user or assistant text message, clipped.

Jump to

Keyboard shortcuts

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