Agent class is the core agent implementation in Upsonic, providing a powerful and flexible interface for creating AI agents with advanced capabilities including memory management, safety policies, reliability layers, and sophisticated tool integration.
Table of Contents
Creating an Agent
TheAgent can be created with minimal configuration or with extensive customization to suit your specific needs. The agent provides a robust foundation for AI-powered applications with built-in support for various advanced features.
Basic Agent Creation
The simplest way to create an agent is with default settings:"openai/gpt-4o". Make sure you have the appropriate API key set in your environment.
Agent with Custom Configuration
For more control over your agent’s behavior, you can specify various parameters:Agent with Company Information
You can provide company context to help the agent understand your organization:Agent Attributes
TheAgent exposes numerous attributes that control its behavior and capabilities. Understanding these attributes is crucial for effective agent configuration.
Core Identity Attributes
Example:
Model and Performance Attributes
Example:
Company Context Attributes
Example:
Role and Professional Attributes
Example:
System and Context Attributes
Example:
Tool and Execution Attributes
Example:
enable_reasoning_tool requires enable_thinking_tool to be True. Setting reasoning without thinking will raise a ValueError.
Memory and Storage Attributes
Example:
Safety and Reliability Attributes
Example:
Canvas and External Integration Attributes
Example:
Adding a Memory
Memory capabilities allow your agent to maintain context across conversations, learn from interactions, and provide personalized responses. The memory system supports multiple storage backends and various memory types.Memory System Overview
The memory system in Upsonic provides three main types of memory:- Full Session Memory: Stores complete conversation history
- Summary Memory: Maintains condensed summaries of conversations
- User Analysis Memory: Builds user profiles and preferences
Setting Up Memory with SQLite
Memory Configuration Options
Example with Custom Memory Settings:
Using Memory in Task Execution
When memory is enabled, the agent automatically:- Retrieves relevant context from previous conversations
- Updates user profiles based on interactions
- Maintains conversation summaries for long-term context
- Feeds tool call results into memory (if enabled)
Memory Management Methods
The agent provides methods to manage memory:Adding Thinking Tool
Thinking Tool capabilities enable the agent to think through problems step-by-step, analyze its own reasoning, and provide more thoughtful responses. This is particularly useful for complex problem-solving tasks.Enabling Thinking Tool
Thinking Tool is controlled by theenable_thinking_tool parameter:
How Thinking Tool Works
When Thinking Tool is enabled, the agent:- Analyzes the problem before attempting to solve it
- Breaks down complex tasks into manageable steps
- Evaluates its own reasoning and adjusts if needed
- Provides detailed explanations of its thought process
Thinking Tool Configuration
You can control Thinking Tool at both the agent and task level:Thinking Tool Use Cases
Thinking Tool is particularly valuable for:- Financial calculations and modeling
- Risk assessment and compliance analysis
- Multi-step loan processing workflows
- Regulatory compliance verification
- Investment strategy planning
Adding Reasoning
Reasoning capabilities build upon Thinking Tool to provide even more sophisticated problem-solving abilities. Reasoning enables the agent to use advanced logical analysis and structured thinking approaches.Enabling Reasoning
Reasoning requires bothenable_thinking_tool and enable_reasoning_tool to be True:
enable_reasoning_tool cannot be True if enable_thinking_tool is False. This will raise a ValueError.
Reasoning vs. Thinking Tool
Reasoning Configuration
Reasoning can be configured at multiple levels:Advanced Reasoning Use Cases
Reasoning is ideal for:- Strategic banking and fintech analysis
- Complex financial data interpretation
- Multi-variable risk assessment
- Regulatory compliance and risk mitigation
- Portfolio optimization and investment strategies
Reasoning Output Structure
When reasoning is enabled, the agent provides:- Financial Problem Decomposition: Breaking complex banking scenarios into components
- Risk Analysis: Step-by-step risk assessment and logical reasoning
- Regulatory Evidence Evaluation: Assessing compliance requirements and financial data
- Financial Synthesis: Combining insights into coherent banking recommendations
- Actionable Recommendations: Specific next steps for implementation and compliance
Performance Considerations
Warning: Reasoning capabilities consume more tokens and processing time than basic Thinking Tool. Monitor your usage and costs when using reasoning for production applications.Complete Example: Advanced Agent Configuration
Here’s a comprehensive example showing how to create a fully-featured agent with all capabilities:Best Practices
- Start Simple: Begin with basic configuration and add features as needed for your banking use case
- Monitor Performance: Use debug mode to understand token usage and costs in financial applications
- Memory Management: Choose appropriate memory settings for customer relationship management and compliance tracking
- Safety First: Always implement appropriate safety policies for financial data and regulatory compliance
- Error Handling: Configure retry settings based on your reliability requirements for critical banking operations
- Resource Management: Be mindful of token consumption with reasoning capabilities in risk assessment scenarios
- Regulatory Compliance: Ensure all AI outputs meet banking regulations and compliance requirements
- Data Security: Implement proper data encryption and access controls for sensitive financial information

