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

# Query Rewriter Agent • Rust AI Agent SDK

> QueryRewriterAgent: Agent for rewriting queries

# QueryRewriterAgent

> Defined in the [**Specialized Agents**](../modules/specialized_agents) module.

<Badge color="orange">Rust AI Agent SDK</Badge>

Agent for rewriting queries

```mermaid theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
%%{init: {'theme': 'base', 'themeVariables': { 'primaryColor': '#8B0000', 'primaryTextColor': '#fff', 'primaryBorderColor': '#710101', 'lineColor': '#189AB4', 'secondaryColor': '#189AB4', 'tertiaryColor': '#fff' }}}%%

graph LR
    input["Input Data"] --> agent["Agent: QueryRewriterAgent"]
    agent --> output["Output Result"]
    style agent fill:#8B0000,color:#fff
    style input fill:#8B0000,color:#fff
    style output fill:#8B0000,color:#fff
```

## Fields

| Name     | Type                  | Description |
| -------- | --------------------- | ----------- |
| `config` | `QueryRewriterConfig` | -           |

## Methods

### `new`

```rust theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
fn new() -> QueryRewriterAgentBuilder
```

Create a new builder

### `name`

```rust theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
fn name(&self) -> &str
```

Get agent name

### `model`

```rust theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
fn model(&self) -> &str
```

Get model

### `expand_abbreviations`

```rust theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
fn expand_abbreviations(&self, query: &str) -> String
```

Expand abbreviations in query

**Parameters:**

| Name    | Type   |
| ------- | ------ |
| `query` | `&str` |

### `detect_strategy`

```rust theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
fn detect_strategy(&self, query: &str, has_chat_history: bool) -> RewriteStrategy
```

Detect the best rewriting strategy for a query

**Parameters:**

| Name               | Type   |
| ------------------ | ------ |
| `query`            | `&str` |
| `has_chat_history` | `bool` |

### `rewrite_sync`

```rust theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
fn rewrite_sync(
        &self,
        query: &str,
        strategy: RewriteStrategy,
        chat_history: Option<&[HashMap<String, String>]>,
        context: Option<&str>,
        num_queries: Option<usize>,
    ) -> RewriteResult
```

Rewrite a query (sync placeholder - actual implementation would use LLM)

**Parameters:**

| Name           | Type                            |
| -------------- | ------------------------------- |
| `query`        | `&str`                          |
| `strategy`     | `RewriteStrategy`               |
| `chat_history` | `Option&lt;&[HashMap&lt;String` |
| `context`      | `Option&lt;&str&gt;`            |
| `num_queries`  | `Option&lt;usize&gt;`           |

## Source

<Card title="View on GitHub" icon="github" href="https://github.com/MervinPraison/PraisonAI/blob/main/src/praisonai-rust/praisonai/src/specialized_agents.rs#L722">
  `praisonai/src/specialized_agents.rs` at line 722
</Card>

***

## Related Documentation

<CardGroup cols={2}>
  <Card title="Rust Agent" icon="robot" href="/docs/rust/agent" />

  <Card title="Rust Overview" icon="book-open" href="/docs/rust/overview" />

  <Card title="Rust Quickstart" icon="rocket" href="/docs/rust/quickstart" />

  <Card title="Rust Installation" icon="download" href="/docs/rust/installation" />

  <Card title="Rust Autonomy" icon="wand-magic-sparkles" href="/docs/rust/autonomy" />
</CardGroup>
