behavior

package
v1.10.0 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package behavior defines the Behavior entity — what an agent does.

Behaviors are condition-triggered action patterns — the "habits" and "reflexes" that compose skills and traits into contextual responses.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Action

type Action struct {
	Type   ActionType `json:"type"`
	Target string     `json:"target,omitempty"`
	Value  any        `json:"value,omitempty"`
}

Action defines what happens when a behavior triggers.

type ActionType

type ActionType string

ActionType defines what a behavior does when triggered.

const (
	ActionInjectPrompt    ActionType = "inject_prompt"
	ActionPreferSkill     ActionType = "prefer_skill"
	ActionRequireTool     ActionType = "require_tool"
	ActionModifyParam     ActionType = "modify_param"
	ActionSwitchCognitive ActionType = "switch_cognitive"
	ActionAddGuardrail    ActionType = "add_guardrail"
)

type Behavior

type Behavior struct {
	cortex.Entity
	ID            id.BehaviorID  `json:"id"`
	Name          string         `json:"name"`
	Description   string         `json:"description,omitempty"`
	Scope         cortex.Scope   `json:"scope"`
	Triggers      []Trigger      `json:"triggers,omitempty"`
	Actions       []Action       `json:"actions,omitempty"`
	Priority      int            `json:"priority,omitempty"`
	RequiresSkill string         `json:"requires_skill,omitempty"`
	RequiresTrait string         `json:"requires_trait,omitempty"`
	Metadata      map[string]any `json:"metadata,omitempty"`
}

Behavior represents a condition-triggered action pattern.

type ListFilter

type ListFilter struct {
	Exact  bool
	Search string
	Limit  int
	Offset int
}

ListFilter controls pagination and matching for behavior listing. Scope arrives on the context; Exact narrows to rows stored at precisely that depth instead of everything beneath it.

type Store

type Store interface {
	CreateBehavior(ctx context.Context, behavior *Behavior) error
	GetBehavior(ctx context.Context, behaviorID id.BehaviorID) (*Behavior, error)
	GetBehaviorByName(ctx context.Context, name string) (*Behavior, error)
	UpdateBehavior(ctx context.Context, behavior *Behavior) error
	DeleteBehavior(ctx context.Context, behaviorID id.BehaviorID) error
	ListBehaviors(ctx context.Context, filter *ListFilter) ([]*Behavior, error)
	CountBehaviors(ctx context.Context, filter *ListFilter) (int64, error)
}

Store defines persistence for behaviors.

type Trigger

type Trigger struct {
	Type    TriggerType `json:"type"`
	Pattern string      `json:"pattern,omitempty"`
}

Trigger defines when a behavior activates.

type TriggerType

type TriggerType string

TriggerType defines when a behavior activates.

const (
	TriggerOnInput      TriggerType = "on_input"
	TriggerOnToolResult TriggerType = "on_tool_result"
	TriggerOnError      TriggerType = "on_error"
	TriggerOnStepCount  TriggerType = "on_step_count"
	TriggerOnContext    TriggerType = "on_context"
	TriggerAlways       TriggerType = "always"
)

Jump to

Keyboard shortcuts

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