メインコンテンツへスキップ
weave / SubAgent ネストされたエージェント呼び出しです。現在のエージェントが 別の名前付きエージェントに処理を引き継ぐ際に使用されます (例: planner が researcher を呼び出す場合) 。サブエージェントの名と (必要に応じて) そのモデルがタグ付けされた invoke_agent スパンを出力します。 weave.startSubagent() (または turn.startAgent()、あるいは llm.startAgent()) で作成し、end() で終了します。
const  = weave.startSubagent({: 'researcher', : 'gpt-4o'});
try {
  // ... サブエージェントの LLM/Tool Call を調整する ...
} finally {
  .end();
}

階層

  • SpanBase SubAgent

目次

プロパティ

メソッド

プロパティ

モデル

Readonly モデル: string

定義場所

src/genai/subagent.ts:41

Readonly name: string

定義場所

src/genai/subagent.ts:40

メソッド

addEvent

addEvent(name, attributes?, startTime?): this スパン に名前付きイベントを追加します。コンテキストの圧縮、tool ループの検出、 または guardrail の発動など、スパン 以外の時点を記録する際に便利です。end() の後に呼び出すと警告を出し、 何も行いません。OTel Span.addEvent と同様の動作です。

パラメーター

タイプ
namestring
attributes?Attributes
startTime?TimeInput

戻り値

this
span.addEvent('context_compacted', {: 12});

継承元

SpanBase.addEvent

定義場所

src/genai/spanBase.ts:77

end

end(opts?): void SubAgent の スパン を終了します。冪等です。失敗としてマークするには、error を渡します。 終了時刻を過去にさかのぼって設定するには、endTime を渡します。

パラメーター

タイプ
opts?SpanEndOptions

戻り値

void

定義場所

src/genai/subagent.ts:72

setAttributes

setAttributes(attributes): this スパンに複数の属性をまとめて設定します。end() の後に呼び出すと、警告を出して何も実行しません。OTel の Span.setAttributes (および Python SDK の set_attributes) に準拠しています。

パラメーター

タイプ
attributesAttributes

戻り値

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

継承元

SpanBase.setAttributes

定義場所

src/genai/spanBase.ts:63

create

create(opts): SubAgent

パラメーター

タイプ
optsSubAgentInit & ChildSpanContext

戻り値

SubAgent

定義場所

src/genai/subagent.ts:46