Skip to main content
weave / Turn

Hierarchy

  • SpanBase Turn

Table of contents

Accessors

Methods

Accessors

agentName

get agentName(): string

Returns

string

Defined in

src/genai/turn.ts:103

model

get model(): string

Returns

string

Defined in

src/genai/turn.ts:107

Methods

addEvent

Deprecated. Record this data via setAttributes instead. OpenTelemetry is phasing out the Span Event API (Span.addEvent). This method still works and existing span-event data stays valid. See https://opentelemetry.io/blog/2026/deprecating-span-events/Example
span.addEvent('context_compacted', {: 12});
addEvent(name, attributes?, startTime?): this Add a named event to the span. Useful for marking non-span moments such as context compaction, tool-loop detection, or guardrail trips. Warns and no-ops after end(). Mirrors OTel Span.addEvent.

Parameters

NameType
namestring
attributes?Attributes
startTime?TimeInput

Returns

this

Inherited from

SpanBase.addEvent

Defined in

src/genai/spanBase.ts:82

end

end(opts?): void Read current field values (to reflect mutations made via record() since start) and close the span. Idempotent. Pass error to mark it as failed; pass endTime to backdate the close.

Parameters

NameType
opts?SpanEndOptions

Returns

void

Defined in

src/genai/turn.ts:241

record

record(opts): this Bulk-set any subset of the mutable fields. Replaces (does not merge). Useful for assigning everything at once after a provider call returns.

Parameters

NameType
optsObject
opts.agentDescription?string
opts.agentId?string
opts.agentName?string
opts.agentVersion?string
opts.messages?Message[]
opts.model?string
opts.systemInstructions?string[]

Returns

this

Defined in

src/genai/turn.ts:201

setAttribute

Deprecated. Use setAttributes instead, which mirrors the Python SDK’s set_attributes and OTel’s Span.setAttributes. Retained as a thin alias so existing single-attribute callers keep working. Only Turn carries this — the other emitters never shipped a singular form.
setAttribute(key, value): this

Parameters

NameType
keystring
valueAttributeValue

Returns

this

Defined in

src/genai/turn.ts:193

setAttributes

setAttributes(attributes): this Set multiple attributes on the span at once. Warns and no-ops after end(). Mirrors OTel Span.setAttributes (and the Python SDK’s set_attributes).

Parameters

NameType
attributesAttributes

Returns

this Example
span.setAttributes({'weave.tag': 'prod', 'gen_ai.response.id': id});

Inherited from

SpanBase.setAttributes

Defined in

src/genai/spanBase.ts:63

startLLM

startLLM(opts): LLM Start a child LLM span under this Turn.

Parameters

NameType
optsLLMInit

Returns

LLM

Defined in

src/genai/turn.ts:161

startSubagent

startSubagent(opts): SubAgent Start a child SubAgent span under this Turn.

Parameters

NameType
optsSubAgentInit

Returns

SubAgent

Defined in

src/genai/turn.ts:179

startTool

startTool(opts): Tool Start a child Tool span under this Turn.

Parameters

NameType
optsToolInit

Returns

Tool

Defined in

src/genai/turn.ts:170

create

create(opts?): Turn

Parameters

NameType
optsTurnInit & { conversationId?: string }

Returns

Turn

Defined in

src/genai/turn.ts:124