Agentic Application Workflow

How Maven Works: An End-to-End Workflow

Maven is an AI-powered product assistant designed to streamline the process of researching, selecting, and comparingElectroniccategorized products. This document details the complete yet simple operational workflow of Maven, from the initial user interaction to the delivery of AI-powered results.

Complete Workflow Overview
A egde-level view of Maven's end-to-end workflow process
Combined Tool Diagram Usage

Workflow

1. User Input Initiation

The workflow begins when a user interacts with Maven, providing input through one of several methods.

Text Input

The user enters a text-based query or request (e.g., “find me the best noise-canceling headphones“).

Product Attachment

The user attaches a product (represented by its ID, title, and link) to the conversation.

Product Comparison

The user requests a comparison between two products (identified by their call IDs).

Inquiry Response

The user responds to a previous inquiry from Maven, providing additional information.

PayloadData Type Definition|typescript
1export type PayloadData = {
2  textInput?: string;
3  attachProduct?: AttachProduct;
4  productCompare?: ProductCompare;
5  inquiryResponse?: InquiryResponse;
6};

2. Orchestrator Processing

The PayloadData is passed to the orchestrator function, the central control unit that manages the workflow.

1

Message Unification

The user‘s input is converted into a standardized UserContentMessage and then into a MessageProperty object, adding it to the conversation history.

2

Intent Determination

The orchestrator analyzes the user's input to determine their intent (e.g., search for a product, get product details, compare products).

3

Tool Selection

Based on the intent, the orchestrator selects the most appropriate agent tool(s) from the available options.

4

State Management

The orchestrator interacts with MutableAIState to update the conversation history and manage the AI's state.

Available Tools|typescript
1export const AvailableTools = {
2  SEARCH_PRODUCT: "searchProduct",
3  GET_PRODUCT_DETAILS: "getProductDetails",
4  PRODUCTS_COMPARISON: "productsComparison",
5  INQUIRE_USER: "inquireUser",
6  RECOMMENDATOR: "recommendator",
7} as const;

3. Agentic Tool Execution

The selected agent tool(s) are executed. Each tool performs a specific task, leveraging AI models and external APIs.

AI Product Picks (recommendator)
Provides personalized product recommendations based on user intent and scope

Input

  • User intent
  • Scope parameters

Output

  • Personalized product recommendations
  • Explanatory insights
  • Optional related queries

Process Flow

  1. Takes the user's intent and scope
  2. Generates recommendations using streamObject and the recommendationSchema
  3. Generates explanatory insights using streamText
  4. Updates the AI state
  5. Optionally generates related queries

4. State Mutation

After a tool completes, mutateTool is called to update the AI state with the results.

1

Validation (Optional)

Uses validateArgs and validateResult from ToolMutationConfig to validate input/output.

2

Transformation (Optional)

Uses transformResult to transform output before storing in the AI state.

3

State Update

Updates MutableAIState with tool results and generated messages.

4

Override Assistant (Optional)

If provided, updates the AI state with the given content.

MutationPayload Type Definition|typescript
1export type MutationPayload<ARGS, DATA> = {
2  name: AvailableTool;
3  args: ARGS;
4  result: DATA;
5  overrideAssistant?: {
6    content: string;
7  };
8};

5. UI Update and Rendering

The streamUI function generates UI components based on the AI's state.

UI Component Generation
The streamUI function generates React components to display results

AssistantMessage

ProductSearch

ProductDetails

ProductComparison

RecommendationAction

UserInquiry

RelatedMessage

ErrorMessage

UIState Type Definition|typescript
1export type UIState = {
2  id: string;
3  display: ReactNode;
4}[];

6. Error Handling

Error handling is implemented throughout the workflow to ensure robustness.

Scraping Errors
external

handleScrapingWithCache handles web scraping errors.

API Errors
external

Errors from external API calls are caught.

LLM Generation Errors
processing

Errors during text/object generation are caught.

Database Errors
data

Errors accessing the database are handled.

Input Validation Errors
user

inputInquirySchema and validation functions handle invalid input.

Stream Generation Status
StreamGeneration Type|typescript
1export type StreamGeneration = {
2  loading: boolean;
3  process:
4  "initial"
5  | "generating"
6  | "api_success"
7  | "api_error"
8  | "database_error"
9  | "fatal_error"
10  | "done"
11  | ({} & string);
12  error?: string;
13};

7. Final Output

The final output is the updated UI, presented to the user. This reflects the AI agent's processing, including generated text, product information, comparisons, recommendations, or inquiries. The user can then continue the interaction.

Final UI Rendering
The final step in Maven's workflow is rendering the UI components to the user

Complete Workflow Cycle

The user can now view the results and continue the interaction, starting a new workflow cycle.

Conclusion

This document provides a simple, technical overview of Maven's workflow. By combining user input, AI-powered tools, state management, and dynamic UI generation, Maven delivers a powerful product research experience. The modular design ensures robustness and maintainability.