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

# Tool calling की सुरक्षा और validation

> Tool arguments validate करें, execution को सुरक्षित बनाएँ और model की unsafe actions रोकें।

Model द्वारा बनाए गए tool arguments को untrusted input मानें।

## सुरक्षा जाँच-सूची

* Tool schemas को छोटा और स्पष्ट रखें।
* Tool execute करने से पहले parsed arguments validate करें।
* Tool names को allowlist करें और unknown tools अस्वीकार करें।
* External calls के लिए timeouts और retries जोड़ें।
* Call ID, tool name और validation failures log करें।

## अनुरोध सत्यापन का उदाहरण (TypeScript + Zod)

```typescript theme={null}
import { z } from "zod";

const WeatherArgs = z.object({
  city: z.string().min(1),
});

function executeToolCall(name: string, rawArgs: string) {
  if (name !== "get_weather") {
    throw new Error(`Unsupported tool: ${name}`);
  }

  const parsed = WeatherArgs.parse(JSON.parse(rawArgs));
  return getWeather(parsed.city);
}
```

## विफलता से निपटने की रणनीति

Validation विफल होने पर:

1. Tool execute न करें।
2. अगले model turn में controlled error payload लौटाएँ।
3. Model से corrected arguments के साथ फिर कोशिश करने को कहें।

## स्ट्रीमिंग पर ध्यान दें

स्ट्रीमिंग टूल कॉल मॉडल और प्रदाता के समर्थन पर निर्भर हैं। कॉल को पार्स, सत्यापित या निष्पादित करने से पहले सभी आर्ग्युमेंट डेल्टा इकट्ठे करें। [स्ट्रीमिंग](./streaming.mdx) देखें।


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.