Overview
The Report Generation Tools provide AI-powered automated report creation with support for multiple output formats and customizable templates. These tools integrate with the OpsHub data infrastructure to aggregate portfolio metrics, performance data, and compliance information into professional reports suitable for management, boards, and regulatory audiences. Reports are generated through a three-stage pipeline: template selection, data aggregation, and AI-enhanced narrative generation. The system supports multiple report types including NAV summaries, breach reports, board presentations, and compliance documents.Quick Reference
Common Report Types
| Report Type | Purpose | Primary Audience | Typical Format |
|---|---|---|---|
nav_summary | Portfolio valuation overview | Management/Board | |
breach_report | Validation failure analysis | Compliance/Risk | Excel/PDF |
board_deck | Quarterly performance presentation | Board/Investors | PowerPoint |
performance_report | Fund/portfolio metrics | Management | PDF/Excel |
compliance_report | Regulatory compliance status | Compliance Officers |
Supported Output Formats
- PDF: Professional documents with formatting, tables, and charts
- Excel: Spreadsheet format with multiple sheets and data tables
- PowerPoint: Presentation format with slides and visual layouts
Common Cron Expressions
Tools
generate_report
Generate a comprehensive professional report with AI-powered narrative sections. Function Signature:| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
report_type | string | Yes | - | Report template type: nav_summary, breach_report, board_deck, performance_report, compliance_report |
period_start | string | Yes | - | Report period start date in YYYY-MM-DD format |
period_end | string | Yes | - | Report period end date in YYYY-MM-DD format |
format | string | No | Output format: pdf, excel, or powerpoint | |
portfolio_ids | List[string] | No | None | Filter data to specific portfolio IDs; if not provided, includes all portfolios |
template_id | string | No | None | Custom template ID; uses default template for report_type if not specified |
include_narrative | boolean | No | true | Include AI-generated narrative analysis and executive summaries |
report_id: Unique identifier for tracking and retrievalsections: Total number of report sections (tables, charts, text)narrative_sections: Count of AI-generated narrative sections (executive summaries, analysis)file_url: Download URL or generation location (may be “generated_in_memory”)
- NAV by Portfolio: Historical net asset values across portfolios
- NAV Variance Trends: 30-day performance trends for selected portfolio
- NAV Metrics: Aggregate metrics including total NAV, pass rates, validation counts
- Breaches: Validation failures and compliance events
- Remediation Actions: Corrective actions and compliance efforts
include_narrative=true, the system generates two narrative sections:
- Executive Summary: High-level overview with key metrics, trends, and performance highlights
- Root Cause Analysis: Analysis of validation breaches and remediation approaches
- Template: Collection of ordered sections with configuration
- Section: Individual content block (table, chart, narrative) with data source
- Data Source: Query or aggregation method (nav_by_portfolio, breaches, etc.)
- Rendering: Template engine interpolates data into final document
agent.report_templates table with versioning support.
Note: If a custom template is not found, the tool returns an error. If no template_id is provided, it automatically uses the default template for the report_type. If no default exists, it creates one from system defaults.
list_report_templates
List available report templates with optional filtering. Function Signature:| Parameter | Type | Required | Description |
|---|---|---|---|
report_type | string | No | Filter templates by report type (nav_summary, breach_report, etc.) |
- Discover available templates before calling
generate_report - Get template IDs for use in
generate_reportwithtemplate_idparameter - Understand template structure and section count
- Verify custom templates are available
schedule_report
Schedule recurring report generation and automated distribution. Function Signature:| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
template_id | string | Yes | - | Template ID to use (get from list_report_templates) |
schedule_cron | string | Yes | - | Cron expression defining schedule frequency and time |
distribution_list | List[string] | Yes | - | Email addresses for report delivery (minimum 1 recipient) |
format | string | No | Output format: pdf, excel, or powerpoint |
minute hour day month weekday
Common Patterns:
| Pattern | Cron | Frequency |
|---|---|---|
| Daily at 9am | 0 9 * * * | Every day |
| Weekdays at 9am | 0 9 * * 1-5 | Monday-Friday |
| Monday at 9am | 0 9 * * 1 | Every Monday |
| Friday at 5pm | 0 17 * * 5 | Every Friday |
| Month start at 9am | 0 9 1 * * | 1st of each month |
| Twice daily | 0 9,17 * * * | 9am and 5pm |
- Reports are emailed to all addresses in
distribution_list - Format (PDF, Excel, PowerPoint) is attached and specified in email
- Reports use the template configuration for period and data scope
- Delivery timing depends on system scheduler and mail queue
agent.report_schedules table:
schedule_id: Unique identifiertemplate_id: Reference to report templateschedule_cron: Cron expressionis_active: Boolean flag (can be toggled to pause/resume)distribution_list: Email recipients
Advanced Features
Custom Templates
Create custom templates for organization-specific needs:- Use
list_report_templatesto understand template structure - Clone existing template or create new in
agent.report_templates - Define sections with data sources and rendering instructions
- Reference custom template with
template_idingenerate_report
Data Source Integration
Available data aggregation sources:select_nav_by_portfolio: Portfolio-level NAV dataselect_nav_variance_trend: Historical performance trendscalculate_nav_metrics: Aggregate metrics and statisticsselect_breaches: Validation failures and eventsselect_remediation_actions: Compliance corrective actions
Narrative Customization
AI narratives are customized per section:- Executive Summary: Data-driven overview of period performance
- Root Cause Analysis: Analysis of top 5 breaches with remediation context
Error Handling
Common Errors:| Error | Cause | Solution |
|---|---|---|
| Template not found | Invalid template_id or missing default | Use list_report_templates to find valid IDs |
| Invalid format | Format not in pdf/excel/powerpoint | Check format parameter spelling |
| Invalid date format | Dates not in YYYY-MM-DD | Use standard date format |
| No data available | Period has no data or invalid portfolio_ids | Adjust date range or verify portfolio IDs |
Integration with OpsHub
Report generation integrates with:- Supabase Database: Stores templates, schedules, and generated reports
- Data Aggregation Service: Queries NAV, breach, and performance data
- Narrative Engine: AI-powered analysis and summarization
- Format Engines: PDF, Excel, and PowerPoint rendering
Performance Considerations
- Report Generation Time: Typically 5-30 seconds depending on data volume and format
- File Size: PDF (1-5MB), Excel (2-10MB), PowerPoint (3-15MB)
- Data Retention: Generated reports stored 90 days by default
- Rate Limits: No hard limit; consider scheduling during off-peak hours
File References
- Implementation:
/opshub-agent-backend/app/agent/tools/report_generation.py - Template Engine:
/opshub-agent-backend/app/agent/reporting/template_engine.py - Formatters:
/opshub-agent-backend/app/agent/reporting/formatters.py - Data Aggregation:
/opshub-agent-backend/app/agent/reporting/data_aggregator.py - Narrative Generator:
/opshub-agent-backend/app/agent/reporting/narrative_generator.py