Chapter 6 : AI Agents
Prerequisite
- Please complete below tutorial first:
AI Agents Building
Jumpstart development with AI Agents Building template code based on common patterns described in Anthropic's research paper Building Effective Agents.
The agentic system's code model agentic flows in terms of:
- Multi-LLM Workflows
- Prompt-Chaining: Decomposes a task into sequential subtasks, where each step builds on previous results.
- Parallelization: Distributes independent subtasks across multiple LLMs for concurrent processing.
tip
Low-code customize the templates for any data tables or data models to build AI solutions.
How To Build AI Agent
EasyManage: AI Agents Building templates
List Templates
- Locate generated code folder, we will refer to it as
DEST
DEST
: generated code...\resources\templates\ai-agent\spring-java
- Locate Templates as zip files
- Locate generated code folder, we will refer to it as
emagent_chain.zip
emagent_parallel.zip
README-emagent.md
AI Agent Template For | Use Zip |
---|---|
Prompt Chaining Workflow Example | emagent_chain.zip |
Parallelization Workflow Example | emagent_parallel.zip |
How To Use AI Agent Templates
- Extract zip, Low-code Customize And Use
- Please see section:
How To Use AI Agent Templates
in providedREADME-emagent.md
- Please see section:
Prompt Chaining Workflow Example Run
Example Run Response
Prompts
"""
What tools are available? Please list them and avoid any additional comments.
"""
// Step 1
"""
Call MCP easymanage-mcp Tool get table schema for Product
""",
// Step 2
"""
Call MCP easymanage-mcp Tool get table data from product table
""",
// Step 3
"""
You will be given Product table schema and data.
Analyze table schema and data for insights.
Suggest what insights and trends can be derived from tables.
Prioritize as per high-value to low-value insights.
# Product Schema
%s
# Product Data
%s
"""
Outputs & Responses
- Included are relevant parts.
2025-10-08T23:18:04.230+05:30 INFO 22192 --- [emagent] [ main] c.example.emagent.app.EmAgentSpringApp : Started EmAgentSpringApp in 4.457 seconds (process running for 4.706)
2025-10-08T23:23:09.826+05:30 INFO 22316 --- [emagent] [ main] c.example.emagent.app.EmAgentSpringApp : ------- List MCP Tools ------------
2025-10-08T23:23:09.827+05:30 INFO 22316 --- [emagent] [ main] c.example.emagent.app.EmAgentSpringApp : 1) Get Available Tools:
Tool: functions.get_table_data_customer -> get table data from customer table
Tool: functions.get_table_data_queried_customer -> get table data queried and sorted as per parameter strings as pages from customer table
Tool: functions.get_table_data_by_key_inventory -> get table data by key column from inventory table
Tool: functions.get_table_data_by_key_shipping -> get table data by key column from shipping table
Tool: functions.get_via_key_OrdersShipping5000110 -> get table join data by key column from OrdersShipping5000110 tables
Tool: functions.delete_table_data_record_shipping -> delete table data record in shipping table
Tool: functions.get_all_api_docs -> get all api docs
Tool: functions.get_table_data_queried_shipping -> get table data queried and sorted as per parameter strings as pages from shipping table
Tool: functions.get_table_data_tenant -> get table data from tenant table
Tool: functions.get_queried_OrdersShipping5000110 -> get table join data queried and sorted as per parameter strings as pages from OrdersShipping5000110 tables
Tool: functions.get_table_data_inventory -> get table data from inventory table
Tool: functions.get_table_data_by_key_customer -> get table data by key column from customer table
Tool: functions.get_table_data_by_key_product -> get table data by key column from product table
Tool: functions.get_via_key_ShippingTenant5000111 -> get table join data by key column from ShippingTenant5000111 tables
Tool: functions.get_queried_ShippingTenant5000111 -> get table join data queried and sorted as per parameter strings as pages from ShippingTenant5000111 tables
Tool: functions.create_table_data_record_shipping -> create table data record in shipping table
Tool: functions.get_table_data_product -> get table data from product table
Tool: functions.update_table_data_record_product -> update table data record in product table
Tool: functions.update_table_data_record_inventory -> update table data record in inventory table
Tool: functions.update_table_data_record_shipping -> update table data record in shipping table
Tool: functions.create_table_data_record_orders -> create table data record in orders table
Tool: functions.get_table_data_orders -> get table data from orders table
Tool: functions.delete_table_data_record_orders -> delete table data record in orders table
Tool: functions.get_table_data_queried_orders -> get table data queried and sorted as per parameter strings as pages from orders table
Tool: functions.get_via_key_OrdersShipping1Multi -> get table join data by key column from OrdersShipping1Multi tables
Tool: functions.get_table_data_by_key_orders -> get table data by key column from orders table
Tool: functions.get_table_data_queried_product -> get table data queried and sorted as per parameter strings as pages from product table
Tool: functions.create_table_data_record_inventory -> create table data record in inventory table
Tool: functions.delete_table_data_record_inventory -> delete table data record in inventory table
Tool: functions.delete_table_data_record_product -> delete table data record in product table
Tool: functions.create_table_data_record_tenant -> create table data record in tenant table
Tool: functions.update_table_data_record_tenant -> update table data record in tenant table
Tool: functions.delete_table_data_record_tenant -> delete table data record in tenant table
2025-10-08T23:18:04.233+05:30 INFO 22192 --- [emagent] [ main] c.example.emagent.app.EmAgentSpringApp : ------- Run ProductEmAgentChain ------------
STEP 1:
The table schema for the **Product** is as follows:
{
"Product": {
"type": "object",
"properties": {
"productId": {
"type": "integer",
"format": "int64"
},
"productName": {
"type": "string"
},
"productCategory": {
"type": "string"
},
"primarySupplier": {
"type": "string"
}
}
}
}
### Properties:
- **productId**: An integer representing the unique identifier for the product.
- **productName**: A string representing the name of the product.
- **productCategory**: A string representing the category of the product.
- **primarySupplier**: A string representing the primary supplier of the product.
## Schema Recap
**Product** table with fields:
- ProductID (Primary Key)
- ProductName
- Category
- Price (decimal)
- StockQuantity (int)
- CreatedAt (timestamp)
- UpdatedAt (timestamp)
STEP 2:
## Table Data
The data you gave has these fields, but actually includes a **primarySupplier** which is not in the schema (this might be metadata or from a related table), and lacks values for Price, StockQuantity, CreatedAt, UpdatedAt.
Sample data:
ProductID | ProductName | Category | PrimarySupplier |
-----------|-------------------|-----------------|-----------------|
101 | Smartphone Model X| Electronics | Supplier A |
102 | Vacuum Cleaner Pro| Home Appliances | Supplier B |
103 | Learning JSON | Books | Supplier C |
STEP 3:
## Potential High-Value to Low-Value Insights From Schema and Data
### High-Value Insights
1. **Category-wise Sales and Inventory Analysis**
- Analyze total stock quantity and average price in each category.
- Identify categories with most inventory, highest revenue potential.
- Track stock depletion rates over time for demand planning.
2. **Price Trends and Pricing Strategy**
- Price distribution across categories or within a category to detect premium vs budget products.
- Historical price changes (using CreatedAt & UpdatedAt) to assess how pricing evolves due to market or seasonality.
3. **Product Lifecycle & Freshness**
- Time since product introduction (CreatedAt) vs last update (UpdatedAt) to understand product lifecycle.
- Flag stale or outdated products for clearance or update.
4. **Stock Management & Replenishment**
- Identify low-stock products (StockQuantity near zero).
- Predict potential stock-outs by combining stock data with sales.
- Optimize inventory to reduce holding costs while avoiding lost sales.
5. **Supplier Performance & Product Sourcing**
- Although not in schema, if supplier info is available, evaluate supplier contribution to inventory and pricing.
- Correlate supplier with product updates or stock changes (if timestamps relate to restock).
---
### Medium-Value Insights
6. **Product Popularity and Demand Trends**
- Track demand changes over time via update timestamps (if updates reflect sales).
- Correlate product introduction dates with sales spike periods (e.g., holidays).
7. **Category Growth or Decline**
- Using CreatedAt frequency, identify categories seeing more new products added (growth areas).
- Conversely, categories with less new product introduction might indicate market decline or saturation.
8. **Price Elasticity Indicators**
- If price changes (UpdatedAt) can be linked to stock quantity or sales, estimate price elasticity.
---
### Lower-Value Insights
9. **Product Naming Patterns**
- Analyze naming conventions for branding consistency.
- Detect potential renaming or variant introductions.
10. **Temporal Updates and Maintenance**
- Frequency of product data updates could indicate product attention or seasonality.
---
## Summary
Priority | Insight Area | Description |
-----------------|-----------------------------------|-------------------------------------------------------------------------------------------------|
High | Category-wise Sales & Inventory | Stock and price distributions by category for revenue and inventory management |
High | Price Trends | Pricing strategies and changes over time |
High | Product Lifecycle & Freshness | Identify outdated vs newly introduced products |
High | Stock Management & Replenishment | Low-stock alerts and stock optimization |
Medium | Demand Trends and Popularity | Product demand variation over time |
Medium | Category Growth or Decline | Assess expanding or contracting product categories |
Medium | Price Elasticity Indicators | Understand customer sensitivity to price changes |
Low | Product Naming Patterns | Branding and product identification |
Low | Temporal Updates & Maintenance | Frequency and timing of product record updates |
---
If additional related data such as sales, supplier details, or reorder history is integrated, many more actionable insights could be generated (e.g., supplier reliability, forecasting, promotion effectiveness).
Let me know if you want a detailed analysis on any specific insight or suggestions on enriching the schema and data!