Skip to main content
This example demonstrates how to create and use an Upsonic Team in coordinate mode to automate end-to-end loan covenant compliance monitoring. The example showcases how to leverage Upsonic’s multi-agent coordination to orchestrate three specialist agents that work together on document parsing, financial calculation, and risk assessment.

Overview

Upsonic framework provides seamless integration for multi-agent systems. This example showcases:
  1. Team Coordination β€” Using Team in coordinate mode with a leader agent that delegates to specialists
  2. Custom Financial Tools β€” Six standalone calculation functions used as agent tools
  3. Structured Output β€” Enforced CovenantMonitoringReport Pydantic schema for type-safe results
  4. Agent Personas β€” Agents with role, goal, education, and work experience for domain expertise
  5. Memory Persistence β€” In-memory session storage for continuity
  6. FastAPI Server β€” Running the team as a production-ready API server
The team uses three specialist agents:
  • Covenant Extractor β€” Parses loan agreement text to extract covenant definitions and thresholds
  • Financial Calculator β€” Computes financial ratios using custom calculation tools
  • Risk Assessor β€” Evaluates compliance status and produces risk scores with remediation recommendations

Project Structure

Environment Variables

You can configure the model using environment variables:

Installation

Managing Dependencies

Sections: api, development

Usage

Option 1: Run Directly

Runs the agent with default test inputs (GlobalTech Manufacturing Inc., Q4 2025).

Option 2: Run as API Server

Server starts at http://localhost:8000. API documentation at /docs. Example API call:

How It Works

Example Output

Query:
Response:

Complete Implementation

main.py

team.py

agents.py

tools.py

upsonic_configs.json

Key Features

Team Coordination (Coordinate Mode)

The leader agent uses Upsonic’s coordinate mode to automatically delegate tasks to the three specialist agents, synthesize their findings, and produce a unified compliance report.

Specialist Agents with Personas

Each agent is configured with domain-specific expertise:
  • Covenant Extractor: Legal document analysis with JD/CFA credentials and 15 years of leveraged finance experience
  • Financial Calculator: Quantitative analysis with FRM certification and custom calculation tools
  • Risk Assessor: Credit risk evaluation with PRM certification and compliance scoring methodology

Custom Financial Tools

Six standalone functions provide deterministic, auditable financial calculations:
  • calculate_leverage_ratio β€” Total Debt / EBITDA
  • calculate_interest_coverage_ratio β€” EBIT / Interest Expense
  • calculate_current_ratio β€” Current Assets / Current Liabilities
  • calculate_debt_service_coverage_ratio β€” Net Operating Income / Total Debt Service
  • calculate_tangible_net_worth β€” Total Assets - Total Liabilities - Intangible Assets
  • evaluate_covenant_compliance β€” Determines compliant / near-breach / breached status with headroom

Structured Output

The CovenantMonitoringReport Pydantic model enforces consistent, machine-readable output with covenant definitions, calculated ratios, compliance results, risk assessment, executive summary, and next steps.

Repository

View the complete example: Loan Covenant Monitoring Agent