# Configuration

When using the `@model` decorator, you can optionally provide a configuration object to customize the model's behavior:

```typescript
@model('openai:gpt-4', {
  maxTokens: 100,
  temperature: 0.5,
  maxRetries: 3,
  maxSteps: 3,
  toolChoice: 'auto'
})
class MyAgent extends Agent<string, string> {}
```

### Configuration options

| Option        | Type                 | Default | Description                                                                                                                                                |
| ------------- | -------------------- | ------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `maxTokens`   | `number`             | -       | Maximum number of tokens to generate in the response. Use this to control response length.                                                                 |
| `temperature` | `number`             | -       | Sampling temperature between 0 and 1. Lower values make responses more focused and deterministic, while higher values make them more creative and diverse. |
| `maxRetries`  | `number`             | -       | Maximum number of retries for failed API requests before giving up.                                                                                        |
| `maxSteps`    | `number`             | 3       | Maximum number of conversation steps (tool calls) the agent can take to complete a task.                                                                   |
| `toolChoice`  | `'auto'` \| `'none'` | -       | Controls how the model uses tools. Set to 'none' to disable tool usage, or 'auto' to let the model decide when to use tools.                               |

### Example usage

```typescript
// Basic usage without configuration
@model('openai:gpt-4')
class SimpleAgent extends Agent<string, string> {}

// With partial configuration
@model('openai:gpt-4', {
    maxTokens: 100,
    temperature: 0.7
})
class ConfiguredAgent extends Agent<string, string> {}

// With full configuration
@model('openai:gpt-4', {
    maxTokens: 150,
    temperature: 0.5,
    maxRetries: 3,
    maxSteps: 5,
    toolChoice: 'auto'
})
class FullyConfiguredAgent extends Agent<string, string> {}
```

### Best practices

1. Set `maxTokens` based on your expected response length needs to optimize costs
2. Use lower `temperature` (0.1-0.4) for tasks requiring precise, factual responses
3. Use higher `temperature` (0.6-0.9) for tasks requiring creativity
4. Adjust `maxSteps` based on task complexity - simple tasks may only need 1-2 steps
5. Consider setting `maxRetries` for improved reliability in production environments


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://axar-ai.gitbook.io/axar/advanced/configuration.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
