> ## 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.

# Agent: Tool Result Scanning

> POST /railscore/v1/agent/tool-result - Agent को pass करने से पहले tool output को PII और injection के लिए scan करें।

<Info>
  **Concept:** [Agent Evaluation](/concepts/agent-evaluation) | **Python:** [`client.agent.scan_tool_result()`](/sdk/python/agent-evaluation)
</Info>

## Parameters

<ParamField body="tool_name" type="string" required>
  Tool का नाम जिसने यह result produce किया।
</ParamField>

<ParamField body="tool_result" type="object" required>
  Tool का output, एक object के रूप में। Text को `raw` (string) के under दें और/या structured output को `data` (any) के under दें। Optional `format` (string, default `"text"`)। `raw`/`data` में से कम से कम एक present होना चाहिए।
</ParamField>

<ParamField body="tool_params" type="object">
  Tool को जो parameters के साथ call किया गया था, अगर available हों।
</ParamField>

<ParamField body="agent_context" type="object">
  Agent की role और current task। Object में optional fields हैं: `goal` (string), `prior_tool_calls` (array), `agent_id` (string), `turn_index` (integer)।
</ParamField>

<ParamField body="checks" type="string[]">
  कौन से checks run करने हैं। `"pii"`, `"prompt_injection"`, `"rail_score"` में से कोई भी। Defaults to सभी तीनों। Credit cost checks की संख्या के साथ scale होती है (3 = 1.0, 2 = 0.75, 1 = 0.5)।
</ParamField>

## Request

```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"]
  }'
```

## Response

```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">
  Overall risk: `"low"`, `"medium"`, `"high"`, या `"critical"`।
</ResponseField>

<ResponseField name="recommended_action" type="string">
  Suggested action: `"PASS"`, `"FLAG"`, `"REDACT_AND_PASS"`, `"REDACT_AND_FLAG"`, या `"DISCARD_AND_ALERT"`।
</ResponseField>

<ResponseField name="pii_detected" type="object">
  Present जब `pii` check run होता है। Contains `found` (boolean), `entities` (array of `{type, value, offset, should_redact}`), `redacted_result` (string with PII replaced by `[TYPE]` placeholders), और `compliance_flags` (string\[])।
</ResponseField>

<ResponseField name="dpdp_flags" type="object">
  Present जब Indian PII (e.g. Aadhaar, PAN) detect होता है। DPDP exposure को indicate करता है और recommended Rule 6 safeguards को। Detected Indian identifiers भी `pii_detected.redacted_result` में mask हो जाते हैं।
</ResponseField>

<ResponseField name="prompt_injection" type="object">
  Present जब `prompt_injection` check run होता है। Contains `detected` (boolean) और `confidence` (0-1)।
</ResponseField>
