Expand description
Shared helpers for codec validation, diagnostics, and preservation metadata.
Constants§
- PRESERVATION_
METADATA_ KEY - Public alias for the embedded preservation metadata key.
- SWITCHYARD_
METADATA_ KEY - Metadata key used to embed exact preserved payloads in provider JSON.
Functions§
- capture_
request_ preservation - Captures an exact source request body according to preservation policy.
- capture_
response_ preservation - Captures an exact source response body according to preservation policy.
- compact_
text_ blocks - Joins non-empty text fragments with a caller-provided separator.
- embed_
preservation - Embeds preservation metadata into a translated wire body when requested.
- exact_
preserved_ request - Returns an exact preserved request for the target format when available.
- exact_
preserved_ response - Returns an exact preserved response for the target format when available.
- extract_
preservation - Extracts embedded preservation metadata from a provider wire body.
- is_
truthy_ string - Returns a non-empty string when the value is string-like enough to preserve.
- json_
string - Serializes JSON values into provider argument strings.
- normalize_
anthropic_ tool_ use_ ids - Normalizes Anthropic tool-use IDs while keeping tool_use/tool_result pairs aligned.
- object
- Reads a JSON object or returns a typed translation error at the given path.
- prepare_
request_ for_ target - Applies a selected target model and optionally prepends its system prompt.
- push_
lossy - Applies the lossy-conversion policy and records diagnostics when configured.
- push_
unknown_ field - Applies the unknown-field policy and records diagnostics when configured.
- sanitize_
anthropic_ tool_ use_ id - Converts an ID into a reversible Anthropic-safe representation.
- stable_
id - Generates a stable, human-readable ID from a prefix and counter.
- string_
value - Converts JSON scalars to Python-compatible string values where providers do so.
- validate_
request_ capabilities - Checks a request against declared target capabilities.