> ## Documentation Index
> Fetch the complete documentation index at: https://docs.responsibleailabs.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# エージェント: ツール結果スキャン

> POST /railscore/v1/agent/tool-result - エージェントに渡す前にツール出力でPIIとインジェクションをスキャンします。

<Info>
  **概念:** [エージェント評価](/concepts/agent-evaluation) | **Python:** [`client.agent.scan_tool_result()`](/sdk/python/agent-evaluation)
</Info>

## パラメータ

<ParamField body="tool_name" type="string" required>
  この結果を生成したツールの名前。
</ParamField>

<ParamField body="tool_result" type="object" required>
  ツールの出力。`raw` (文字列) と `data` (任意) の下に構造化出力を提供します。オプションの `format` (文字列、デフォルト `"text"`)。`raw`/`data` のうち少なくとも1つが存在する必要があります。
</ParamField>

<ParamField body="tool_params" type="object">
  利用可能な場合、ツールが呼び出されたときのパラメータ。
</ParamField>

<ParamField body="agent_context" type="object">
  エージェントの役割と現在のタスク。オプションのフィールド: `goal` (string)、`prior_tool_calls` (配列)、`agent_id` (string)、`turn_index` (integer)。
</ParamField>

<ParamField body="checks" type="string[]">
  実行するチェック。`"pii"`、`"prompt_injection"`、`"rail_score"` のいずれか。デフォルトはすべて3つ。クレジットコストはチェック数でスケール (3 = 1.0、2 = 0.75、1 = 0.5)。
</ParamField>

## リクエスト

```bash theme={null}
curl -X POST https://api.responsibleailabs.ai/railscore/v1/agent/tool-result \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_RAIL_API_KEY" \
  -d '{
    "tool_name": "search_database",
    "tool_result": {"raw": "Customer John Smith (SSN: 123-45-6789) called on 2026-03-15."},
    "checks": ["pii", "prompt_injection"]
  }'
```

## レスポンス

```json theme={null}
{
  "event_id": "evt_1a2b3c4d",
  "risk_level": "medium",
  "recommended_action": "REDACT_AND_PASS",
  "pii_detected": {
    "found": true,
    "entities": [
      {"type": "full_name", "value": "John Smith", "offset": 9, "should_redact": true},
      {"type": "ssn", "value": "123-45-6789", "offset": 26, "should_redact": true}
    ],
    "redacted_result": "Customer [FULL_NAME] (SSN: [SSN]) called on 2026-03-15.",
    "compliance_flags": ["gdpr_personal_data", "hipaa_phi"]
  },
  "redacted_available": true,
  "prompt_injection": {"detected": false, "confidence": 0.02},
  "context_signals": {"pii_fields_detected": ["full_name", "ssn"]},
  "credits_consumed": 0.75,
  "evaluated_at": "2026-06-25T10:00:00Z"
}
```

<ResponseField name="risk_level" type="string">
  全体的なリスク: `"low"`、`"medium"`、`"high"`、または `"critical"`。
</ResponseField>

<ResponseField name="recommended_action" type="string">
  推奨されるアクション: `"PASS"`、`"FLAG"`、`"REDACT_AND_PASS"`、`"REDACT_AND_FLAG"`、または `"DISCARD_AND_ALERT"`。
</ResponseField>

<ResponseField name="pii_detected" type="object">
  `pii` チェックが実行される場合に存在します。`found` (ブール値)、`entities` (オブジェクトの配列 `{type, value, offset, should_redact}`)、`redacted_result` (PII が `[TYPE]` プレースホルダーに置き換えられた文字列)、および `compliance_flags` (文字列の配列) が含まれます。
</ResponseField>

<ResponseField name="dpdp_flags" type="object">
  インドのPII (例: Aadhaar、PAN) が検出された場合に存在します。DPDP 露出と推奨される Rule 6 セーフガードを示します。検出されたインドの識別子は `pii_detected.redacted_result` にもマスクされます。
</ResponseField>

<ResponseField name="prompt_injection" type="object">
  `prompt_injection` チェックが実行される場合に存在します。`detected` (ブール値) と `confidence` (0-1) が含まれます。
</ResponseField>
