hook

package
v0.3.68 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

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

New registers hook/before-step: Run compaction services before each model step; contributes /compact.

Best practices:

  • Point compaction at the same pipeline instance the agent uses for overflow recovery.

func NewSessionIndex added in v0.3.13

NewSessionIndex registers hook/session-index: refresh the session FTS index after each successful turn.

func NewTurnContinue

func NewTurnContinue(cfg TurnContinueConfig, deps TurnContinueDeps) (agentkit.HookProvider, error)

NewTurnContinue registers hook/turn-continue: Decide whether an autonomous turn continues or stops; contributes /status.

Best practices:

  • Useless without tool/todo and tool/finish: with no completion signal it can only stop on stall or continuation limit.
  • Decision order is finish, then stall, then continuation limit, then no-progress, then pending work.

func NewTurnNudge added in v0.3.66

NewTurnNudge registers hook/turn-nudge: Inject wrap-up notices into tool results as a turn consumes its step / elapsed-time budget.

Best practices:

  • Notices are appended to tool results, so they persist in session history and reach the model at the next step.
  • Two tiers: periodic soft nudges (stepInterval / timeIntervalMinutes) and a budget limit (stepLimit / timeLimitMinutes) after which every tool result carries limitMessage.
  • The step counter mirrors agent maxSteps semantics (turn-wide, across segments); one parallel tool batch still counts as one step.
  • This hook only nudges; hard limits stay with agent maxSteps and hook/turn-continue.

Types

type Config

type Config struct {
	// ContributeCommands registers /compact on the shared commands registry.
	// Only one hook/before-step instance should enable this (typically the default agent).
	ContributeCommands bool `json:"contributeCommands"`
}

type Deps

type Deps struct {
	// Compaction is typically compaction.pipeline.* (chain + inner services wired in config).
	Compaction   compaction.Service    `json:"compaction"`
	SessionStore agentkit.SessionStore `json:"sessionStore"`
}

type Provider

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

func (*Provider) Commands

func (p *Provider) Commands() []agentkit.Command

func (*Provider) Hooks

func (p *Provider) Hooks() agentkit.HookContribution

type SessionIndexConfig added in v0.3.13

type SessionIndexConfig struct{}

type SessionIndexDeps added in v0.3.13

type SessionIndexDeps struct {
	Index capsessionindex.Service `json:"index"`
}

type TurnContinueConfig

type TurnContinueConfig struct {
	// MaxContinuations is the most segments this hook will ask for after the first.
	MaxContinuations int `json:"maxContinuations"`
	// ContinuePrompt is text injected to start another segment.
	ContinuePrompt string `json:"continuePrompt"`
	// RequireFinish keeps going until tool/finish is called, even with no pending todos.
	RequireFinish *bool `json:"requireFinish"`
	// RequireTodosDone keeps going while todos are still pending.
	RequireTodosDone *bool `json:"requireTodosDone"`
	// StallLimit stops after this many repeats of the same tool call signature.
	StallLimit int `json:"stallLimit"`
	// NoProgressLimit stops after this many consecutive continuations with no
	// substantive progress — no new tool/call, todo/update, or run/finish event
	// (default 3). Guards against idle loops when tool/finish is missing or the
	// model keeps ending segments with text-only replies.
	NoProgressLimit int `json:"noProgressLimit"`
}

func (*TurnContinueConfig) SetDefaults added in v0.3.48

func (c *TurnContinueConfig) SetDefaults()

SetDefaults implements pluginkit.Defaulter.

func (*TurnContinueConfig) Validate added in v0.3.48

func (c *TurnContinueConfig) Validate() error

Validate implements pluginkit.Validator.

type TurnContinueDeps

type TurnContinueDeps struct {
	SessionStore agentkit.SessionStore `json:"sessionStore"`
}

type TurnNudgeConfig added in v0.3.66

type TurnNudgeConfig struct {
	// StepInterval injects a budget-status notice (numbers only) after every N
	// completed model steps in a turn (default 20). Steps align with agent maxSteps:
	// one step may batch many tool calls. 0 keeps the default; set a very large
	// value to disable.
	StepInterval int `json:"stepInterval"`
	// TimeIntervalMinutes injects a budget-status notice (numbers only) after every
	// N minutes of turn elapsed time (default 10). 0 keeps the default; set a very
	// large value to disable.
	TimeIntervalMinutes int `json:"timeIntervalMinutes"`
	// StepLimit is the model-step budget for one turn (default 100). Once reached,
	// every further tool result carries LimitMessage telling the model to summarize
	// and end the turn. 0 keeps the default; set a very large value to disable.
	StepLimit int `json:"stepLimit"`
	// TimeLimitMinutes is the elapsed-time budget for one turn (default 60). Once
	// reached, every further tool result carries LimitMessage. 0 keeps the default;
	// set a very large value to disable.
	TimeLimitMinutes int `json:"timeLimitMinutes"`
	// Message is the periodic budget-status template (numbers only, no wrap-up
	// directive); {steps} and {elapsed} are replaced.
	Message string `json:"message"`
	// LimitMessage is injected on every tool result after a limit is reached;
	// {steps} and {elapsed} are replaced.
	LimitMessage string `json:"limitMessage"`
}

func (*TurnNudgeConfig) SetDefaults added in v0.3.66

func (c *TurnNudgeConfig) SetDefaults()

SetDefaults implements pluginkit.Defaulter.

func (*TurnNudgeConfig) Validate added in v0.3.66

func (c *TurnNudgeConfig) Validate() error

Validate implements pluginkit.Validator.

type TurnNudgeDeps added in v0.3.66

type TurnNudgeDeps struct{}

TurnNudgeDeps has no dependencies; state is kept in memory per session.

Jump to

Keyboard shortcuts

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