responses

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jul 5, 2026 License: MIT Imports: 19 Imported by: 0

Documentation

Overview

Package responses integrates OpenAI's Responses API workflows.

Index

Constants

View Source
const DefaultMaxOutputTokens = 16384

DefaultMaxOutputTokens is the fallback output-token budget for reasoning models (gpt-5*) when the caller does not specify --max-tokens. The API default (1024) is far too small — reasoning tokens compete with the visible response, so the model exhausts its budget on thinking alone.

View Source
const MaxResponsesInputTokens = 250_000

MaxResponsesInputTokens caps server-billed input tokens per iteration. OpenAI re-bills the full previous_response_id chain on every call, so unbounded server-side context translates directly to unbounded cost. When a response reports more input tokens than this, the loop returns with ErrInputTokenCapReached.

Variables

View Source
var ErrInputTokenCapReached = errors.New("input token cap reached")

ErrInputTokenCapReached signals the input-token watchdog tripped in the Responses API tool loop.

Functions

func ConvertTools

func ConvertTools(toolDefs []llms.Tool) []oairesponses.ToolUnionParam

ConvertTools converts langchaingo tool definitions to the Responses API FunctionToolParam format.

func IsReasoningModel

func IsReasoningModel(model string, prefixes []string) bool

IsReasoningModel reports whether a model emits reasoning tokens that require a larger output-token budget. It checks the model name against the configured reasoning prefixes (e.g. ["gpt-5"]).

func RunWithTools

func RunWithTools(ctx context.Context, apiKey, baseURL, model, systemPrompt, userPrompt, workingDir, organization, resumeResponseID string, temperature float64, maxTokens, maxIterations, editDeadline int, reasoningPrefixes []string, taskCfg *tools.TaskConfig, m *metrics.Metrics, ex executor.Executor, skillRuntime *tools.SkillRuntime, confirmRuntime *tools.ConfirmRuntime) (string, error)

RunWithTools drives a tool-calling loop using the OpenAI Responses API. resumeResponseID, if non-empty, chains the initial request via PreviousResponseID so a prior session can be continued server-side.

func UseResponsesAPI

func UseResponsesAPI(provider, model string, prefixes []string) bool

UseResponsesAPI reports whether the Responses API path should be used.

Types

type Config

type Config struct {
	Model             string
	Tools             []oairesponses.ToolUnionParam
	Temperature       float64
	MaxTokens         int
	Instructions      string
	ReasoningPrefixes []string
}

Config bundles the immutable parameters for a Responses API session.

type FunctionCall

type FunctionCall struct {
	ID        string
	CallID    string
	Name      string
	Arguments string
}

FunctionCall holds the parsed details of a function_call item from the Responses API output.

func ExtractFunctionCalls

func ExtractFunctionCalls(resp *oairesponses.Response) []FunctionCall

ExtractFunctionCalls pulls function_call items from a Responses API response.

Jump to

Keyboard shortcuts

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