翻訳は機械翻訳により提供されています。提供された翻訳内容と英語版の間で齟齬、不一致または矛盾がある場合、英語版が優先します。
OpenAI エージェント
このページでは、OpenAI エージェントを計測する方法、スパンの特定方法、評価フィールドの抽出方法について説明します。AgentCore Evaluations は、Python と TypeScript に組み込まれた OpenAI エージェントをサポートしています。このページでは、Python エージェントサポートと TypeScript エージェントサポートの各言語を個別に説明します。
トピック
Python エージェントのサポート
Python OpenAI エージェントは、スコープ名 opentelemetry.instrumentation.openai_agents (OpenTelemetry) または openinference.instrumentation.openai_agents (OpenInference) でスパンを出力します。
エージェントを計測する
OpenAI エージェントは、OpenTelemetry (opentelemetry-instrumentation-openai-agents) または OpenInference () の 2 つの計測ライブラリのいずれかを使用して計測できますopeninference-instrumentation-openai-agents。Amazon Bedrock AgentCore Evaluations は両方のライブラリをサポートしています。ライブラリは異なるスコープ名を出力し、異なるスパン属性を使用します。評価サービスは、それぞれから同じ値を抽出します。
Amazon Bedrock AgentCore ランタイムなど、エージェントが AWS Distro for OpenTelemetry (ADOT) で実行されている場合、明示的な計測コードを追加する必要はありません。計測ライブラリをプロジェクトの依存関係に追加するだけで十分です。ADOT は起動時に検出し、自動的にアクティブ化します。
依存関係に必要なパスの計測ライブラリを追加します。ピン留めする理由がない限り、利用可能な最新バージョンを使用してください。
例
- OpenTelemetry
-
注: バージョン 0.61.0 以降を使用します。これは、評価サービスでテストされた最も古いバージョンです。
opentelemetry-instrumentation-openai-agents を依存関係に追加します。出力されるスコープ名は ですopentelemetry.instrumentation.openai_agents。
requirements.txt:
opentelemetry-instrumentation-openai-agents>=0.61.0
pyproject.toml:
[project]
dependencies = [
"opentelemetry-instrumentation-openai-agents>=0.61.0",
]
- OpenInference
-
注: バージョン 1.5.0 以降を使用します。これは、評価サービスでテストされた最も古いバージョンです。
openinference-instrumentation-openai-agents を依存関係に追加します。出力されるスコープ名は ですopeninference.instrumentation.openai_agents。
requirements.txt:
openinference-instrumentation-openai-agents>=1.5.0
pyproject.toml:
[project]
dependencies = [
"openinference-instrumentation-openai-agents>=1.5.0",
]
計測は、オブザーバビリティを設定する 1 つのステップです。評価のためにテレメトリをエクスポートするには、「オブザーバビリティの設定」で完全なセットアップを完了します。
スパンの識別方法
スパンの分類に使用される属性は、2 つの計測ライブラリ間で異なります。
例
- OpenTelemetry
-
OpenTelemetry 計測ライブラリは、 gen_ai.operation.name 属性を使用してスパンを分類します。
| スパンタイプ |
属性の識別 |
|
エージェントを呼び出す
|
gen_ai.operation.name = invoke_agent
|
|
実行ツール
|
gen_ai.operation.name = execute_tool
|
|
推測
|
gen_ai.operation.name = chat
|
OpenAI エージェントは、 gen_ai.operation.name = の内部ターン境界スパンも出力しますunknown。評価サービスはこれらをスキップします。
- OpenInference
-
OpenInference 計測ライブラリは、 openinference.span.kind 属性を使用してスパンを分類します。
| スパンタイプ |
属性の識別 |
|
エージェントを呼び出す
|
openinference.span.kind = AGENTまたは CHAIN
|
|
実行ツール
|
openinference.span.kind = TOOL
|
|
推測
|
openinference.span.kind = LLM
|
OpenInference ライブラリでは、 AGENT と CHAINスパンは空の構造コンテナであり、会話コンテンツを持ちません。ユーザープロンプトとエージェントのレスポンスは、同じトレース内の推論 (LLM) スパンから再構築されます。
OpenAI エージェントは、メッセージをパートベースの形式でシリアル化します。各メッセージには、型付きコンテンツブロックのparts配列 (例: ) が格納されます[{"role": "user", "parts": [{"type": "text", "content": "…"}]}]。OpenTelemetry ライブラリを使用すると、AgentCore Evaluations はこれらの部分からテキストを解析します。OpenInference ライブラリでは、モデル出力は完全な OpenAI Response オブジェクトであり、AgentCore Evaluations は からレスポンステキストを読み取りますoutput[].content[].text。
このコンテンツの場所は、テレメトリの収集方法によって異なります。どちらの場合も、識別属性 (gen_ai.operation.name または openinference.span.kind) はスパン上にあります。詳細については、「テレメトリのセットアップと配信」を参照してください。
分割テレメトリを使用すると、AgentCore Evaluations は各スパンに相関するイベントレコードから会話コンテンツを読み取ります。ツールの入力と出力の場所は、2 つのライブラリによって異なります。
-
OpenTelemetry:
-
ユーザープロンプトとエージェントのレスポンス: エージェントスパンのイベントレコードの呼び出しから、 body.inputおよび 。 body.output
-
ツール呼び出し: のツール名gen_ai.tool.name、およびgen_ai.tool.call.result実行ツールスパンの引数gen_ai.tool.call.argumentsと結果。OpenTelemetry ライブラリでは、ツールの引数と結果は、分割テレメトリでもスパン属性に残ります。
-
OpenInference:
-
ユーザープロンプトとエージェントのレスポンス: 推論スパンのイベントレコードから再構築されました。AgentCore Evaluations は body.inputと からメッセージを読み取りbody.output、空の呼び出しエージェントスパンをユーザープロンプトとエージェントレスポンスでバックフィルします。
-
ツール呼び出し: 実行ツールスパンtool.nameの からのツール名。ツールの引数と結果は、 body.inputと のスパンのイベントレコードから取得されますbody.output。
詳細については、「分割テレメトリのスパンの例」を参照してください。
統合テレメトリでは、同じコンテンツが属性と同じスパンに残ります。属性は、計測ライブラリによって異なります。
-
OpenTelemetry:
-
OpenInference:
詳細については、「統合テレメトリでのスパンの例」を参照してください。
分割テレメトリのスパンの例
分割テレメトリでは、スパンは識別属性を保持し、コンテンツは相関イベントレコードに存在します。次の例は、Amazon Bedrock AgentCore ランタイムにデプロイされた Python OpenAI Agents の旅行計画エージェントからのものです。 AgentCore 各計測ライブラリの下に同じエージェントが表示されます。
これらの例は完全なスパンではありません。実際のエージェントインタラクションからの代表的なデータが表示され、読みやすいように一部のフィールドは省略され、長い値は切り捨てられます。
OpenTelemetry
例
- Invoke agent span
-
gen_ai.operation.name 属性 (invoke_agent) は、これを呼び出しエージェントのスパンとして識別します。
{
"traceId": "6a01eef11066751d68f90def0da1f80a",
"spanId": "3a300b0b3fe650e4",
"name": "invoke_agent openaiOtelTravel",
"kind": "INTERNAL",
"scope": {
"name": "opentelemetry.instrumentation.openai_agents",
"version": "0.62.1"
},
"attributes": {
"gen_ai.operation.name": "invoke_agent",
"gen_ai.agent.name": "openaiOtelTravel",
"gen_ai.system": "openai",
"gen_ai.provider.name": "openai",
"gen_ai.request.model": "gpt-4o-mini-2024-07-18",
"session.id": "sea-nyc-trip-2-turns-openai-otel"
},
"status": {
"code": "OK"
}
}
相関イベントレコードは会話を保持します。各メッセージの contentは OpenAI parts-format 配列です。ユーザープロンプトはユーザーメッセージのテキスト、エージェントのレスポンスはアシスタントメッセージのテキストです。
{
"spanId": "3a300b0b3fe650e4",
"traceId": "6a01eef11066751d68f90def0da1f80a",
"scope": {
"name": "opentelemetry.instrumentation.openai_agents"
},
"body": {
"input": {
"messages": [
{
"role": "user",
"content": "[{\"role\": \"user\", \"parts\": [{\"type\": \"text\", \"content\": \"Hey, how can you help me\"}]}]"
}
]
},
"output": {
"messages": [
{
"role": "assistant",
"content": "[{\"role\": \"assistant\", \"parts\": [{\"type\": \"text\", \"content\": \"I can assist you with planning your trips ...\"}]}]"
}
]
}
}
}
- Execute tool span
-
gen_ai.operation.name 属性 (execute_tool) は、これを実行ツールスパンとして識別します。 はツール名gen_ai.tool.nameを保持します。OpenTelemetry ライブラリでは、ツール引数と結果は分割テレメトリでもスパン属性に残ります。
{
"traceId": "6a01eefa5c52f3d86a35038f35f5ba30",
"spanId": "3cbc4ea5f73fef81",
"name": "execute_tool search_flights",
"kind": "INTERNAL",
"scope": {
"name": "opentelemetry.instrumentation.openai_agents",
"version": "0.62.1"
},
"attributes": {
"gen_ai.operation.name": "execute_tool",
"gen_ai.tool.name": "search_flights",
"gen_ai.tool.type": "function",
"gen_ai.tool.call.arguments": "{\"origin\": \"SEA\", \"destination\": \"NYC\", \"date\": \"2025-03-15\"}",
"gen_ai.tool.call.result": "{\"origin\": \"SEA\", \"destination\": \"NYC\", \"flights\": [ ... ]}",
"session.id": "sea-nyc-trip-2-turns-openai-otel"
},
"status": {
"code": "OK"
}
}
- Inference span
-
gen_ai.operation.name 属性 (chat) は、これを推論スパンとして識別します。このスパンには、モデルメタデータと、 でエージェントが使用できるツールgen_ai.tool.definitionsのリストが含まれます。モデル呼び出しの会話メッセージは、 body.inputと の相関イベントレコードにライブ表示されますbody.output。
{
"traceId": "6a01eef11066751d68f90def0da1f80a",
"spanId": "7c1f9a2b4d6e8a03",
"name": "openai.response",
"kind": "INTERNAL",
"scope": {
"name": "opentelemetry.instrumentation.openai_agents",
"version": "0.62.1"
},
"attributes": {
"gen_ai.operation.name": "chat",
"gen_ai.provider.name": "openai",
"gen_ai.request.model": "gpt-4o-mini-2024-07-18",
"gen_ai.response.model": "gpt-4o-mini-2024-07-18",
"gen_ai.usage.input_tokens": 269,
"gen_ai.usage.output_tokens": 78,
"gen_ai.tool.definitions": "[{\"type\": \"function\", \"function\": {\"name\": \"search_flights\", \"description\": \"Search for available flights between cities.\", \"parameters\": { ... }}}]",
"session.id": "sea-nyc-trip-2-turns-openai-otel"
},
"status": {
"code": "OK"
}
}
{
"spanId": "7c1f9a2b4d6e8a03",
"traceId": "6a01eef11066751d68f90def0da1f80a",
"scope": {
"name": "opentelemetry.instrumentation.openai_agents"
},
"body": {
"input": {
"messages": [
{
"role": "user",
"content": "[{\"role\": \"user\", \"parts\": [{\"type\": \"text\", \"content\": \"Hey, how can you help me\"}]}]"
}
]
},
"output": {
"messages": [
{
"role": "assistant",
"content": "[{\"role\": \"assistant\", \"parts\": [{\"type\": \"text\", \"content\": \"I can assist you with planning your trips ...\"}]}]"
}
]
}
}
}
OpenInference
OpenInference ライブラリでは、呼び出しエージェント (AGENT) スパンは空のコンテナです。AgentCore Evaluations は、コンテンツが相関イベントレコードに存在する推論 (LLM) スパンからユーザープロンプトとエージェントレスポンスを再構築します。
例
- Invoke agent span
-
openinference.span.kind 属性 (AGENT) は、これを呼び出しエージェントのスパンとして識別します。スパンには会話コンテンツはありません。
{
"traceId": "6a387ee61078243c1cc455ed45c6c313",
"spanId": "9a1c7dce81b692cd",
"name": "openaiOInfTravel",
"kind": "INTERNAL",
"scope": {
"name": "openinference.instrumentation.openai_agents",
"version": "1.5.0"
},
"attributes": {
"openinference.span.kind": "AGENT",
"graph.node.id": "openaiOInfTravel",
"llm.system": "openai",
"session.id": "sea-nyc-trip-2-turns-openai-oi"
},
"status": {
"code": "OK"
}
}
- Execute tool span
-
openinference.span.kind 属性 (TOOL) は、これを実行ツールスパンとして識別します。 はツール名tool.nameを保持します。ツールの引数と結果は、相関イベントレコードに残ります。
{
"traceId": "6a387ef07b8f4f3732fab45d3c0b51ff",
"spanId": "b4e78cb0a06a6fe2",
"name": "search_flights",
"kind": "INTERNAL",
"scope": {
"name": "openinference.instrumentation.openai_agents",
"version": "1.5.0"
},
"attributes": {
"openinference.span.kind": "TOOL",
"tool.name": "search_flights",
"input.mime_type": "application/json",
"output.mime_type": "application/json",
"session.id": "sea-nyc-trip-2-turns-openai-oi"
},
"status": {
"code": "OK"
}
}
{
"spanId": "b4e78cb0a06a6fe2",
"traceId": "6a387ef07b8f4f3732fab45d3c0b51ff",
"scope": {
"name": "openinference.instrumentation.openai_agents"
},
"body": {
"input": {
"messages": [
{ "role": "user", "content": "{\"origin\": \"SEA\", \"destination\": \"NYC\", \"date\": \"2025-03-15\"}" }
]
},
"output": {
"messages": [
{ "role": "assistant", "content": "{\"origin\": \"SEA\", \"destination\": \"NYC\", \"flights\": [ ... ]}" }
]
}
}
}
- Inference span
-
openinference.span.kind 属性 (LLM) は、これを推論スパンとして識別します。メッセージロールとツール定義はスパン属性にあり、メッセージコンテンツは相関イベントレコードに存在します。ADOT は入力ロールを にフラット化するためuser、AgentCore Evaluations はユーザープロンプトとして最後のプレーンテキストの入力メッセージを使用します。出力メッセージは OpenAI Response オブジェクトで、そこから AgentCore Evaluations がレスポンステキストを読み取ります。
{
"traceId": "6a387ee61078243c1cc455ed45c6c313",
"spanId": "1221a062c7f90a8e",
"name": "response",
"kind": "INTERNAL",
"scope": {
"name": "openinference.instrumentation.openai_agents",
"version": "1.5.0"
},
"attributes": {
"openinference.span.kind": "LLM",
"llm.model_name": "gpt-4o-mini-2024-07-18",
"llm.input_messages.0.message.role": "system",
"llm.input_messages.1.message.role": "user",
"llm.output_messages.0.message.role": "assistant",
"llm.tools.0.tool.json_schema": "{\"type\": \"function\", \"function\": {\"name\": \"search_flights\", ...}}",
"session.id": "sea-nyc-trip-2-turns-openai-oi"
},
"status": {
"code": "OK"
}
}
{
"spanId": "1221a062c7f90a8e",
"traceId": "6a387ee61078243c1cc455ed45c6c313",
"scope": {
"name": "openinference.instrumentation.openai_agents"
},
"body": {
"input": {
"messages": [
{ "role": "user", "content": "[{\"content\": \"Hey, how can you help me\", \"role\": \"user\"}]" },
{ "role": "user", "content": "You are a travel planning assistant. Help users plan trips ..." },
{ "role": "user", "content": "Hey, how can you help me" }
]
},
"output": {
"messages": [
{
"role": "assistant",
"content": "{\"id\": \"resp_abc123...\", \"output\": [{\"type\": \"message\", \"content\": [{\"type\": \"output_text\", \"text\": \"I can assist you with planning your trips ...\"}]}]}"
}
]
}
}
}
統合テレメトリのスパンの例
統合テレメトリでは、同じコンテンツがスパン属性に残り、個別のイベントレコードは生成されません。次の例は、Python OpenAI Agents の旅行計画エージェントからのものです。各計測ライブラリの下に同じエージェントが表示されます。
これらの例は完全なスパンではありません。実際のエージェントインタラクションからの代表的なデータが表示され、読みやすいように一部のフィールドは省略され、長い値は切り捨てられます。
OpenTelemetry
例
- Invoke agent span
-
gen_ai.input.messages 属性はユーザープロンプトを保持し、 gen_ai.output.messages 属性はエージェントのレスポンスを保持します。どちらも OpenAI parts-format 配列です。
{
"traceId": "6a4de7b85e61747e6b568a1f4768e89d",
"spanId": "50656fd77904d125",
"name": "invoke_agent openaiOtelTravel",
"kind": "INTERNAL",
"scope": {
"name": "opentelemetry.instrumentation.openai_agents",
"version": "0.62.1"
},
"attributes": {
"gen_ai.operation.name": "invoke_agent",
"gen_ai.agent.name": "openaiOtelTravel",
"gen_ai.system": "openai",
"gen_ai.input.messages": "[{\"role\": \"user\", \"parts\": [{\"type\": \"text\", \"content\": \"Hey, how can you help me\"}]}]",
"gen_ai.output.messages": "[{\"role\": \"assistant\", \"parts\": [{\"type\": \"text\", \"content\": \"I can assist you with planning your trips ...\"}]}]",
"session.id": "sea-nyc-trip-2-turns-unified"
},
"status": {
"code": "OK"
}
}
- Execute tool span
-
gen_ai.tool.call.arguments 属性はツール引数を保持し、 gen_ai.tool.call.result 属性はツールの結果を保持します。
{
"traceId": "6a4de7c376913db82e6f0f336a16731d",
"spanId": "8840e8e23724ebd7",
"name": "execute_tool search_flights",
"kind": "INTERNAL",
"scope": {
"name": "opentelemetry.instrumentation.openai_agents",
"version": "0.62.1"
},
"attributes": {
"gen_ai.operation.name": "execute_tool",
"gen_ai.tool.name": "search_flights",
"gen_ai.tool.call.arguments": "{\"origin\": \"SEA\", \"destination\": \"NYC\", \"date\": \"2025-03-15\"}",
"gen_ai.tool.call.result": "{\"origin\": \"SEA\", \"destination\": \"NYC\", \"flights\": [ ... ]}",
"session.id": "sea-nyc-trip-2-turns-unified"
},
"status": {
"code": "OK"
}
}
- Inference span
-
gen_ai.operation.name 属性 (chat) は、これを推論スパンとして識別します。モデルメタデータと gen_ai.tool.definitions 属性 (エージェントが使用できるツールのリスト) は、スパンでインラインに保持されます。
{
"traceId": "6a4de7b85e61747e6b568a1f4768e89d",
"spanId": "9b2c1e5f7a3d0846",
"name": "openai.response",
"kind": "INTERNAL",
"scope": {
"name": "opentelemetry.instrumentation.openai_agents",
"version": "0.62.1"
},
"attributes": {
"gen_ai.operation.name": "chat",
"gen_ai.provider.name": "openai",
"gen_ai.request.model": "gpt-4o-mini-2024-07-18",
"gen_ai.response.model": "gpt-4o-mini-2024-07-18",
"gen_ai.usage.input_tokens": 269,
"gen_ai.usage.output_tokens": 78,
"gen_ai.tool.definitions": "[{\"type\": \"function\", \"function\": {\"name\": \"search_flights\", \"description\": \"Search for available flights between cities.\", \"parameters\": { ... }}}]",
"session.id": "sea-nyc-trip-2-turns-unified"
},
"status": {
"code": "OK"
}
}
OpenInference
例
- Execute tool span
-
input.value 属性はツール引数を保持し、 output.value 属性はツールの結果を保持します。
{
"traceId": "6a387ef07b8f4f3732fab45d3c0b51ff",
"spanId": "d5a1c9e70b46f312",
"name": "search_flights",
"kind": "INTERNAL",
"scope": {
"name": "openinference.instrumentation.openai_agents",
"version": "1.5.1"
},
"attributes": {
"openinference.span.kind": "TOOL",
"tool.name": "search_flights",
"input.value": "{\"origin\": \"SEA\", \"destination\": \"NYC\", \"date\": \"2025-03-15\"}",
"output.value": "{\"origin\": \"SEA\", \"destination\": \"NYC\", \"flights\": [ ... ]}",
"session.id": "sea-nyc-trip-2-turns-oi"
},
"status": {
"code": "OK"
}
}
- Inference span
-
メッセージの内容は、インデックス付き属性でインラインです。llm.input_messages.* 属性はシステムプロンプトとユーザープロンプトを保持し、llm.output_messages.*属性はエージェントのレスポンスを保持します。AgentCore Evaluations は、このスパンからユーザープロンプトとエージェントレスポンスを再構築し、空の呼び出しエージェント (AGENT) スパンをバックフィルします。
{
"traceId": "6a387ee61078243c1cc455ed45c6c313",
"spanId": "c9f0a2b41d773e88",
"name": "response",
"kind": "INTERNAL",
"scope": {
"name": "openinference.instrumentation.openai_agents",
"version": "1.5.1"
},
"attributes": {
"openinference.span.kind": "LLM",
"llm.model_name": "gpt-4o-mini-2024-07-18",
"llm.input_messages.0.message.role": "system",
"llm.input_messages.0.message.content": "You are a travel planning assistant ...",
"llm.input_messages.1.message.role": "user",
"llm.input_messages.1.message.content": "Hey, how can you help me",
"llm.output_messages.0.message.role": "assistant",
"llm.output_messages.0.message.contents.0.message_content.text": "I can assist you with planning your trips ...",
"session.id": "sea-nyc-trip-2-turns-oi"
},
"status": {
"code": "OK"
}
}
TypeScript エージェントのサポート
TypeScript OpenAI Agents エージェントは、Python エージェントと同じスパンタイプ、識別属性、およびコンテンツレイアウトを出力するため、評価サービスはそれを同じ方法で読み取ります。TypeScript 計測ライブラリは 2 つあり、それぞれに独自のスコープ名があります。
エージェントを計測する
TypeScript の依存関係に必要な規則の計測ライブラリを追加します。ピン留めする理由がない限り、利用可能な最新バージョンを使用してください。
例
- ADOT (OpenTelemetry)
-
ADOT の TypeScript エージェントの場合、依存関係に AWS Distro Node 自動計測パッケージ (@aws/aws-distro-opentelemetry-node-autoinstrumentation) を追加します。これには、起動時にアクティブ化され、スコープ名 を出力する組み込み OpenAI エージェント計測が含まれています@aws/aws-distro-opentelemetry-instrumentation-openai-agents。
package.json:
{
"dependencies": {
"@aws/aws-distro-opentelemetry-node-autoinstrumentation": "^0.12.0"
}
}
- OpenInference
-
@arizeai/openinference-instrumentation-openai-agents を依存関係に追加します。出力されるスコープ名は です@arizeai/openinference-instrumentation-openai-agents。
package.json:
{
"dependencies": {
"@arizeai/openinference-instrumentation-openai-agents": "^0.2.2"
}
}
計測は、オブザーバビリティを設定する 1 つのステップです。評価のためにテレメトリをエクスポートするには、「オブザーバビリティの設定」で完全なセットアップを完了します。
スパンの識別方法
スパン識別は Python エージェントの場合と同じです。ADOT ネイティブ OpenTelemetry ライブラリ ( AWS Distro Node 自動計測パッケージ から@aws/aws-distro-opentelemetry-node-autoinstrumentation、スコープ名 を発行@aws/aws-distro-opentelemetry-instrumentation-openai-agents) は を設定しgen_ai.operation.name、OpenInference JS ライブラリ (@arizeai/openinference-instrumentation-openai-agents) は を設定しますopeninference.span.kind。値については、「Python エージェントサポートでスパンを識別する方法」を参照してください。
フィールド抽出は、Python エージェントと同じ属性を読み取ります。ADOT ネイティブ TypeScript ライブラリでは、呼び出しエージェントスパンは構造コンテナです。Python OpenTelemetry ライブラリとは異なり、ユーザープロンプトとエージェントレスポンスは呼び出しエージェントスパンではなく推論 (chat) スパンから再構築されます。各フィールドの読み取り元については、Python エージェントサポートで評価フィールドを抽出する方法を参照してください。
TypeScript エージェントからのスパンの例
次の例は、統合テレメトリを使用して Amazon Bedrock AgentCore ランタイムにデプロイされた TypeScript OpenAI Agents の旅行計画エージェントからのものです。 AgentCore 各計測ライブラリの下に同じエージェントが表示されます。
これらの例は完全なスパンではありません。実際のエージェントインタラクションからの代表的なデータが表示され、読みやすいように一部のフィールドは省略され、長い値は切り捨てられます。
OpenTelemetry
ADOT ネイティブライブラリ ( AWS Distro Node 自動計測パッケージ から、スコープ名 を出力@aws/aws-distro-opentelemetry-instrumentation-openai-agents) では@aws/aws-distro-opentelemetry-node-autoinstrumentation、呼び出しエージェントスパンは構造コンテナであり、会話コンテンツはパート形式とgen_ai.input.messagesgen_ai.output.messages属性の推論 (chat) スパンに存在します。AgentCore Evaluations は、推論スパンからユーザープロンプトとエージェントレスポンスを再構築します。
例
- Invoke agent span
-
gen_ai.operation.name 属性 (invoke_agent) は、これを呼び出しエージェントのスパンとして識別します。スパンはエージェント名とツールリストを保持しますが、会話コンテンツは保持しません。
{
"traceId": "6a6bc695459e41aa14a172bb41d3246d",
"spanId": "9a1c7dce81b692cd",
"name": "invoke_agent openaiAdotTS",
"kind": "INTERNAL",
"scope": {
"name": "@aws/aws-distro-opentelemetry-instrumentation-openai-agents",
"version": "0.12.0"
},
"attributes": {
"gen_ai.operation.name": "invoke_agent",
"gen_ai.agent.name": "openaiAdotTS",
"gen_ai.provider.name": "openai",
"open_ai.agent.tools": "[\"search_flights\", \"book_flight\", \"search_hotels\", \"book_hotel\", \"search_activities\", \"book_activity\"]",
"session.id": "sea-nyc-trip-2-turns"
},
"status": {
"code": "OK"
}
}
- Execute tool span
-
gen_ai.operation.name 属性 (execute_tool) は、これを実行ツールスパンとして識別します。 はツール名gen_ai.tool.nameを保持します。gen_ai.tool.call.arguments および gen_ai.tool.call.result 属性は、ツールの引数と結果を保持します。
{
"traceId": "6a6bc695459e41aa14a172bb41d3246d",
"spanId": "3cbc4ea5f73fef81",
"name": "execute_tool search_flights",
"kind": "INTERNAL",
"scope": {
"name": "@aws/aws-distro-opentelemetry-instrumentation-openai-agents",
"version": "0.12.0"
},
"attributes": {
"gen_ai.operation.name": "execute_tool",
"gen_ai.tool.name": "search_flights",
"gen_ai.tool.type": "function",
"gen_ai.tool.call.arguments": "{\"origin\": \"SEA\", \"destination\": \"NYC\", \"date\": \"2025-03-15\"}",
"gen_ai.tool.call.result": "{\"origin\": \"SEA\", \"destination\": \"NYC\", \"flights\": [ ... ]}",
"session.id": "sea-nyc-trip-2-turns"
},
"status": {
"code": "OK"
}
}
- Inference span
-
gen_ai.operation.name 属性 (chat) は、これを推論スパンとして識別します。属性gen_ai.input.messagesと gen_ai.output.messages 属性は、会話を parts 形式で保持し、システムプロンプトgen_ai.system_instructionsを保持し、エージェントが使用できるツールをgen_ai.tool.definitions一覧表示します。
{
"traceId": "6a6bc695459e41aa14a172bb41d3246d",
"spanId": "7c1f9a2b4d6e8a03",
"name": "chat gpt-4o-mini-2024-07-18",
"kind": "INTERNAL",
"scope": {
"name": "@aws/aws-distro-opentelemetry-instrumentation-openai-agents",
"version": "0.12.0"
},
"attributes": {
"gen_ai.operation.name": "chat",
"gen_ai.provider.name": "openai",
"gen_ai.response.model": "gpt-4o-mini-2024-07-18",
"gen_ai.input.messages": "[{\"role\": \"user\", \"parts\": [{\"type\": \"text\", \"content\": \"Hey, how can you help me\"}]}]",
"gen_ai.output.messages": "[{\"role\": \"assistant\", \"parts\": [{\"type\": \"text\", \"content\": \"I can assist you with planning your trips ...\"}]}]",
"gen_ai.system_instructions": "[{\"type\": \"text\", \"content\": \"You are a travel planning assistant ...\"}]",
"gen_ai.tool.definitions": "[{\"type\": \"function\", \"name\": \"search_flights\", \"description\": \"Search for available flights between cities.\", ...}]",
"gen_ai.usage.input_tokens": 422,
"gen_ai.usage.output_tokens": 82,
"session.id": "sea-nyc-trip-2-turns"
},
"status": {
"code": "OK"
}
}
OpenInference
OpenInference JS ライブラリでは、呼び出しエージェント (AGENT) とターン (CHAIN) スパンは空のコンテナです。AgentCore Evaluations は、推論 (LLM) スパンからユーザープロンプトとエージェントレスポンスを再構築します。そのメッセージはインデックス付きllm.input_messages.*属性と llm.output_messages.* 属性にあります。
例
- Invoke agent span
-
openinference.span.kind 属性 (AGENT) は、これを呼び出しエージェントのスパンとして識別します。スパンには会話コンテンツはありません。
{
"traceId": "6a6bc695459e41aa14a172bb41d3246d",
"spanId": "9a1c7dce81b692cd",
"name": "openaiAgentsOInf",
"kind": "INTERNAL",
"scope": {
"name": "@arizeai/openinference-instrumentation-openai-agents",
"version": "0.2.2"
},
"attributes": {
"openinference.span.kind": "AGENT",
"graph.node.id": "openaiAgentsOInf",
"llm.system": "openai",
"session.id": "sea-nyc-trip-2-turns"
},
"status": {
"code": "OK"
}
}
- Execute tool span
-
openinference.span.kind 属性 (TOOL) は、これを実行ツールスパンとして識別します。 はツール名tool.nameを保持します。input.value および output.value 属性は、ツールの引数と結果を保持します。
{
"traceId": "6a6bc695459e41aa14a172bb41d3246d",
"spanId": "b4e78cb0a06a6fe2",
"name": "search_flights",
"kind": "INTERNAL",
"scope": {
"name": "@arizeai/openinference-instrumentation-openai-agents",
"version": "0.2.2"
},
"attributes": {
"openinference.span.kind": "TOOL",
"tool.name": "search_flights",
"input.value": "{\"origin\": \"SEA\", \"destination\": \"NYC\", \"date\": \"2025-03-15\"}",
"output.value": "{\"origin\": \"SEA\", \"destination\": \"NYC\", \"flights\": [ ... ]}",
"session.id": "sea-nyc-trip-2-turns"
},
"status": {
"code": "OK"
}
}
- Inference span
-
openinference.span.kind 属性 (LLM) は、これを推論スパンとして識別します。llm.input_messages.* 属性はシステムプロンプトとユーザープロンプトを保持し、llm.output_messages.*属性はエージェントのレスポンスを保持し、llm.tools.*.tool.json_schema属性はツール定義を保持します。AgentCore Evaluations は、このスパンからユーザープロンプトとエージェントレスポンスを再構築し、空の呼び出しエージェント (AGENT) スパンをバックフィルします。
{
"traceId": "6a6bc695459e41aa14a172bb41d3246d",
"spanId": "1221a062c7f90a8e",
"name": "response",
"kind": "INTERNAL",
"scope": {
"name": "@arizeai/openinference-instrumentation-openai-agents",
"version": "0.2.2"
},
"attributes": {
"openinference.span.kind": "LLM",
"llm.model_name": "gpt-4o-mini-2024-07-18",
"llm.input_messages.0.message.role": "system",
"llm.input_messages.0.message.content": "You are a travel planning assistant ...",
"llm.input_messages.1.message.role": "user",
"llm.input_messages.1.message.content": "Hey, how can you help me",
"llm.output_messages.0.message.role": "assistant",
"llm.output_messages.0.message.contents.0.message_content.text": "I can assist you with travel planning by ...",
"llm.tools.0.tool.json_schema": "{\"type\": \"function\", \"function\": {\"name\": \"search_flights\", ...}}",
"session.id": "sea-nyc-trip-2-turns"
},
"status": {
"code": "OK"
}
}