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 submit metadata for the terminal submit_result tool, which agents call to return a structured response at the end of a conversation. The handlers parse the call into a toolcall.SubmitOutcome; the executor decides whether the parsed response commits (ending the run) after running its registered result validators (see the executors' WithResultValidator option), or is rejected back to the model with the validators' findings so the loop continues.
Payload leniency: when the model JSON-encodes the payload object into a string instead of passing it as a nested object (a common model mistake), the handlers transparently decode the string and accept the submit instead of rejecting it with a parameter error. Strings that do not contain a JSON object are still rejected back to the model.
Index ¶
- func ClaudeTool[Response any](opts Options[Response]) (claudetool.SubmitMetadata[Response], error)
- func ClaudeToolForResponse[Response any]() (claudetool.SubmitMetadata[Response], error)
- func GoogleTool[Response any](opts Options[Response]) (googletool.SubmitMetadata[Response], error)
- func GoogleToolForResponse[Response any]() (googletool.SubmitMetadata[Response], error)
- func OpenAITool[Response any](opts Options[Response]) (openaistool.SubmitMetadata[Response], error)
- func OpenAIToolForResponse[Response any]() (openaistool.SubmitMetadata[Response], error)
- type Options
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ClaudeTool ¶
func ClaudeTool[Response any](opts Options[Response]) (claudetool.SubmitMetadata[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.SubmitMetadata[Response], error)
ClaudeToolForResponse constructs the submit_result tool using metadata inferred from the response type annotations.
func GoogleTool ¶
func GoogleTool[Response any](opts Options[Response]) (googletool.SubmitMetadata[Response], error)
GoogleTool constructs the Google executor metadata for the submit_result tool.
func GoogleToolForResponse ¶
func GoogleToolForResponse[Response any]() (googletool.SubmitMetadata[Response], error)
GoogleToolForResponse constructs the submit_result tool using metadata inferred from the response type annotations.
func OpenAITool ¶ added in v0.3.0
func OpenAITool[Response any](opts Options[Response]) (openaistool.SubmitMetadata[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.SubmitMetadata[Response], error)
OpenAIToolForResponse constructs the submit_result tool using metadata inferred from the response type annotations.
Types ¶
type Options ¶
type Options[Response any] struct { ToolName string Description string SuccessMessage string PayloadFieldName string PayloadDescription string Generator *schema.Generator }
Options configures the submit_result tool wiring.
func OptionsForResponse ¶
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.