ids

package
v1.261022.1 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2026 License: MPL-2.0 Imports: 2 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package ids mints the identifiers tingly-box puts on protocol objects it synthesizes on behalf of an upstream that speaks a different protocol: Responses API response and output item ids, Anthropic message ids, and a tool call id when the upstream omitted one.

The gateway serves the standard wire form first and adapts providers behind it, so every minted id has the canonical OpenAI shape "<prefix>_<32 lowercase hex>" (a random uuid v4) regardless of which provider produced the content. Random ids are also what OpenAI itself issues; clients such as Codex persist them and replay them verbatim, so an id is random only at the moment it is minted and stable ever after.

The shape satisfies every constraint OpenAI enforces when such ids are replayed into a native Responses request: type prefix (fc_, msg_, rs_), charset [A-Za-z0-9_-], at most 64 characters, unique within the input. Neither timestamps (collide within a second) nor upstream-derived ids (leak the provider's shape, can exceed 64 chars) meet all of them.

See .design/protocol-responses.md §2 for the discussion behind these rules.

Index

Constants

View Source
const (
	PrefixResponse     = "resp"
	PrefixMessage      = "msg"
	PrefixFunctionCall = "fc"
	PrefixReasoning    = "rs"
	PrefixCall         = "call"
)

Prefixes of the ids the gateway mints.

Variables

This section is empty.

Functions

func Call

func Call() string

Call mints a tool call correlation id (call_...) for an upstream tool call that arrived without one.

func FunctionCall

func FunctionCall() string

FunctionCall mints a function_call item id (fc_...). It is distinct from the call_id, which is the correlation key and always comes from upstream when the upstream provides one.

func Message

func Message() string

Message mints a message item id (msg_...). It doubles as the Anthropic message id, whose canonical form uses the same prefix.

func New

func New(prefix string) string

New returns "<prefix>_<32 hex>".

func Reasoning

func Reasoning() string

Reasoning mints a reasoning item id (rs_...).

func Response

func Response() string

Response mints a Responses API response id (resp_...).

func SetGeneratorForTest

func SetGeneratorForTest(fn func() string) (restore func())

SetGeneratorForTest replaces the random suffix generator, so tests and recording replays get a deterministic sequence. It returns a restore func.

Types

This section is empty.

Jump to

Keyboard shortcuts

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