schema

package
v0.0.0-...-5f7de7d Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package schema provides helpers for building tool input schemas.

Package internal provides shared utilities for tool implementations

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Array

func Array(desc string, itemType string) map[string]any

Array creates an array property definition.

func Bool

func Bool(desc string) map[string]any

Bool creates a boolean property definition.

func Integer

func Integer(desc string) map[string]any

Integer creates an integer property definition.

func Parse

func Parse[T any](input string) (T, error)

Parse unmarshals tool input JSON into the given type.

func Props

func Props(required []string, properties map[string]any) anthropic.ToolInputSchemaParam

Props builds an InputSchema from a map of property definitions.

func ShouldTruncateOldToolResult

func ShouldTruncateOldToolResult(turnsAgo int) bool

ShouldTruncateOldToolResult determines if an old tool result should be summarized. turnsAgo: how many turns ago this tool result occurred.

func Str

func Str(desc string) map[string]any

Str creates a string property definition.

func SummarizeFileWrite

func SummarizeFileWrite(path string, lineCount int) string

SummarizeFileWrite creates a brief summary for file write operations.

func SummarizeOldToolResult

func SummarizeOldToolResult(toolName, fullOutput string) string

SummarizeOldToolResult creates a brief summary of an old tool result. This is used when pruning old tool results from conversation history.

func TruncateFileRead

func TruncateFileRead(content string, truncated bool) string

TruncateFileRead truncates file read output for very large files. Files under 2000 lines are returned in full — truncating source files causes repeated re-reads that waste API turns (far more expensive than the extra context tokens). Truncation is for large error logs, content dumps, and generated files — not normal source code. Files over 2000 lines get truncated (first 500 + last 50).

func TruncateLines

func TruncateLines(output string, keepFirst, keepLast int) string

TruncateLines smart-truncates multi-line output to keep context manageable. keepFirst: number of lines to keep from the start keepLast: number of lines to keep from the end Returns truncated output with a marker showing how many lines were removed.

func TruncateList

func TruncateList(items []string, maxItems int) string

TruncateList truncates a list of items (e.g., file listings). maxItems: maximum number of items to show before truncating.

func TruncateShellOutput

func TruncateShellOutput(output string) string

TruncateShellOutput truncates shell command output intelligently. Default: keep first 20 + last 10 lines if over 40 lines total.

Types

This section is empty.

Jump to

Keyboard shortcuts

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