Build and unpack typed data with codecs
Connect Encode/Decode pairs while preserving missing fields, explicit null, list positions and remainders.
A codec is an ordinary reusable node that builds or unpacks a value with an exact published type. Encode combines declared fields into the named structure; Decode exposes those fields as typed output sockets. Codec pairs let both people and agents work with meaningful contracts instead of repeatedly writing ad hoc object extraction code.
Find a matching pair#
Search the type name in Library and inspect its Encode and Decode assets. The selected operation's socket contract determines which pair is compatible. Similar names or shape-equivalent schemas do not establish identity; verify the exact type ID and version.
Current pack discovery groups paired codecs with their types and may hide raw transport helpers that are still retained for old pins. Adding a pack does not upgrade an existing graph or replace a historically published codec.
A typical pattern is request Encode → provider operation → response Decode. For a structured output field, add its own compatible Decode only when the workflow needs those inner fields. Leave irrelevant optional outputs unwired.
Missing, null and remainder#
Absence is different from explicit null. A Decode may omit an optional field entirely. Wiring that missing output into a dependent node normally makes the dependent path skip; ONF does not fill it from a literal after a connection was chosen.
Semantic record codecs expose declared compatible fields and retain other values in a named remainder contract. Encode merges declared fields with that remainder and rejects duplicate ownership rather than silently choosing a winner. This matters when extending provider payloads or rebuilding a value losslessly.
Nullable Decode produces an is_null flag and, when non-null, a typed value. Its Encode requires the matching presence relationship. JSON Value variants use an explicit kind and a matching scalar, record or list value; null carries no additional payload.
Lists and dynamic JSON#
List Decode selects an index, usually configured as zero by default. It exposes an optional item, the remaining typed list, the selected index and original count. Empty lists have no item. Encode reinserts an optional item and validates any supplied count. A constrained nonempty list can use a separate empty-capable Rest type.
Dynamic dictionaries use a finite named JSON vocabulary rather than inventing a new schema for every unknown provider field. JSON Record can become typed entries, each with a key and JSON Value. Encoders preserve JSON data and reject duplicate dictionary ownership. Backend persistence may impose additional key restrictions beyond a pure codec's schema.
Validate a round trip#
Use representative synthetic records with absent optional properties, null variants, empty/nonempty lists and unfamiliar remainder fields. Decode then Encode only the outputs actually present. Compare the reconstructed JSON and run the exact target schema validation.
Codecs are transformations. They do not obtain OAuth grants, call providers, inject service defaults or prove that a provider will accept the resulting business request. Use mapping for deliberate shape conversion and collections for per-item graph execution.
Source provenance
Reviewed against maintained source and topic documentation on 23 October 2026. This is a source snapshot; installed versions and provider access may differ.
docs/TYPED-DATA-CODECS.mddocs/TYPES-AND-VERSIONING.mddocs/LIBRARY-PACKS.mddocs/STORAGE.md