Circle V2 API Docs
    Preparing search index...

    Function defineStep

    • Wrap a function at its definition so it opens a LangSmith child span every time it runs — the definition-site counterpart to the call-site withStepTrace. The wrapped export keeps its own name (no traced twin), and the span nests automatically under whatever root/child span is active (via traceable's async context). Use it for deterministic pipeline steps — gates, derivations, post-process — whose output you'd want to inspect in a trace.

      The return value is auto-captured as the span's output (through the Set/Map-safe trace serializer); pass traceInputs to also record a non-PII projection of the arguments. Tracing no-ops when disabled, so the wrapped function runs its raw body unchanged (just Promise-wrapped).

      Because traceable always returns a promise, the wrapped function is async even if fn is synchronous — call sites and tests await it.

      Type Parameters

      • TArgs extends unknown[]
      • TReturn

      Parameters

      Returns (...args: TArgs) => Promise<TReturn>