Chapter 6 : AI Agents
Build AI Agents
- Build AI Agents with No-code and Customize & Extend to complete your use case.
- Use AI Agents in workflows or as chat.
Prerequisite
- Please complete below tutorial first:
AI Agents Building
Jumpstart development with AI Agents Building 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.
 
Also available:
- Chat Agent with access to MCP Tools- A simple command-line chat application with access to EasyManage MCP Server Tools available, to chat with AI models.
 
AI Agents - Spring Java
AI Agent emagent
- Agentic System Workflows with agentic patterns Prompt-Chaining, Prallelization with access to MCP Tools
- Low-code customize to build AI solutions
AI Agent emchat
- Chat Agent with access to MCP Tools
Locating Agent Projects
info
- AI Agent - Spring Java is built along with Backend & MCP spring-java.
- Project Location in downloaded dir is at e.g.- EmGenDir_JohnDoe_WS_51069\WS_51069\agent\spring-java\emagent
 
- Chat Agent with access to MCP Tools is at e.g.- EmGenDir_JohnDoe_WS_51069\WS_51069\agent\spring-java\emchat
 
Run Builds and Explore
tip
AI Agents invoke MCP Layer which Connects to API Layer, REST or GraphQL. So please configure and run destination API Layer first. Then build MCP Layer.
AI Agent emagent
AI Agent Project Build & Run
- Go to Project Location in downloaded dir is at e.g.- cd EmGenDir_JohnDoe_WS_51069\WS_51069\agent\spring-java\emagent
 
- Set env var: OPENAI_API_KEY
- Build the project: - ./mvnw clean install
- Run the application: - ./mvnw spring-boot:run
AI Agent Example Run For Product
Prompt Chaining Workflow Example Run
List MCP Tools
2025-10-20T21:20:48.610+05:30  WARN 14068 --- [emagent_data] [           main] o.s.m.p.s.SyncMcpSamplingProvider        : No sampling methods found
2025-10-20T21:20:48.610+05:30  WARN 14068 --- [emagent_data] [           main] o.s.m.p.e.SyncMcpElicitationProvider     : No elicitation methods found
2025-10-20T21:20:52.428+05:30  INFO 14068 --- [emagent_data] [           main] c.example.emagent.app.EmAgentSpringApp   : Started EmAgentSpringApp in 5.174 seconds (process running for 5.424)
2025-10-20T21:20:52.428+05:30  INFO 14068 --- [emagent_data] [           main] c.example.emagent.app.EmAgentSpringApp   : ------- List MCP Tools Available ------------
Listed MCP Tools
- Name
Tool Name: get_table_data_customer
Tool Name: get_table_data_queried_customer
Tool Name: get_table_data_by_key_inventory
Tool Name: get_table_data_by_key_shipping
...
- Name, Description, Input Schema
Tool Name: get_table_data_customer
Tool Description: get table data from customer table
Tool Input Schema: {"type":"object","properties":{},"required":[],"additionalProperties":false}
...
Build ChatClient
2025-10-20T23:47:35.892+05:30  INFO 28280 --- [emagent_data] [           main] c.example.emagent.app.EmAgentSpringApp   : ------- Build ChatClient  ------------
2025-10-20T23:47:35.908+05:30  INFO 28280 --- [emagent_data] [           main] c.example.emagent.app.EmAgentSpringApp   : ------- Run EmAgents ------------
------------
Prompt Chaining
- When set chain
2025-10-20T23:51:18.894+05:30  INFO 35932 --- [emagent_data] [           main] c.example.emagent.app.EmAgentSpringApp   : ------- Set runPattern = [chain] ------------
2025-10-20T23:51:18.894+05:30  INFO 35932 --- [emagent_data] [           main] c.example.emagent.app.EmAgentSpringApp   : ------- Run ProductEmAgentChain ------------
Prompts List
            // Step 1 
            """ 
                    Call MCP easymanage-mcp Tool get table schema for erp_product  
                    """, 
            // Step 2 
            """ 
                    Call MCP easymanage-mcp Tool get table data from erp_product  
                    """, 
            // Step 3 
            """ 
                    You will be given erp_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. 
                     
                    # erp_product Schema 
                    %s 
 
                    # erp_product Data 
                    %s 
                    """ 
Get Table Schema Response
STEP 0:
 The table schema for the Product is as follows:
{
  "ErpProduct": {
    "type": "object",
    "properties": {
      "productId": {
        "type": "integer",
        "format": "int64"
      },
      "productName": {
        "type": "string"
      },
      "productCategory": {
        "type": "string"
      },
      "primarySupplier": {
        "type": "string"
      },
      "productDesc": {
        "type": "string"
      },
      "productPicture": {
        "type": "array",
        "items": {
          "type": "string",
          "format": "byte"
        }
      }
    }
  }
}
This schema defines the structure of the `ErpProduct` table, including the data types and properties for each field.
Get Table Data Response
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      |
Analyze For Insights Response
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!
Prompt Parallel Workflow Example Run
- When custom set Parallel in App:- Edit src\main\java\com\example\emagent\app\EmAgentSpringApp.java
- Set String runPattern = "parallel"; //chain|parallel
 
- Edit 
2025-10-20T23:47:35.908+05:30  INFO 28280 --- [emagent_data] [           main] c.example.emagent.app.EmAgentSpringApp   : ------- Set runPattern = [parallel] ------------
2025-10-20T23:47:35.908+05:30  INFO 28280 --- [emagent_data] [           main] c.example.emagent.app.EmAgentSpringApp   : ------- Run ProductEmAgentParallel ------------
- Step 1 and Step 2 are excuted in Parallel.
- Upon both completion, Step 3 is run.
AI Agent emchat
AI Agent Project Build & Run
- Go to Project Location in downloaded dir is at e.g.- cd EmGenDir_JohnDoe_WS_51069\WS_51069\agent\spring-java\emchat
 
- Set env var: OPENAI_API_KEY
- Build the project: - ./mvnw clean install
- Run the application: - ./mvnw spring-boot:run
Run Chat Example Run
Prompt & Response
Chat With AI Model:
Starting interactive chat session. Type 'exit' to quit.
USER: easymanage-mcp get table data customer
MODEL:
Here is the table data from the customer:
1. **Customer ID**: 1
   - **Customer Name**: Fortis Hospital
   - **Start Date**: Not available
2. **Customer ID**: 2
   - **Customer Name**: Manipal Hospital
   - **Start Date**: Not available
3. **Customer ID**: 3
   - **Customer Name**: Apollo Hospital
   - **Start Date**: Not available
If you need further details or assistance, feel free to ask!
USER: exit
Ending chat session.