Loading...
    • 建構
    • 管理
    • 模型與定價
    • 客戶端 SDK
    • API 參考
    Search...
    ⌘K
    管理
    Admin API 概覽工作區資料駐留API 與資料保留
    監控
    Claude Code 分析 API使用量與費用 API
    第三方平台
    Amazon BedrockMicrosoft FoundryVertex AI
    Console
    Log in
    Loading...
    Loading...
    Loading...
    Loading...
    Loading...
    Loading...
    Loading...
    Loading...
    Loading...
    Loading...
    Loading...
    Loading...
    Loading...
    Loading...
    Loading...
    Loading...

    Solutions

    • AI agents
    • Code modernization
    • Coding
    • Customer support
    • Education
    • Financial services
    • Government
    • Life sciences

    Partners

    • Amazon Bedrock
    • Google Cloud's Vertex AI

    Learn

    • Blog
    • Catalog
    • Courses
    • Use cases
    • Connectors
    • Customer stories
    • Engineering at Anthropic
    • Events
    • Powered by Claude
    • Service partners
    • Startups program

    Company

    • Anthropic
    • Careers
    • Economic Futures
    • Research
    • News
    • Responsible Scaling Policy
    • Security and compliance
    • Transparency

    Learn

    • Blog
    • Catalog
    • Courses
    • Use cases
    • Connectors
    • Customer stories
    • Engineering at Anthropic
    • Events
    • Powered by Claude
    • Service partners
    • Startups program

    Help and security

    • Availability
    • Status
    • Support
    • Discord

    Terms and policies

    • Privacy policy
    • Responsible disclosure policy
    • Terms of service: Commercial
    • Terms of service: Consumer
    • Usage policy
    監控

    會話追蹤

    使用 Console 時間軸和原始事件檢視來監控和除錯您的會話。

    Was this page helpful?

    • Console 可觀測性

    Claude Managed Agents 在 Claude Console 中提供可觀測性工具,幫助您監控、除錯和理解您的代理會話。

    Console 可觀測性

    Console 提供您代理會話的視覺時間軸檢視。在 Console 中導航至 Claude Managed Agents 部分以查看:

    • 會話清單 - 所有會話及其狀態、建立時間和模型
    • 追蹤檢視 - 會話內事件的時間順序檢視(內容、時間戳記、令牌使用量)。這些僅供開發人員和管理員存取。
    • 工具執行 - 每個工具呼叫及其結果的詳細資訊

    原始事件

    若要進行程式化除錯,請透過 API 擷取原始事件:

    curl -fsSL "https://api.anthropic.com/v1/sessions/$SESSION_ID/events" \
      -H "x-api-key: $ANTHROPIC_API_KEY" \
      -H "anthropic-version: 2023-06-01" \
      -H "anthropic-beta: managed-agents-2026-04-01" \
    | jq -r '
      .data[]
      | "Type: \(.type)",
        "Processed: \(.processed_at)",
        ( if .type | IN("user.message", "agent.message") then
            .content[]
            | "  Block: \(.type)",
              (select(.type == "text") | "  Text: \(.text[:100])...")
          elif .type | IN("agent.tool_use", "agent.custom_tool_use", "agent.mcp_tool_use") then
            "  Tool: \(.name)"
          else empty end ),
        "---"
    '

    使用相同的事件串流來顯示錯誤並追蹤令牌消耗:

    除錯提示

    • 檢查會話事件 - 會話錯誤透過 session.error 事件傳達
    • 檢視工具結果 - 工具執行失敗通常會解釋意外的代理行為
    • 追蹤令牌使用量 - 監控令牌消耗以最佳化提示並降低成本
    • 使用系統提示 - 將記錄指令新增至系統提示,讓代理解釋其推理
    curl -fsSL "https://api.anthropic.com/v1/sessions/$SESSION_ID/events" \
      -H "x-api-key: $ANTHROPIC_API_KEY" \
      -H "anthropic-version: 2023-06-01" \
      -H "anthropic-beta: managed-agents-2026-04-01" \
    | jq -r '
      (.data[] | select(.type == "session.error") | "[\(.error.type)] \(.error.message)"),
      (reduce (.data[] | select(.type == "span.model_request_end") | .model_usage) as $u
         ({input: 0, output: 0}; .input += $u.input_tokens | .output += $u.output_tokens)
       | "Total input tokens: \(.input), output tokens: \(.output)")
    '