Circle V2 API Docs
    Preparing search index...

    Function serializeForTrace

    • Recursively normalize a value into a JSON-safe shape for LangSmith trace inputs/outputs.

      LangSmith serializes trace payloads with JSON.stringify, which turns a Set or Map into {} (they carry no own-enumerable properties). This walks the value first and folds the containers we actually return from steps into arrays / objects so they render as their contents instead of an empty object. Everything JSON already handles (primitives, arrays, plain objects) passes through untouched; a Date becomes its ISO string.

      Applied inside the span helpers (withStepTrace / withRootTrace), so every span — including defineStep, which builds on withStepTrace — gets it for free. Runtime return values are never affected: this only shapes the trace copy.

      Parameters

      • value: unknown

      Returns unknown