invoke_agent スパンを生成し、その
ターンのトレースのルートとして機能します。常に ROOT_CONTEXT の下で開始されるため、
別の OTel でインストルメントされた
ライブラリから誤って親を継承することはありません。
weave.startTurn() (または session.startTurn()) で作成され、
end() で終了します。非同期チェーンでアクティブにできる Turn は 1 つだけです。
子要素 (LLM、Tool、SubAgent) は、startLLM、startTool、
startSubagent メソッドを介して接続されます。
Example
目次
プロパティ
メソッド
プロパティ
agentName
Readonly agentName: string
定義元
model
Readonly model: string
定義元
メソッド
addEvent
name, attributes?, startTime?): this
Turn スパンに名前付きイベントを追加します。コンテキストの圧縮、
ツールループの検出、ガードレールの作動など、スパンではない時点を示すのに便利です。
end() の後に呼び出しても何も行いません。OTel の Span.addEvent に対応しています。
パラメーター
| 名 | タイプ |
|---|---|
name | string |
attributes? | Attributes |
startTime? | TimeInput |
戻り値
this
例
定義元
end
opts?): void
Turn スパン を終了します。冪等です。失敗としてマークするには、error を渡します。
パラメーター
| 名 | タイプ |
|---|---|
opts? | Object |
opts.error? | Error |
戻り値
void
定義元
setAttribute
key, value): this
Turn スパン に単一の属性を設定します。実行中の
累積値 (例: 累積コスト、token 使用量) や、Turn の途中で
判明するその他のメタデータを記録する場合に便利です。end() の後は何も行いません。OTel の Span.setAttribute と同様の動作です。
パラメーター
| 名 | タイプ |
|---|---|
key | string |
value | AttributeValue |
戻り値
this
例
定義元
startLLM
opts): LLM
この Turn 配下で子 LLM スパン を開始します。
パラメーター
| 名 | タイプ |
|---|---|
opts | LLMInit |
戻り値
LLM
定義元
startSubagent
opts): SubAgent
この Turn の配下に、子 SubAgent のスパンを開始します。
パラメーター
| 名 | タイプ |
|---|---|
opts | SubAgentInit |
戻り値
SubAgent
定義元
startTool
opts): Tool
この Turn 配下で子 Tool の スパン を開始します。
パラメーター
| 名 | タイプ |
|---|---|
opts | ToolInit |
戻り値
Tool
定義元
create
opts?): Turn
パラメーター
| 名 | タイプ |
|---|---|
opts | TurnInit & { conversationId?: string } |
戻り値
Turn