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

tools

package
v0.4.34 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExposedToolName added in v0.3.34

func ExposedToolName(canonical string) string

ExposedToolName makes a plugin tool name safe for OpenAI function / Responses API input names (^ [a-zA-Z0-9_-]+$). Non [A-Za-z0-9_] runes become '_'.

func NewRuntime

func NewRuntime(cfg RuntimeConfig, deps RuntimeDeps) (agentkit.ToolRuntime, error)

NewRuntime registers tools/runtime: Tool orchestration: visibility, policy evaluation, hooks, execution, result capping.

Best practices:

  • Policies are the enforcement plane; hooks only observe and rewrite. Put a security rule in a policy.
  • The approval dep is consulted only for ask decisions, so it never sees an allowed or denied call.

func ResultText

func ResultText(result agentkit.ToolResult) string

Types

type Runtime

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

Runtime executes tools through the policy and approval pipeline.

func (*Runtime) Execute

func (r *Runtime) Execute(ctx context.Context, call agentkit.ToolCall) (agentkit.ToolResult, error)

func (*Runtime) PreflightTool added in v0.3.55

PreflightTool runs visibility, policy, approval, and BeforeTool for one call. When runBody is false, result is final (deny, not found, etc.).

func (*Runtime) RunToolBody added in v0.3.55

func (r *Runtime) RunToolBody(ctx context.Context, call agentkit.ToolCall) (agentkit.ToolResult, error)

RunToolBody executes the tool body and AfterTool. Call only after a successful PreflightTool.

func (*Runtime) StaticToolNames added in v0.3.27

func (r *Runtime) StaticToolNames() []string

StaticToolNames returns tool names from deps.tools and deps.toolPacks only (not dynamic providers). tools/deferred uses this to decide which specs stay eager in the model-visible list.

func (*Runtime) Visible

func (r *Runtime) Visible(ctx context.Context) ([]agentkit.ToolSpec, error)

type RuntimeConfig

type RuntimeConfig struct {
	// DefaultTimeoutSeconds is per-call timeout when a tool has no specific entry.
	DefaultTimeoutSeconds int `json:"defaultTimeoutSeconds"`
	// MaxResultBytes is deprecated and ignored; spill/truncation happens in session.PrepareToolResultForStorage.
	MaxResultBytes int `json:"maxResultBytes"`
	// ToolTimeouts are per-tool timeout overrides, keyed by tool name (canonical or model-visible; normalized like ExposedToolName).
	ToolTimeouts map[string]int `json:"toolTimeouts,omitempty"`
	// AllowTools is a model-visible tool name whitelist. When non-empty, only listed tools are exposed (names normalized like ExposedToolName).
	AllowTools []string `json:"allowTools,omitempty"`
	// DenyTools is a model-visible tool name blacklist. Ignored when AllowTools is set (names normalized like ExposedToolName).
	DenyTools []string `json:"denyTools,omitempty"`
}

func (*RuntimeConfig) Validate added in v0.3.48

func (c *RuntimeConfig) Validate() error

Validate implements pluginkit.Validator.

type RuntimeDeps

type RuntimeDeps struct {
	Tools        []agentkit.Tool         `json:"tools,omitempty"`
	ToolPacks    []agentkit.ToolPack     `json:"toolPacks,omitempty"`
	DynamicTools []agentkit.ToolProvider `json:"dynamicTools,omitempty"`
	Policies     []agentkit.Policy       `json:"policies,omitempty"`
	Approval     agentkit.Approval       `json:"approval,omitempty"`
	Hooks        agentkit.HookRuntime    `json:"hooks,omitempty"`
}

Jump to

Keyboard shortcuts

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