> For the complete documentation index, see [llms.txt](https://docs.neuron-ai.dev/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.neuron-ai.dev/v2/overview/readme/upgrade-to-v2-from-v1.md).

# Upgrade To v2 From v1

### Updating Dependencies

You should update the following dependencies in your application's `composer.json` file:

* **neuron-core/neuron-ai** to **^2.0**

### High Impact Changes

#### Workflow

The Workflow component was completely re-architected. The Edge class was completely removed and now the orchestration system is event-driven relying only on node definition.

It also supports real-time streaming.

We strongly recommend to use the V2 documentation to understand the new system and move your previously created Workflow to the new architecture.

<a href="/pages/LwiA5oss8HSjzdefFNvg" class="button secondary" data-icon="arrow-right-long">Workflow Documentation</a>

### Low Impact

#### RAG Retrieval component

In the previous version the RAG component could interact with a vector store and an embeddings provider, but there was no way to customize this behavior. Recently many different retrieval techniques emerged trying to increase the accuracy of a RAG system.

Neuron RAG now has a separate retrieval component that allwos you to implement different strategies to accomplish context retrieval from an external data source. By default RAG uses `SimilarityRetrieval` that simply replicate the previous behaviour maintaining backward compatibility. But it depends now by its own interface so you can create custom implementation and inject it into the RAG.

<a href="#rag-retrieval-component" class="button secondary" data-icon="arrow-right-long">Retrieval Documentation</a>

### New Features

#### Neuron CLI

V2 ships with practical developer experience improvements that address common friction points. The CLI tool brings the new “make” command that helps you scaffold common classes reducing boilerplate fatigue:

```bash
# Unix
php vendor/bin/neuron make:agent App\\Neuron\\MyAgent

# Windows
php .\vendor\bin\neuron make:agent App\\Neuron\\MyAgent
```

#### Evaluators

When building AI agents, evaluating their performance is crucial during this process. It's important to consider various qualitative and quantitative factors, including response quality, task completion, success, and inaccuracies or hallucinations.

Neuron introduces a system to create evaluators against test cases, so you can continues verify the output of your agentic entities overtime.

<a href="/pages/hlVUMD8XoXRBHEHgu2CP" class="button secondary" data-icon="arrow-right-long">Evaluation Documentation</a>

#### Structured Output validation rules

We introduced two new validation rules for structured output: [WordsCount](#structured-output-validation-rules) (works on string), and [InRange](#structured-output-validation-rules) (works on numeric).

#### Tool Max Tries

Agents now have a safety mechanism that tracks the number of times a tool is invoked during an execution session. If the agent exceeds this limit, execution is interrupted and an exception is thrown. By default the limit is 5 calls, and it count for each tool individually.&#x20;

You can customize this value with the `toolMaxTries()` method at agent level, or use `setMaxTries()` on the tool level. Setting Max tries on single tool takes precedence over the global setting.

```php
try {

    $result = YouTubeAgent::make()
        ->toolMaxTries(5) // Max number of calls for each tool
        ->addTool(
            // Tool level config takes precedence over the global setting
            CustomTool::make()->setMaxTries(2)
        )
        ->chat(...);
        
} catch (ToolMaxTriesException $exception) {
    // do something
}
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://docs.neuron-ai.dev/v2/overview/readme/upgrade-to-v2-from-v1.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
