condition

package
v0.0.0-beta Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package condition provides shared condition evaluation for /assert and custom injectors.

Supports boolean conditions (todo_empty, auto), parameterized comparisons (history_gt:5, context_below:30), model conditions (model_has:vision, model_params_gt:10, model_context_lt:128000), filesystem conditions (exists:go.mod), shell conditions (bash:go build ./...), negation (not auto), and composition (history_gt:5 and history_lt:10).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Check

func Check(expr string, s State) bool

Check evaluates a condition expression against the state.

Supports:

  • Boolean conditions: todo_empty, todo_done, todo_pending, auto
  • Greater-than: history_gt:5, tool_errors_gt:3, context_above:70, model_context_gt:8000
  • Less-than: history_lt:10, tool_errors_lt:5, context_below:30, model_context_lt:128000
  • Model capabilities: model_has:vision, model_has:tools, model_has:thinking
  • Model parameters: model_params_gt:10, model_params_lt:0.5 (in billions)
  • Filesystem: exists:go.mod, exists:.aura/embeddings (files or directories)
  • Negation: "not auto", "not model_has:vision"
  • Composition: "model_has:tools and model_params_gt:10"

All terms joined by "and" must be true. Unknown conditions evaluate to false.

func Validate

func Validate(expr string) error

Validate checks that a condition expression uses only known condition names and has parseable values. Both Validate and eval use the same registry, so adding a new condition is a single map entry.

Validate checks syntax only: "exists:go.mod" validates that "exists" is a recognized name and the value is non-empty, but does NOT check the filesystem.

Types

type ModelState

type ModelState struct {
	ParamCount    int64           // raw units (8e9 for 8B)
	ContextLength int             // max context tokens
	Capabilities  map[string]bool // "vision" → true, etc.
	Name          string          // e.g. "qwen3:32b", for model_is:<name> checks
}

ModelState holds model metadata (zero values when model not yet resolved).

type State

type State struct {
	Todo         TodoState
	Tokens       TokensState
	MessageCount int
	Tools        ToolsState
	Turns        int
	Compactions  int
	Iteration    int
	Auto         bool
	Model        ModelState
}

State is a structured snapshot of runtime values that conditions check against. Both /assert and custom injectors populate this from their respective contexts.

type TodoState

type TodoState struct {
	Empty   bool
	Done    bool
	Pending bool
}

TodoState holds todo-list boolean flags.

type TokensState

type TokensState struct {
	Percent float64
	Total   int
}

TokensState holds context-window token metrics.

type ToolsState

type ToolsState struct {
	Errors int
	Calls  int
}

ToolsState holds cumulative tool invocation counts.

Jump to

Keyboard shortcuts

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