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

tools

package
v0.1.0-alpha.4 Latest Latest
Warning

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

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

Documentation

Overview

Package tools provides the built-in tool executors that an agent runtime runs inside a sandbox, plus the model-facing input schemas that describe them to the model.

A tool execution error (bad input, missing file, unimplemented tool) is reported to the model via Result.IsError so the model can recover; it is not a session-level error.

Index

Constants

View Source
const (
	// CMA documents a file-backed preview above 100,000 characters. Mango
	// applies the same threshold to its projected model-visible UTF-8 text.
	MaxInlineResultChars = 100_000
	ResultPreviewChars   = 2_000
)

Variables

This section is empty.

Functions

func ResultPreview

func ResultPreview(text string) string

ResultPreview returns the bounded UTF-8 preview used after full output retention.

func Schema

func Schema(name string) map[string]any

Schema returns the model-facing JSON input_schema for the named tool, or nil if the tool is unknown. Shapes adapt useful public tool conventions to the semantics Mango actually implements.

web_fetch/web_search are declared to the model through their native routing path, but still need legal local schema objects for shared configuration and fallback validation. The real Anthropic API rejects "input_schema":null (400). They therefore get a minimal permissive {"type":"object"} schema. Only a genuinely unknown tool name (not one of the eight built-ins) returns nil.

func SelfHostedSchema

func SelfHostedSchema(name string) map[string]any

SelfHostedSchema returns the model-facing contract implemented by an Environment worker. Only the worker-owned bash tool has additional lifecycle controls; the transitional Mango-managed executor remains a one-shot process and continues to use Schema.

Types

type Result

type Result struct {
	Content []any
	IsError bool
}

Result is the outcome of a tool execution. Content is the wire block array (a list of {type:"text", text:string} maps) fed back to the model.

func ProjectMCPResult

func ProjectMCPResult(
	input mcpclient.Result,
) (result Result, raw json.RawMessage, err error)

ProjectMCPResult separates a protocol-native MCP result from the content sent to the model. _meta and other control fields remain only in the bounded raw diagnostic value. The control plane cannot write into an operator-owned self-hosted workspace, so binary content is reported as unsupported instead of returning a path the worker could not read.

Jump to

Keyboard shortcuts

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