agent

package
v0.0.1-alpha.2 Latest Latest
Warning

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

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

Documentation

Overview

Package agent implements the core turn loop (spec: openspec/specs/agent-loop, ADR-0001, ADR-0005, ADR-0007). The loop depends only on the ports.Provider port, the tool.Registry port, and the policy.Gate port — it never knows which model backend or which concrete tool implementation is behind them.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Agent

type Agent struct {
	Provider ports.Provider
	Tools    *tool.Registry
	Gate     policy.Gate

	// OnEvent, if set, receives every streamed Event as it arrives — the
	// seam a Bubble Tea front-end (T-030) hooks into for live rendering.
	OnEvent func(ports.Event)

	// OnToolResult, if set, is fired after each tool call executes (or is
	// denied/fails), carrying the call and its neutral result block. The TUI
	// (T-031) uses it to render edit diffs and tool output.
	OnToolResult func(call ports.ToolCall, result ports.Block)
}

Agent wires the three ports together and runs turns until the model stops requesting tools.

func (*Agent) Run

func (a *Agent) Run(ctx context.Context, system string, tools []ports.ToolSchema, history []ports.Message) ([]ports.Message, error)

Run drives one session to completion: repeated turns until a turn produces zero tool calls. It returns the final message history.

Jump to

Keyboard shortcuts

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