重构src/agent目录中的代码,减少其代码重复 #28
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
1.修改原因:src/agent目录中的agent的实现,代码几乎完全相同,存在严重的代码重复;各个agent对应的prompt模板,存在大量重复
2.修改内容:
(1). 代码:refactor(agent): 重构多个agent类继承自BaseAgent
将browser_use_agent、deep_analyzer_agent、deep_researcher_agent和planning_agent重构为继承自新创建的BaseAgent类,减少代码重复。BaseAgent类包含了这些agent共有的核心功能实现。
主要变更:
1). 创建BaseAgent基类包含共享逻辑
2). 简化各子类实现,仅保留特定配置
3). 统一初始化流程
(2). prompt模板
重构agent中的prompt模板
1).重构agent中的prompt模板,减少模板中的重复描述;
2).重构base_agent的模板加载逻辑,支持多目录搜索和jinja2渲染