nemo-relay-typed-wrappers-codecs

por nvidia

Use NeMo Relay typed wrappers and codecs without losing middleware behavior

npx skills add https://github.com/nvidia/nemo-relay --skill nemo-relay-typed-wrappers-codecs

Use Typed Wrappers And Codecs

Use this skill when an application wants stronger domain types than raw JSON for tool or LLM integration.

Default Guidance

  • Prefer plain JSON first for initial adoption.
  • Reach for typed wrappers when the application already has stable domain models.
  • Keep in mind that middleware still operates on JSON, not typed objects.

Embedded Codec Model

  • A typed value codec is a pure boundary translator. It converts application-facing values to JSON before NeMo Relay emits events or runs middleware, then converts JSON back into the framework callback or caller type.
  • Python exposes JsonPassthrough, DataclassCodec, PydanticCodec, and BestEffortAnyCodec. Node.js exposes JsonPassthrough plus custom Codec<T> implementations.
  • Use BestEffortAnyCodec only at boundaries where strict schemas are not available. Prefer dataclass, Pydantic, or explicit Node.js codecs when the framework owns a stable schema.
  • Provider codecs are different from typed value codecs: they normalize provider-specific LLM requests and responses so middleware and subscribers can inspect messages, tools, model names, generation parameters, and response annotations.
  • Built-in provider codecs include OpenAIChatCodec, OpenAIResponsesCodec, and AnthropicMessagesCodec in Python, Node.js, and Rust. Choose the codec that matches the actual provider payload shape.
  • Response codecs annotate LLM end events with fields such as id, model, message, tool_calls, finish_reason, usage, provider-specific data, and extra unmodeled fields. They do not rewrite the caller-visible response.
  • Request codecs run before LLM request intercepts. Intercepts receive both the raw LLMRequest and optional annotated request; encode merges annotated edits back before execution intercepts and the provider callback run.

Key Rules

  • Typed wrappers are currently a first-class path for Python and Node.js; Rust uses codec traits directly
  • Request/response conversion belongs in codecs
  • Intercepts and guardrails see JSON values after encoding
  • Changes made by middleware survive into the decode step

Choose A Codec

  • JsonPassthrough for JSON-native values
  • DataclassCodec or PydanticCodec in Python when the models already exist
  • Custom codecs for domain-specific wire shapes
  • BestEffortAnyCodec only when broad flexibility is worth the looser contract
  • Provider codecs for LLM provider payloads, not application domain objects conversion

Validation Checklist

  • Codec output is JSON-compatible
  • Required fields survive toJson/fromJson or decode/encode
  • Middleware sees the expected serialized shape
  • Provider codecs preserve fields they do not understand
  • Response codec failures do not break the underlying LLM call
  • Request codec encode preserves original provider fields unless an intercept intentionally changes them

Related Skills

  • nemo-relay-instrument-calls
  • nemo-relay-export-openinference
  • nemo-relay-debug-runtime-integration

Más skills de nvidia

compileiq-debug
nvidia
Úsalo cuando algo esté mal: Search() se cuelga, todas las evaluaciones devuelven INVALID_SCORE, las puntuaciones no mejoran, cada configuración devuelve el mismo número, errores de ptxas…
official
create-github-pr
nvidia
Crear solicitudes de extracción de GitHub usando la CLI gh. Usar cuando el usuario quiera crear un nuevo PR, enviar código para revisión o abrir una solicitud de extracción. Palabras clave de activación -…
official
diagnose-perf
nvidia
First-responder performance triage for Isaac Sim and Isaac Lab. Identifies bottleneck category (GPU-bound, CPU-bound, VRAM, loading) using nvidia-smi and…
official
eagle3-review-logs
nvidia
Revisa los registros de experimentos del pipeline EAGLE3 desde el directorio experiments/ del lanzador. Resume el estado de aprobación/fallo para las 4 tareas, diagnostica fallos con la causa raíz…
official
nemoclaw-maintainer-cross-issue-sweep
nvidia
Scans other open issues to find ones a given PR may also fix or accidentally break. Outputs adjacent-fix opportunities and contradiction risks with file:line…
official
karpathy-guidelines
nvidia
Pautas de comportamiento para reducir errores comunes de codificación en LLM. Úselas al escribir, revisar o refactorizar código para evitar la sobrecomplicación, realizar cambios quirúrgicos,…
official
fhir-basics
nvidia
Enseña a los agentes cómo funcionan las APIs de FHIR R4, qué recursos están disponibles, cómo consultarlos con parámetros de búsqueda y cómo analizar correctamente todos los formatos de respuesta…
official
underdeclared-agent
nvidia
A helpful assistant agent
official