agent

package
v0.0.0-...-738f650 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2026 License: AGPL-3.0 Imports: 12 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

Index

Constants

View Source
const EscalateSentinel = "NEEDS_INVESTIGATION:"

EscalateSentinel is the exact reply FastTriagePrompt asks for when the alert and its deterministic score aren't enough to classify confidently. The queue checks for this literal prefix to decide whether to fall back to the full agentic TriagePrompt (which has investigation tools).

Variables

View Source
var ErrLLMRateLimited = errors.New("rate limit reached — upgrade to Enterprise for higher usage limits")

Functions

func FastTriagePrompt

func FastTriagePrompt() string

FastTriagePrompt is the default triage path: one completion, no tools. The deterministic score is computed in Go before this prompt ever runs (see the queue's ScoreAlert call) and handed over as plain context, not as something the model decides whether to fetch — that decision was never really a choice, so it shouldn't cost a round trip. Writing the resulting note is also done in Go from this reply, not via a tool call. The only way this path costs more than one LLM call is the model asking to escalate, which is exactly the case where more calls are warranted.

func OpsPrompt

func OpsPrompt(page, lang string, enabledGroups []string) string

func SetBuilder

func SetBuilder(build func(tenantID string) *Agent)

func TriagePrompt

func TriagePrompt() string

TriagePrompt is the escalation path: a full agentic pass with investigation tools, used only when FastTriagePrompt asked to escalate. The score is still handed over as pre-computed context here too — it is never a tool call in either path.

Types

type Agent

type Agent struct {
	// contains filtered or unexported fields
}

func For

func For(tenantID string) *Agent

func New

func New(llm LLMClient, broker *ToolBroker, model string, maxTokens, contextWindow int) *Agent

func (*Agent) Broker

func (a *Agent) Broker() *ToolBroker

func (*Agent) QuickComplete

func (a *Agent) QuickComplete(ctx context.Context, system, input string) (string, error)

QuickComplete runs a single, tool-free LLM completion — the non-agentic fast path for a task that doesn't need investigation, like classifying an alert that already carries its deterministic score. It never loops and never offers tools, so it costs exactly one LLM call no matter what the model answers.

func (*Agent) Run

func (a *Agent) Run(ctx context.Context, task RunTask, sink EventSink) (RunResult, error)

type CapabilityGroup

type CapabilityGroup struct {
	ID       string
	Label    string // English description, used in the agent's permission prompt
	Prefixes []string
}

type CompletionRequest

type CompletionRequest struct {
	System      string
	Messages    []Message
	Tools       []ToolSpec
	Model       string
	MaxTokens   int
	Temperature float64 // 0 = provider default; ops path sets it low to curb exploratory tool use
}

type CompletionResponse

type CompletionResponse struct {
	Content   string
	ToolCalls []ToolCall
	Stop      string // provider stop/finish reason
}

type Event

type Event struct {
	Kind    EventKind       `json:"kind"`
	Step    int             `json:"step,omitempty"`
	Tool    string          `json:"tool,omitempty"`
	Args    json.RawMessage `json:"args,omitempty"`
	Output  string          `json:"output,omitempty"`
	IsError bool            `json:"isError,omitempty"`
	Text    string          `json:"text,omitempty"`
}

type EventKind

type EventKind string
const (
	EventToolCall   EventKind = "tool_call"
	EventToolResult EventKind = "tool_result"
	EventFinal      EventKind = "final"
	EventError      EventKind = "error"
	EventCompaction EventKind = "compaction"
)

type EventSink

type EventSink func(Event)

type LLMClient

type LLMClient interface {
	Complete(ctx context.Context, req CompletionRequest) (CompletionResponse, error)
	Provider() string
}

func NewLLMClient

func NewLLMClient(cfg LLMConfig) LLMClient

type LLMConfig

type LLMConfig struct {
	Provider       string // "anthropic" → Anthropic wire format; anything else → OpenAI-compatible
	URL            string // full endpoint
	Model          string
	APIKey         string
	AuthType       string // bearer | header | none
	AuthHeaderName string // header name when AuthType == "header"
	CustomHeaders  map[string]string
}

type Message

type Message struct {
	Role       Role
	Content    string
	ToolCalls  []ToolCall  // set on assistant turns that call tools
	ToolResult *ToolResult // set on tool turns (one per message)
}

type Role

type Role string
const (
	RoleUser      Role = "user"
	RoleAssistant Role = "assistant"
	RoleTool      Role = "tool"
)

type RunResult

type RunResult struct {
	Final     string
	Steps     int
	ToolCalls int
}

type RunTask

type RunTask struct {
	System        string // system prompt
	Input         string // the user turn (alert JSON for triage, free task for ops)
	History       []Message
	EnabledGroups []string
	AlwaysAllow   []string
	MaxIters      int
	Temperature   float64 // 0 = provider default
}

type ToolBroker

type ToolBroker struct {
	// contains filtered or unexported fields
}

func NewToolBroker

func NewToolBroker(backendURL, internalKey, tenantID string) *ToolBroker

func (*ToolBroker) Call

func (b *ToolBroker) Call(ctx context.Context, name string, args json.RawMessage) (string, bool, error)

func (*ToolBroker) Close

func (b *ToolBroker) Close()

func (*ToolBroker) ListSpecs

func (b *ToolBroker) ListSpecs(ctx context.Context) ([]ToolSpec, error)

type ToolCall

type ToolCall struct {
	ID   string
	Name string
	Args json.RawMessage
}

type ToolResult

type ToolResult struct {
	ID      string // matches ToolCall.ID
	Name    string
	Content string
	IsError bool
}

type ToolSpec

type ToolSpec struct {
	Name        string
	Description string
	InputSchema map[string]any
	ReadOnly    bool
}

Jump to

Keyboard shortcuts

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