deferred

package
v0.7.1 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2026 License: Apache-2.0 Imports: 4 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package deferred knows the format of Claude Code's deferred-tools list.

Claude Code defers MCP tools: the `tools` array then carries only the built-ins and a placeholder, and the mcp__* names arrive in a message as a header line, one name per line, and a blank line. Each such list is a delta, so a request carries one per change and the declared set is all of them together.

The format lives here, and not in the dashboard, so a second reader (a filter, a proxy component) uses the same header text and the same end rules. A reader that ended a list in a different place would count a different set of tools.

Index

Constants

View Source
const Header = "The following deferred tools are now available via ToolSearch."

Header starts a list of deferred tools.

Claude Code also sends removals, in wording not yet captured, so a removed server stays in the set until the session ends.

View Source
const MaxNameLen = 128

MaxNameLen is the API's own documented limit for a tool name. dash's maxDeclName is this constant.

Variables

This section is empty.

Functions

func Regions

func Regions(body []byte, budget int) [][]byte

Regions returns every deferred list in the RAW (still JSON-escaped) body, each as a sub-slice of body. It runs on every request, so it is byte searches only and copies nothing. A body without a list returns nil.

A region runs from the header to a blank line (`\n\n` in the escaped body), a closing `</system-reminder>` line, or the end of its JSON string, whichever is first. Both JSON spellings of the tag count: Claude Code writes it literally, an encoder that escapes HTML (Go's does) writes `\u003c/system-reminder\u003e`. Text after a closing tag (a date, another reminder) must not reach a caller's digest. budget bounds the bytes returned in total.

func Texts

func Texts(body []byte) []string

Texts returns the text that Claude Code itself sends and that holds a list: a user or system message's own text, never a tool result, which holds whatever a command printed. Messages without the header are skipped.

func TextsResponses

func TextsResponses(body []byte) []string

TextsResponses is Texts for a Responses body: the `instructions` string, and the text of every user, system or developer item of `input`. As in Texts, a function_call_output (a tool result) is never read.

func ValidName

func ValidName(s string) bool

ValidName reports whether s is a bare tool name: the API's own charset and length.

Types

type List

type List struct {
	Names      []string
	Start, End int
}

List is one parsed list: its tool names and the byte range of the list in the text.

func Lists

func Lists(text string) (lists []List, voided int)

Lists parses every valid list in text. The header must start a line, and every line up to the end of the list must be a bare tool name (ValidName). One line that is not voids that whole list, because a user can quote the header. It returns how many lists it voided, so a caller can log a format change instead of showing "0 MCP servers".

Jump to

Keyboard shortcuts

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