Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Agent support #727

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open

Agent support #727

wants to merge 1 commit into from

Conversation

wassemgtk
Copy link
Collaborator

Key Features:

Base Agent Infrastructure

Introduces a flexible BaseAgent class that all agents inherit from Implements tool management and conversation history tracking Provides abstract methods for custom agent implementations

Built-in Agents:

a) ReAct Agent

Implements the Reasoning + Acting pattern
Follows a structured process: Reason → Act → Observe → Respond Excels at complex tasks requiring tool use and step-by-step thinking Maximum 5 steps to prevent infinite loops

b) Chain of Thought (CoT) Agent

Specializes in breaking down complex problems into logical steps Shows explicit reasoning process for each step
Focuses on transparent decision-making
Ideal for math, logic, and analysis tasks

c) Tool-Using Agent

Optimized for scenarios requiring multiple tool interactions Analyzes available tools and plans usage sequence
Executes tools and processes results
Built-in error handling for missing tools

Custom Agent Framework

Allows creation of specialized agents with custom behaviors Configurable system prompts and extraction patterns Adjustable maximum steps and tool usage
Flexible pattern matching for different response formats

Shared Components:

Tool class for defining and executing custom tools AgentOutput class for standardized response formatting Conversation history tracking
Consistent error handling

from writer.agents import ReActAgent, Tool

# Create a tool
calculator = Tool(
    name="calculator",
    description="Performs basic math operations",
    func=lambda x, y, op: eval(f"{x}{op}{y}")
)

# Initialize agent
agent = ReActAgent(tools=[calculator])

# Run agent
result = agent.run("What is 25 * 48?")

# Access structured output
print(result.response)      # Final answer
print(result.reasoning)     # List of reasoning steps
print(result.actions)       # List of tools used

Key Features:

Base Agent Infrastructure


Introduces a flexible BaseAgent class that all agents inherit from
Implements tool management and conversation history tracking
Provides abstract methods for custom agent implementations


Built-in Agents:

a) ReAct Agent

Implements the Reasoning + Acting pattern
Follows a structured process: Reason → Act → Observe → Respond
Excels at complex tasks requiring tool use and step-by-step thinking
Maximum 5 steps to prevent infinite loops

b) Chain of Thought (CoT) Agent

Specializes in breaking down complex problems into logical steps
Shows explicit reasoning process for each step
Focuses on transparent decision-making
Ideal for math, logic, and analysis tasks

c) Tool-Using Agent

Optimized for scenarios requiring multiple tool interactions
Analyzes available tools and plans usage sequence
Executes tools and processes results
Built-in error handling for missing tools


Custom Agent Framework


Allows creation of specialized agents with custom behaviors
Configurable system prompts and extraction patterns
Adjustable maximum steps and tool usage
Flexible pattern matching for different response formats


Shared Components:


Tool class for defining and executing custom tools
AgentOutput class for standardized response formatting
Conversation history tracking
Consistent error handling

```
from writer.agents import ReActAgent, Tool

# Create a tool
calculator = Tool(
    name="calculator",
    description="Performs basic math operations",
    func=lambda x, y, op: eval(f"{x}{op}{y}")
)

# Initialize agent
agent = ReActAgent(tools=[calculator])

# Run agent
result = agent.run("What is 25 * 48?")

# Access structured output
print(result.response)      # Final answer
print(result.reasoning)     # List of reasoning steps
print(result.actions)       # List of tools used
```
@ramedina86
Copy link
Collaborator

@mmikita95 Mikita, can you please take a look and see how this relates to AI module? I'm seeing clear duplication in things like Tool

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