

本文為英文版的機器翻譯版本，如內容有任何歧義或不一致之處，概以英文版為準。

# 檢視追蹤
<a name="trace-view"></a>

以下說明如何檢視追蹤。選擇您偏好方法的索引標籤，然後遵循下列步驟：

------
#### [ Console ]

**在與代理程式對話期間檢視追蹤**

使用具有 Amazon Bedrock 主控台使用許可的 IAM 身分登入AWS 管理主控台。接著，開啟位於 [https://console.aws.amazon.com/bedrock](https://console.aws.amazon.com/bedrock) 的 Amazon Bedrock 主控台。

1. 在**代理程式**區段中，從代理程式清單中選擇所要測試代理程式的連結。

1. **測試**視窗會出現在右側的窗格中。

1. 輸入訊息，然後選擇**執行**。在回應產生時或完成產生後，選取**顯示追蹤**。

1. 您可以在代理程式執行協同運作時，即時檢視每個**步驟**的追蹤。

------
#### [ API ]

若要檢視追蹤，請使用 [Amazon Bedrock 代理程式執行時期端點](https://docs.aws.amazon.com/general/latest/gr/bedrock.html#bra-rt)傳送 [https://docs.aws.amazon.com/bedrock/latest/APIReference/API_agent-runtime_InvokeAgent.html](https://docs.aws.amazon.com/bedrock/latest/APIReference/API_agent-runtime_InvokeAgent.html) 請求，並將 `enableTrace` 欄位設定為 `TRUE`。根據預設，追蹤已停用。如需範例程式碼，請參閱 [從您的應用程式調用代理程式](agents-invoke-agent.md)。

如果您啟用追蹤，在 [https://docs.aws.amazon.com/bedrock/latest/APIReference/API_agent-runtime_InvokeAgent.html](https://docs.aws.amazon.com/bedrock/latest/APIReference/API_agent-runtime_InvokeAgent.html) 回應中，串流中的每個 `chunk` 都會伴隨一個映射到 [https://docs.aws.amazon.com/bedrock/latest/APIReference/API_agent-runtime_TracePart.html](https://docs.aws.amazon.com/bedrock/latest/APIReference/API_agent-runtime_TracePart.html) 物件的 `trace` 欄位。在 [https://docs.aws.amazon.com/bedrock/latest/APIReference/API_agent-runtime_TracePart.html](https://docs.aws.amazon.com/bedrock/latest/APIReference/API_agent-runtime_TracePart.html) 內是映射到 [https://docs.aws.amazon.com/bedrock/latest/APIReference/API_agent-runtime_Trace.html](https://docs.aws.amazon.com/bedrock/latest/APIReference/API_agent-runtime_Trace.html) 物件的 `trace` 欄位。

------