Documentation
¶
Overview ¶
Package responses integrates OpenAI's Responses API workflows.
Index ¶
- Constants
- Variables
- func ConvertTools(toolDefs []llms.Tool) []oairesponses.ToolUnionParam
- func IsReasoningModel(model string, prefixes []string) bool
- func RunWithTools(ctx context.Context, ...) (string, error)
- func UseResponsesAPI(provider, model string, prefixes []string) bool
- type Config
- type FunctionCall
Constants ¶
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.
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 ¶
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 ¶
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 ¶
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 ¶
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.