Skip to content

Conversation

ayaankhan28
Copy link

@ayaankhan28 ayaankhan28 commented May 15, 2025

Agent Architecture Refactoring

⚠NOTE: TESTING UNDER PROGRESS!!⚠

Overview

Refactored agent architecture to improve modularity and maintainability by introducing a base agent class and restructuring the ReAct agent implementation.

Key Changes

  • Added BaseAgent with standardized interfaces for planning, tool management, and memory
  • Refactored ReActAgent to use the new base architecture
  • Split functionality into specialized components (ReActPlanner, ReActToolManager, ReActMemory)
  • Maintained backward compatibility with legacy implementation

Benefits

  • Better code organization and maintainability
  • Easier to extend with new agent types
  • Improved separation of concerns
  • Standardized interfaces for agent components

Breaking Changes

None. Both old (LegacyReActAgent) and new (NewReActAgent) implementations are available.

<END_OF_USER_QUERY>
"""

OUTPUT_FORMAT = r"""You should provide a JSON object in this structure:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is not used

class ReActMemory(BaseMemory):
"""ReAct-specific memory implementation."""

def retrieve(self, query: str) -> List[Step]:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

retrieve is also not used

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup In progress few things still left to add and test. Memory, training.. will let you know once PR is ready for review in some time.

@ayaankhan28 ayaankhan28 marked this pull request as ready for review May 16, 2025 19:22
@ayaankhan28
Copy link
Author

can you review and let me know is it good or what until now @liyin2015 pls.

@@ -0,0 +1,134 @@
"""Example demonstrating ReAct agent with vector memory support."""
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

examples should not be in the package, please move it to tutorials

raise NotImplementedError


class BaseToolManager(Component):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we dont need another base tool manager, the toolmanager is already abstracted enough.

The goal is not to create more than 3 levels of abstraction especially those not doing much work.

The abstraction of the agent should be more focused on the design pattern of agents, such as openai's agent sdk, where it makes it easier to create an agent from user's experience and still remain the control over the prompts if the user wants to modify it.

also we are trying to make it easy to hand over the context (memory) and the step history to all other agents (as a tool).

i have some code and i can share later.

we can do another quick sync call next week.

you can check out openai agent sdk before that.

raise NotImplementedError


class BaseAgent(Component):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

another complexity of the agent is at the auto-optimization, we can make this new agent experimental and it might need multiple iterations to get more mature

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants