Skip to main content
The 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

  1. Creating an Agent
  2. Agent Attributes
  3. Adding a Memory
  4. Adding Thinking
  5. Adding Reasoning

Creating an Agent

The Agent 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:
Warning: When creating an agent without specifying a model, it defaults to "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

The Agent 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:
Warning: 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:
  1. Full Session Memory: Stores complete conversation history
  2. Summary Memory: Maintains condensed summaries of conversations
  3. 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:
  1. Retrieves relevant context from previous conversations
  2. Updates user profiles based on interactions
  3. Maintains conversation summaries for long-term context
  4. 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 the enable_thinking_tool parameter:

How Thinking Tool Works

When Thinking Tool is enabled, the agent:
  1. Analyzes the problem before attempting to solve it
  2. Breaks down complex tasks into manageable steps
  3. Evaluates its own reasoning and adjusts if needed
  4. Provides detailed explanations of its thought process
Example Output with Thinking Tool:

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
Example:

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 both enable_thinking_tool and enable_reasoning_tool to be True:
Warning: 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
Example:

Reasoning Output Structure

When reasoning is enabled, the agent provides:
  1. Financial Problem Decomposition: Breaking complex banking scenarios into components
  2. Risk Analysis: Step-by-step risk assessment and logical reasoning
  3. Regulatory Evidence Evaluation: Assessing compliance requirements and financial data
  4. Financial Synthesis: Combining insights into coherent banking recommendations
  5. 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:
This comprehensive configuration demonstrates how to leverage all the major features of the Agent for sophisticated banking and fintech applications.

Best Practices

  1. Start Simple: Begin with basic configuration and add features as needed for your banking use case
  2. Monitor Performance: Use debug mode to understand token usage and costs in financial applications
  3. Memory Management: Choose appropriate memory settings for customer relationship management and compliance tracking
  4. Safety First: Always implement appropriate safety policies for financial data and regulatory compliance
  5. Error Handling: Configure retry settings based on your reliability requirements for critical banking operations
  6. Resource Management: Be mindful of token consumption with reasoning capabilities in risk assessment scenarios
  7. Regulatory Compliance: Ensure all AI outputs meet banking regulations and compliance requirements
  8. Data Security: Implement proper data encryption and access controls for sensitive financial information
The Agent provides a powerful foundation for building sophisticated banking and fintech applications with enterprise-grade features, regulatory compliance, and advanced risk management capabilities.