lloyal-agents API Reference
    Preparing search index...

    Function traceScope

    • Create matched scope:open / scope:close pairs for building the trace tree

      Opens a named scope immediately and returns a handle to close it later. The close callback emits a scope:close event with the elapsed duration and flushes the writer, ensuring scope boundaries are always persisted.

      Used throughout the runtime to bracket agent pools, tool dispatches, shared-root regions, and generation passes.

      Parameters

      • writer: TraceWriter

        Active TraceWriter to emit events to

      • parentTraceId: number

        Trace ID of the enclosing scope, or null for root scopes

      • name: string

        Human-readable scope label (e.g. "pool", "tool:search")

      • Optionalmeta: Record<string, unknown>

        Optional key-value metadata attached to the scope:open event

      Returns { close: () => void; traceId: number }

      Object with the allocated traceId and a close callback