scriptfail

package
v1.140.0 Latest Latest
Warning

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

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

Documentation

Overview

Package scriptfail reads a managed script's failed tool call the way the tool classified it (#2032): whose problem the failure is, whether the next run is expected to pass, the sentence a person reads that in, whether the host may issue the call again, and the envelope a script asking for its failures back (on_error = "return") is handed. mcp-trino's trino_query and trino_execute classify every failure in structuredContent.error; the classification is read from that envelope and never from the message text. Extracted from internal/platform/scriptrun, which holds the interpreter and its bindings, for its size budget.

Index

Constants

View Source
const (
	// OnErrorRaise ends the run on a failed call: the default.
	OnErrorRaise = "raise"
	// OnErrorReturn hands a failed call back to the script as data.
	OnErrorReturn = "return"
)

The values platform.query, platform.execute and platform.call take for on_error.

Variables

This section is empty.

Functions

func Class

func Class(env map[string]any) string

Class is the sentence a classified failure is shown with.

func Classify

func Classify(tool string, err error) error

Classify reads a failed call's envelope: a failure its tool classified as retryable ends the run as the upstream's (cause upstream, retryable), and any classified failure carries the sentence describing it. A failure the tool did not classify, and one already attributed, is returned unchanged.

func Detail

func Detail(env map[string]any) string

Detail names what the upstream reported: Trino's error type and name and the SQLSTATE a connector passed through, or how the connection failed.

func Envelope

func Envelope(err error) (map[string]any, bool)

Envelope is the failure a script that asked for it is handed: the tool's error envelope, with code, message and retryable always present; false when err is not a failed tool call. A call whose upstream did not answer is retryable whatever its envelope says, as the run it would have ended is.

func OnError

func OnError(binding, value string) (bool, error)

OnError reads a binding's on_error= argument: true when a failed call is to be returned to the script rather than end the run.

func Retries

func Retries(refusal *scriptsession.RefusalError) bool

Retries reports whether the host may issue a read again after this refusal: its tool reported the failure as temporary, and the upstream itself said so. A failure to reach the upstream at all (transport) is not issued again, because the Trino client has already retried the connection for up to its own limit before reporting it (txn2/mcp-trino#106).

Types

This section is empty.

Jump to

Keyboard shortcuts

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