submitresult

package
v0.7.26 Latest Latest
Warning

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

Go to latest
Published: Jun 29, 2026 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Overview

Package submitresult provides tool definitions for AI agents to submit their final results.

It exposes ClaudeTool, GoogleTool, and OpenAITool constructors that build executor tool metadata for the terminal submit_result tool, which agents call to return a structured response at the end of a conversation.

Each provider also offers a non-terminal validate_result companion (ClaudeValidateTool and friends) that advertises the identical schema and reports whether a payload would be accepted, without ending the run. The SubmitAndValidateForResponse constructors build the submit/validate pair from one Options so they share a schema and submit_result's payload errors point the model at validate_result.

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func ClaudeSubmitAndValidateForResponse added in v0.7.6

func ClaudeSubmitAndValidateForResponse[Response any]() (submit, validate claudetool.Metadata[Response], err error)

ClaudeSubmitAndValidateForResponse constructs the terminal submit_result tool and its non-terminal validate companion from one Options, so they share an identical schema and submit_result's payload errors point at the validate tool. Both are inferred from the response type annotations.

Example

ExampleClaudeSubmitAndValidateForResponse demonstrates building the terminal submit_result tool together with its non-terminal validate_result companion.

package main

import (
	"fmt"

	"chainguard.dev/driftlessaf/agents/submitresult"
)

func main() {
	type MyResult struct {
		Summary string `json:"summary" jsonschema:"required,description=Summary of findings"`
	}

	submit, validate, err := submitresult.ClaudeSubmitAndValidateForResponse[*MyResult]()
	if err != nil {
		panic(err)
	}
	fmt.Println("submit:", submit.Definition.Name)
	fmt.Println("validate:", validate.Definition.Name)
}
Output:
submit: submit_result
validate: validate_result

func ClaudeTool

func ClaudeTool[Response any](opts Options[Response]) (claudetool.Metadata[Response], error)

ClaudeTool constructs the Claude executor metadata for the submit_result tool.

Example

ExampleClaudeTool demonstrates constructing the Claude submit_result tool metadata for a custom response type.

package main

import (
	"fmt"

	"chainguard.dev/driftlessaf/agents/submitresult"
)

func main() {
	type MyResult struct {
		Summary string `json:"summary" jsonschema:"required,description=Summary of findings"`
	}

	tool, err := submitresult.ClaudeTool[*MyResult](submitresult.Options[*MyResult]{
		Description:        "Submit the final analysis result.",
		PayloadDescription: "Structured analysis result.",
	})
	if err != nil {
		panic(err)
	}
	fmt.Println("tool name:", tool.Definition.Name)
}
Output:
tool name: submit_result

func ClaudeToolForResponse

func ClaudeToolForResponse[Response any]() (claudetool.Metadata[Response], error)

ClaudeToolForResponse constructs the submit_result tool using metadata inferred from the response type annotations.

func ClaudeValidateTool added in v0.7.6

func ClaudeValidateTool[Response any](opts Options[Response]) (claudetool.Metadata[Response], error)

ClaudeValidateTool constructs the Claude executor metadata for the non-terminal validate tool. It takes the identical schema as submit_result and reports whether the payload would be accepted, without setting the run's final result — giving the model a safe way to check its payload's shape before the terminal submit.

func GoogleSubmitAndValidateForResponse added in v0.7.6

func GoogleSubmitAndValidateForResponse[Response any]() (submit, validate googletool.Metadata[Response], err error)

GoogleSubmitAndValidateForResponse constructs the terminal submit_result tool and its non-terminal validate companion from one Options, so they share an identical schema and submit_result's payload errors point at the validate tool.

func GoogleTool

func GoogleTool[Response any](opts Options[Response]) (googletool.Metadata[Response], error)

GoogleTool constructs the Google executor metadata for the submit_result tool.

func GoogleToolForResponse

func GoogleToolForResponse[Response any]() (googletool.Metadata[Response], error)

GoogleToolForResponse constructs the submit_result tool using metadata inferred from the response type annotations.

func GoogleValidateTool added in v0.7.6

func GoogleValidateTool[Response any](opts Options[Response]) (googletool.Metadata[Response], error)

GoogleValidateTool constructs the non-terminal validate tool for the Google executor. It takes submit_result's identical schema and reports whether a payload would be accepted, without setting the run's final result.

func OpenAISubmitAndValidateForResponse added in v0.7.6

func OpenAISubmitAndValidateForResponse[Response any]() (submit, validate openaistool.Metadata[Response], err error)

OpenAISubmitAndValidateForResponse constructs the terminal submit_result tool and its non-terminal validate companion from one Options, so they share an identical schema and submit_result's payload errors point at the validate tool.

func OpenAITool added in v0.3.0

func OpenAITool[Response any](opts Options[Response]) (openaistool.Metadata[Response], error)

OpenAITool constructs the OpenAI executor metadata for the submit_result tool.

func OpenAIToolForResponse added in v0.3.0

func OpenAIToolForResponse[Response any]() (openaistool.Metadata[Response], error)

OpenAIToolForResponse constructs the submit_result tool using metadata inferred from the response type annotations.

func OpenAIValidateTool added in v0.7.6

func OpenAIValidateTool[Response any](opts Options[Response]) (openaistool.Metadata[Response], error)

OpenAIValidateTool constructs the non-terminal validate tool for the OpenAI executor. It takes submit_result's identical schema and reports whether a payload would be accepted, without setting the run's final result.

Types

type Options

type Options[Response any] struct {
	ToolName           string
	Description        string
	SuccessMessage     string
	PayloadFieldName   string
	PayloadDescription string
	Generator          *schema.Generator

	// ValidateToolName names the non-terminal companion tool that takes the
	// identical schema and reports whether a payload would be accepted without
	// ending the run. When non-empty, submit_result's payload errors point the
	// model at it. Empty (the default) emits no such hint, for callers that
	// register submit_result without a validate companion.
	ValidateToolName string
}

Options configures the submit_result tool wiring.

func OptionsForResponse

func OptionsForResponse[T any]() Options[T]

OptionsForResponse returns an Options pre-populated from the annotations present on the response type T. Callers may further customize the returned struct before passing it to ClaudeTool or GoogleTool.

Jump to

Keyboard shortcuts

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