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

> AI agent pipelines में tool calls intercept करें, tool results scan करें, और prompt injection पकड़ें।

Agent Evaluation agentic AI systems के लिए तीन safety checkpoints देता है: tool calls को execute होने से पहले evaluate करें, tool results को agent के पास वापस जाने से पहले scan करें, और जिस भी text को agent process करने वाला है उसमें prompt injection पकड़ें।

यह उन systems के लिए है जहाँ कोई AI agent खुद tools (functions, APIs, retrieval) call कर सकता है। अगर आपकी application सिर्फ़ text generate करती है, तो आप इसे छोड़कर [Evaluation](/concepts/evaluation) use कर सकते हैं। अगर आप agents बनाते हैं, तो ये checkpoints उन जगहों की रक्षा करते हैं जहाँ कोई agent कोई action ले सकता है या उससे प्रभावित हो सकता है।

## तीन checkpoints

```mermaid theme={null}
flowchart LR
    User["User input"] -->|"prompt-injection"| Agent["AI Agent"]
    Agent -->|"tool-call"| Tool["Tool execution"]
    Tool -->|"tool-result"| Agent
    Agent --> Response["Final response"]
```

<CardGroup cols={3}>
  <Card title="Tool Call Evaluation" icon="wrench" href="/api-reference/agent-tool-call">
    tool चलने से पहले ALLOW / FLAG / BLOCK।
  </Card>

  <Card title="Tool Result Scanning" icon="shield" href="/api-reference/agent-tool-result">
    tool output पर PII detection और injection check।
  </Card>

  <Card title="Prompt Injection Detection" icon="shield-halved" href="/api-reference/agent-prompt-injection">
    किसी भी input text पर तेज़ injection scan।
  </Card>
</CardGroup>

इन्हें उसी क्रम में लगाएं जिस क्रम में agent चलता है: पहले **आने वाले** input पर injection पकड़ें, फिर किसी **tool call** को execute होने से पहले evaluate करें, फिर **tool result** को agent के पास लौटने से पहले scan करें। आप एक checkpoint अपना सकते हैं या तीनों; अगर एक से शुरू कर रहे हैं, तो user input पर prompt-injection detection सबसे ज्यादा सुरक्षा देती है।

## Quick example

```python theme={null}
from rail_score_sdk import RailScoreClient

client = RailScoreClient(api_key="YOUR_RAIL_API_KEY")

# 1. Check for injection in user input
injection = client.agent.detect_injection(text=user_input)
if injection.injection_detected:
    return "Invalid input detected."

# 2. Evaluate tool call before execution
tool_check = client.agent.evaluate_tool_call(
    tool_name="send_email",
    tool_input={"to": "user@example.com", "body": agent_draft},
    agent_context="Customer support agent",
)
if tool_check.recommendation == "block":
    return f"Tool call blocked: {tool_check.explanation}"

# 3. Execute the tool, then scan the result
tool_output = execute_tool(tool_name, tool_input)
result_scan = client.agent.scan_tool_result(
    tool_name="send_email",
    tool_result=tool_output,
)
if result_scan.pii_detected:
    tool_output = result_scan.redacted_result
```

## आगे क्या

<CardGroup cols={2}>
  <Card title="API Reference: Tool Call" icon="code" href="/api-reference/agent-tool-call">
    tool call evaluation का पूरा specification।
  </Card>

  <Card title="Python SDK: Agent Evaluation" icon="python" href="/sdk/python/agent-evaluation">
    तीनों agent endpoints के लिए Python SDK reference।
  </Card>
</CardGroup>
