Help us shape the future of Go! Take the 2026 Go Developer Survey

agent

package
v0.4.24 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2026 License: MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EncodeEventData

func EncodeEventData(v any) json.RawMessage

func IsStepLimitError added in v0.3.30

func IsStepLimitError(err error) bool

IsStepLimitError reports whether err ends a turn due to maxSteps.

func New

func New(cfg Config, deps Deps) (agentkit.Agent, error)

New registers agent/coding: Default coding agent: runs one turn against session, LLM, tools and prompt.

Best practices:

  • An interrupted turn is repaired on the next turn, so a crash mid-tool-call does not leave the session unusable.
  • Autonomous continuation belongs in TurnStopping hooks (e.g. hook/turn-continue); per-turn step caps use maxSteps.

func StepLimitUserMessage added in v0.3.30

func StepLimitUserMessage(cap int) string

StepLimitUserMessage is the user-visible notice when maxSteps is reached.

Types

type Config

type Config struct {
	// ID is agent id, referenced by loop.defaultAgent.
	ID agentkit.AgentID `json:"id"`
	// Model is model name passed to the LLM provider.
	Model string `json:"model"`
	// Modalities overrides provider input modalities when set (e.g. vision subagent with modalities: [image]).
	Modalities []string `json:"modalities,omitempty"`
	// Retry is per-step retry for transient provider failures.
	Retry *RetryConfig `json:"retry,omitempty"`
	// MaxSteps caps model steps per turn (all segments). Omitted defaults to 200;
	// explicit 0 disables the cap.
	MaxSteps *int `json:"maxSteps,omitempty"`
	// MaxPromptTokens is the pre-send guard: when the assembled prompt (system
	// prompt + hydrated history, inline media counted at real size) exceeds it,
	// force-run compaction once before the LLM call; if it still exceeds, fail
	// the step instead of sending a request the provider will reject. 0 disables.
	MaxPromptTokens int `json:"maxPromptTokens,omitempty"`
	// ToolExecution is how multiple tool calls in one assistant step run together.
	// Omitted defaults to parallel (pi agent-loop default).
	ToolExecution agentkit.ToolExecutionMode `json:"toolExecution,omitempty"`
}

func (*Config) SetDefaults added in v0.3.48

func (c *Config) SetDefaults()

SetDefaults implements pluginkit.Defaulter.

func (*Config) Validate added in v0.3.48

func (c *Config) Validate() error

Validate implements pluginkit.Validator.

type Deps

type Deps struct {
	SessionStore agentkit.SessionStore    `json:"sessionStore"`
	LLM          agentkit.LLMProvider     `json:"llm"`
	Tools        agentkit.ToolRuntime     `json:"tools"`
	Prompt       agentkit.PromptAssembler `json:"prompt"`
	Policies     []agentkit.Policy        `json:"policies,omitempty"`
	Hooks        agentkit.HookRuntime     `json:"hooks,omitempty"`
	Compaction   []compaction.Service     `json:"compaction,omitempty"`
	Workspace    workspace.Service        `json:"workspace,omitempty"`
}

type RetryConfig

type RetryConfig struct {
	Enabled     *bool `json:"enabled"`
	MaxRetries  int   `json:"maxRetries"`
	BaseDelayMs int   `json:"baseDelayMs"`
}

type Runtime

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

func (*Runtime) AgentCatalogEntry added in v0.1.5

func (a *Runtime) AgentCatalogEntry() string

AgentCatalogEntry describes this agent for the /agent catalog command.

func (*Runtime) ConfiguredModel added in v0.3.16

func (a *Runtime) ConfiguredModel() string

ConfiguredModel returns the model from agent config (before session override).

func (*Runtime) EffectiveModel added in v0.3.58

func (a *Runtime) EffectiveModel(ctx context.Context) string

EffectiveModel resolves the model for the session in ctx (session override, then global override, then agent default). Falls back to ConfiguredModel when session id is missing or resolution fails. Used by the loop for trace metadata.

func (*Runtime) ID

func (a *Runtime) ID() agentkit.AgentID

func (*Runtime) RunTurn

func (a *Runtime) RunTurn(ctx context.Context, input agentkit.TurnInput) (runErr error)

func (*Runtime) SessionStore added in v0.1.6

func (a *Runtime) SessionStore() agentkit.SessionStore

SessionStore returns the durable session backend used for turn history.

Jump to

Keyboard shortcuts

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