Skip to content

Commit b1832a6

Browse files
Agent: loop avoid
1 parent ceec6eb commit b1832a6

File tree

22 files changed

+150
-104
lines changed

22 files changed

+150
-104
lines changed

docs/guide/api-reference/classes/AgentRuntime.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ This class encapsulates the complexity of ChatObject and provides a simplified A
1919

2020
- `config` ([AmritaConfig](AmritaConfig.md)): Amrita configuration object containing global configuration settings
2121
- `preset` ([ModelPreset](ModelPreset.md)): Model preset configuration defining basic model parameters and settings
22-
- `strategy` (type[AgentStrategy], optional): Agent strategy class, defaults to AmritaAgentStrategy
22+
- `strategy` (type[AgentStrategy], optional): Agent strategy class, defaults to ReActAgentStrategy
2323
- `template` (Template | str, optional): Train template to render system role message, defaults to DEFAULT_TEMPLATE
2424
- `session` (SessionData | str | None, optional): Session data or session ID string for restoring existing sessions. If None, a new session will be created
2525
- `train` (dict[str, str] | Message[str] | None, optional): Training data (system prompts), can be in dictionary format or as a Message object

docs/guide/api-reference/classes/ChatObject.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ The ChatObject class is the primary interface for conversations with the AI.
4040
- `auto_create_session` (bool): Whether to automatically create a session if it does not exist (default: False)
4141
- `train_template` (Template): Jinja2 template used to format system message (default: DEFAULT_TEMPLATE)
4242
- `jinja2_vars` (dict[str, Any] | None): Variables to be passed to the template system for custom template variables (default: None). **Important**: Keys in this dictionary must NOT match built-in variable names (`train`, `memory`, `chatobj`, `config`) as this would cause a TypeError due to duplicate keyword arguments.
43-
- `agent_strategy` (type[AgentStrategy]): Agent strategy to be used for execution (default: AmritaAgentStrategy)
43+
- `agent_strategy` (type[AgentStrategy]): Agent strategy to be used for execution (default: ReActAgentStrategy)
4444
- `hook_args` (tuple[Any, ...]): Positional arguments passed to event handlers when events are triggered (default: empty tuple)
4545
- `hook_kwargs` (dict[str, Any] | None): Keyword arguments passed to event handlers when events are triggered (default: None)
4646
- `exception_ignored` (tuple[type[BaseException], ...]): Exception types that should be ignored and raised again in event handlers (default: empty tuple)

docs/guide/api-reference/classes/AmritaAgentStrategy.md renamed to docs/guide/api-reference/classes/ReActAgentStrategy.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
# AmritaAgentStrategy
1+
# ReActAgentStrategy
22

3-
The AmritaAgentStrategy is a strategy for executing an agent in RAG and Agent mode.
3+
The ReActAgentStrategy is a strategy for executing an agent in RAG and Agent mode.
44

55
This strategy implements the 'agent-mixed' category, allowing it to dynamically handle both retrieval-augmented generation scenarios and standard iterative tool calling agents within the same execution framework.
66

@@ -56,7 +56,7 @@ The 'agent-mixed' category allows the strategy to dynamically handle both retrie
5656

5757
```python
5858
from amrita_core.agent.context import StrategyContext
59-
from amrita_core.builtins.agent import AmritaAgentStrategy
59+
from amrita_core.builtins.agent import ReActAgentStrategy
6060

6161
# Create strategy context
6262
ctx = StrategyContext(
@@ -66,6 +66,6 @@ ctx = StrategyContext(
6666
)
6767

6868
# Create and use the strategy
69-
strategy = AmritaAgentStrategy(ctx)
69+
strategy = ReActAgentStrategy(ctx)
7070
should_continue = await strategy.single_execute()
7171
```

docs/guide/builtins.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,9 @@ AmritaCore provides built-in adapters for multiple LLM providers, implementing t
7575

7676
AmritaCore includes a comprehensive intelligent agent system capable of autonomously using tools to complete tasks.
7777

78-
### 9.3.1 AmritaAgentStrategy
78+
### 9.3.1 ReActAgentStrategy
7979

80-
The `AmritaAgentStrategy` is the built-in agent strategy that implements the `"agent-mixed"` category, supporting both retrieval-augmented generation (RAG) and iterative tool calling within the same execution framework.
80+
The `ReActAgentStrategy` is the built-in agent strategy that implements the `"agent-mixed"` category, supporting both retrieval-augmented generation (RAG) and iterative tool calling within the same execution framework.
8181

8282
**Key Features**:
8383

docs/guide/concepts/agent-strategy.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,12 +76,12 @@ class MyCustomAgentStrategy(AgentStrategy):
7676

7777
### Using Built-in Strategies
7878

79-
AmritaCore provides the `AmritaAgentStrategy` as a built-in implementation that supports the `"agent-mixed"` category:
79+
AmritaCore provides the `ReActAgentStrategy` as a built-in implementation that supports the `"agent-mixed"` category:
8080

8181
```python
8282
import asyncio
8383
from amrita_core import create_agent, minimal_init
84-
from amrita_core.builtins.agent import AmritaAgentStrategy
84+
from amrita_core.builtins.agent import ReActAgentStrategy
8585

8686
async def use_builtin_strategy():
8787
# Initialize AmritaCore
@@ -91,7 +91,7 @@ async def use_builtin_strategy():
9191
agent = create_agent(
9292
url="https://api.example.com",
9393
key="your-api-key",
94-
strategy=AmritaAgentStrategy
94+
strategy=ReActAgentStrategy
9595
)
9696

9797
# Use the agent
@@ -119,7 +119,7 @@ The `StrategyContext` provides all necessary information for strategy execution:
119119
1. **Choose the Right Category**: Select the strategy category that best matches your use case
120120
2. **Leverage Framework Features**: Use built-in features like tool calling limits, error handling, and response streaming
121121
3. **Handle Errors Gracefully**: Implement proper error handling in your strategy methods
122-
4. **Use Built-in Strategies When Possible**: Start with `AmritaAgentStrategy` before creating custom implementations
122+
4. **Use Built-in Strategies When Possible**: Start with `ReActAgentStrategy` before creating custom implementations
123123
5. **Test Thoroughly**: Ensure your strategy handles edge cases and error conditions properly
124124

125125
## Example: Custom RAG Strategy

docs/zh/guide/api-reference/classes/AgentRuntime.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ AgentRuntime 类是 ChatObject 的高级包装器,提供可重用的 agent 操
1919

2020
- `config` ([AmritaConfig](AmritaConfig.md)): 包含全局配置设置的 Amrita 配置对象
2121
- `preset` ([ModelPreset](ModelPreset.md)): 定义基本模型参数和设置的模型预设配置
22-
- `strategy` (type[AgentStrategy], 可选): agent 策略类,默认为 AmritaAgentStrategy
22+
- `strategy` (type[AgentStrategy], 可选): agent 策略类,默认为 ReActAgentStrategy
2323
- `template` (Template | str, 可选): 用于渲染系统角色消息的训练模板,默认为 DEFAULT_TEMPLATE
2424
- `session` (SessionData | str | None, 可选): 用于恢复现有会话的会话数据或会话 ID 字符串。如果为 None,则会创建新会话
2525
- `train` (dict[str, str] | Message[str] | None, 可选): 训练数据(系统提示),可以是字典格式或 Message 对象

docs/zh/guide/api-reference/classes/ChatObject.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ ChatObject 类是与 AI 进行对话的主要接口。
4040
- `auto_create_session` (bool): 如果会话不存在,是否自动创建(默认:False)
4141
- `train_template` (Template): 用于格式化系统消息的 Jinja2 模板(默认:DEFAULT_TEMPLATE)
4242
- `jinja2_vars` (dict[str, Any] | None): 传递给模板系统的变量,用于自定义模板变量(默认:None)。**重要**:此字典中的键必须 NOT 与内置变量名(`train``memory``chatobj``config`)匹配,否则会导致 TypeError,因为重复的关键字参数在 Python 中是不允许的。
43-
- `agent_strategy` (type[AgentStrategy]): 用于执行的 Agent 策略(默认:AmritaAgentStrategy
43+
- `agent_strategy` (type[AgentStrategy]): 用于执行的 Agent 策略(默认:ReActAgentStrategy
4444
- `hook_args` (tuple[Any, ...]): 触发事件时传递给事件处理器的位置参数(默认:空元组)
4545
- `hook_kwargs` (dict[str, Any] | None): 触发事件时传递给事件处理器的关键字参数(默认:None)
4646
- `exception_ignored` (tuple[type[BaseException], ...]): 在事件处理器中应该被忽略并重新抛出的异常类型(默认:空元组)

docs/zh/guide/api-reference/classes/AmritaAgentStrategy.md renamed to docs/zh/guide/api-reference/classes/ReActAgentStrategy.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
# AmritaAgentStrategy
1+
# ReActAgentStrategy
22

3-
AmritaAgentStrategy 是用于在 RAG 和 Agent 模式下执行 agent 的策略。
3+
ReActAgentStrategy 是用于在 RAG 和 Agent 模式下执行 agent 的策略。
44

55
该策略实现了 'agent-mixed' 类别,允许在同一执行框架内动态处理检索增强生成场景和标准迭代工具调用 agent。
66

@@ -56,7 +56,7 @@ AmritaAgentStrategy 是用于在 RAG 和 Agent 模式下执行 agent 的策略
5656

5757
```python
5858
from amrita_core.agent.context import StrategyContext
59-
from amrita_core.builtins.agent import AmritaAgentStrategy
59+
from amrita_core.builtins.agent import ReActAgentStrategy
6060

6161
# 创建策略上下文
6262
ctx = StrategyContext(
@@ -66,6 +66,6 @@ ctx = StrategyContext(
6666
)
6767

6868
# 创建并使用策略
69-
strategy = AmritaAgentStrategy(ctx)
69+
strategy = ReActAgentStrategy(ctx)
7070
should_continue = await strategy.single_execute()
7171
```

docs/zh/guide/builtins.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,9 @@ AmritaCore 提供了多个LLM提供商的内置适配器,实现了 `ModelAdapt
7575

7676
AmritaCore 包含一个全面的智能体系统,能够自主使用工具完成任务。
7777

78-
### 9.3.1 AmritaAgentStrategy
78+
### 9.3.1 ReActAgentStrategy
7979

80-
`AmritaAgentStrategy` 是内置的Agent策略,实现了 `"agent-mixed"` 类别,支持在同一执行框架内同时处理检索增强生成(RAG)和迭代工具调用。
80+
`ReActAgentStrategy` 是内置的Agent策略,实现了 `"agent-mixed"` 类别,支持在同一执行框架内同时处理检索增强生成(RAG)和迭代工具调用。
8181

8282
**关键特性**
8383

docs/zh/guide/concepts/agent-strategy.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,12 +76,12 @@ class MyCustomAgentStrategy(AgentStrategy):
7676

7777
### 使用内置策略
7878

79-
AmritaCore 提供了 `AmritaAgentStrategy` 作为内置实现,支持 `"agent-mixed"` 类别:
79+
AmritaCore 提供了 `ReActAgentStrategy` 作为内置实现,支持 `"agent-mixed"` 类别:
8080

8181
```python
8282
import asyncio
8383
from amrita_core import create_agent, minimal_init
84-
from amrita_core.builtins.agent import AmritaAgentStrategy
84+
from amrita_core.builtins.agent import ReActAgentStrategy
8585

8686
async def use_builtin_strategy():
8787
# 初始化 AmritaCore
@@ -91,7 +91,7 @@ async def use_builtin_strategy():
9191
agent = create_agent(
9292
url="https://api.example.com",
9393
key="your-api-key",
94-
strategy=AmritaAgentStrategy
94+
strategy=ReActAgentStrategy
9595
)
9696

9797
# 使用 agent
@@ -119,7 +119,7 @@ if __name__ == "__main__":
119119
1. **选择正确的类别**: 选择最适合您用例的策略类别
120120
2. **利用框架功能**: 使用内置功能如工具调用限制、错误处理和响应流
121121
3. **优雅地处理错误**: 在策略方法中实现适当的错误处理
122-
4. **尽可能使用内置策略**: 在创建自定义实现之前,先从 `AmritaAgentStrategy` 开始
122+
4. **尽可能使用内置策略**: 在创建自定义实现之前,先从 `ReActAgentStrategy` 开始
123123
5. **彻底测试**: 确保您的策略能正确处理边缘情况和错误条件
124124

125125
## 示例:自定义 RAG 策略

0 commit comments

Comments
 (0)