Skip to content

refactor: restructure PM Analysis Agent as a LangGraph subgraph #3018

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Aug 15, 2025

Conversation

MH4GF
Copy link
Member

@MH4GF MH4GF commented Aug 15, 2025

Issue

  • resolve: N/A (refactoring)

Why is this change needed?

This refactoring restructures the PM Analysis Agent to follow the same subgraph pattern as the DB Agent, improving codebase consistency and maintainability.

Summary

  • ✅ Replace PMAnalysisAgent class with functional invokePmAnalysisAgent approach
  • ✅ Create dedicated PM Agent subgraph with createPmAgentGraph
  • ✅ Move PM Agent nodes to pm-agent/nodes directory for better organization
  • ✅ Add proper retry policies consistent with DB Agent
  • ✅ Update tests and documentation to reflect new architecture

Test plan

  • All existing tests pass
  • PM Agent functionality remains unchanged
  • Mermaid diagram in tests and README correctly reflects new structure

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features
    • Introduces a modular PM Agent that orchestrates requirements analysis and artifact saving with a unified entry point, clearer handoff to the database stage, and improved resilience via retries.
  • Documentation
    • Overhauls the workflow guide with multi-agent architecture, diagrams, and flow patterns; clarifies database subgraph behavior and integration.
  • Refactor
    • Streamlines the API and internals by replacing a class-based PM analysis with a functional approach and reducing exposed surface area.
  • Tests
    • Updates graph outputs and expectations to match the new workflow topology.

Copy link

vercel bot commented Aug 15, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
liam-app Ready Preview Comment Aug 15, 2025 2:43am
liam-storybook Ready Preview Comment Aug 15, 2025 2:43am
2 Skipped Deployments
Project Deployment Preview Comments Updated (UTC)
liam-docs ⬜️ Ignored Preview Aug 15, 2025 2:43am
liam-erd-sample ⬜️ Skipped Aug 15, 2025 2:43am

Copy link

changeset-bot bot commented Aug 15, 2025

⚠️ No Changeset found

Latest commit: 9b0d4cd

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link
Contributor

coderabbitai bot commented Aug 15, 2025

Walkthrough

Refactors the workflow into a modular multi-agent design by introducing a PM Agent subgraph and integrating it into the main graph. Removes the class-based PMAnalysisAgent, adds a functional PM analysis invoker, updates graph construction and tests, narrows public exports, and revises documentation to reflect the new PM and DB subgraph architectures.

Changes

Cohort / File(s) Summary
Docs: PM & DB multi-agent workflow
frontend/internal-packages/agent/src/chat/workflow/README.md
Rewrites architecture to introduce pmAgent subgraph, update node lists/flows, add diagrams and policies, and refine DB Agent subgraph docs.
Graph construction & tests
frontend/internal-packages/agent/src/createGraph.ts, frontend/internal-packages/agent/src/createGraph.test.ts
Replaces analyzeRequirements/invokeSaveArtifactTool nodes with single pmAgent node; routes START→pmAgent→dbAgent; updates conditional edges and Mermaid expectations.
PM Agent subgraph implementation
frontend/internal-packages/agent/src/pm-agent/createPmAgentGraph.ts, frontend/internal-packages/agent/src/pm-agent/invokePmAnalysisAgent.ts
Adds pmAgent graph builder (LangGraph subgraph with retries and routing) and functional PM analysis invoker with tool binding and reasoning extraction.
Analyze requirements node update
frontend/internal-packages/agent/src/pm-agent/nodes/analyzeRequirementsNode.ts
Switches from PMAnalysisAgent class to invokePmAnalysisAgent; adjusts imports/paths; preserves observable result shape.
Exports surface adjustments (nodes)
frontend/internal-packages/agent/src/chat/workflow/nodes/index.ts
Removes re-exports: analyzeRequirementsNode, invokeSaveArtifactToolNode; keeps other node exports.
Remove PMAnalysisAgent class and exports
frontend/internal-packages/agent/src/langchain/agents/pmAnalysisAgent/agent.ts, frontend/internal-packages/agent/src/langchain/agents/pmAnalysisAgent/index.ts, frontend/internal-packages/agent/src/langchain/agents/index.ts
Deletes PMAnalysisAgent implementation and its re-exports; leaves QAGenerateUsecaseAgent export intact.

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant pmAgent
  participant SaveArtifactTool
  participant dbAgent
  participant Usecase as generateUsecase
  participant DML as prepareDML
  participant Validate as validateSchema
  participant Finalize as finalizeArtifacts

  User->>pmAgent: Messages
  pmAgent->>pmAgent: analyzeRequirements (loop w/ retries)
  pmAgent->>SaveArtifactTool: invokeSaveArtifactTool (optional, iterative)
  pmAgent-->>dbAgent: handoff
  dbAgent->>dbAgent: designSchema / invokeSchemaDesignTool
  dbAgent-->>Usecase: continue workflow
  Usecase-->>DML: generate
  DML-->>Validate: validate
  Validate-->>Finalize: finalize
  Finalize-->>User: Result
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

Suggested labels

Review effort 4/5

Suggested reviewers

  • NoritakaIkeda
  • FunamaYukina
  • junkisai

Poem

I thump my paw—new graphs arise,
PM burrows, DB replies.
Loops of thought, then tools in play,
Hops to schema, onward sway.
Trails converge where artifacts gleam—
Carrots cached in a modular stream. 🥕✨

Tip

🔌 Remote MCP (Model Context Protocol) integration is now available!

Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch refactor-pm-agent-to-subgraph

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

supabase bot commented Aug 15, 2025

Updates to Preview Branch (refactor-pm-agent-to-subgraph) ↗︎

Deployments Status Updated
Database Fri, 15 Aug 2025 02:39:59 UTC
Services Fri, 15 Aug 2025 02:39:59 UTC
APIs Fri, 15 Aug 2025 02:39:59 UTC

Tasks are run on every commit but only new migration files are pushed.
Close and reopen this PR if you want to apply changes from existing seed or migration files.

Tasks Status Updated
Configurations Fri, 15 Aug 2025 02:40:01 UTC
Migrations Fri, 15 Aug 2025 02:40:03 UTC
Seeding Fri, 15 Aug 2025 02:40:03 UTC
Edge Functions Fri, 15 Aug 2025 02:40:03 UTC

View logs for this Workflow Run ↗︎.
Learn more about Supabase for Git ↗︎.

Copy link
Contributor

github-actions bot commented Aug 15, 2025

🤖 Agent Deep Modeling Execution

Started at: 2025-08-15 02:42:47 UTC

Command Output


> @liam-hq/agent@0.1.0 execute-deep-modeling /home/runner/work/liam/liam/frontend/internal-packages/agent
> tsx scripts/executeDeepModelingProcess.ts


✅ [INFO] 2025-08-15T02:42:50.236Z Starting Deep Modeling process execution (log level: INFO)

✅ [INFO] 2025-08-15T02:42:50.362Z Starting Deep Modeling workflow execution...

✅ [INFO] 2025-08-15T02:42:50.412Z Request: Design a business management system database with the following core requirements:

1. **Organization Structure**:
   - Hierarchical organizations with self-referencing parent-child relationships
   - Each organization has a unique code and name

2. **Position & Employee Management**:
   - Position master table with unique position codes and names
   - Employee master table with employee codes and names
   - Employee affiliations linking employees to organizations and positions
   - Support for reporting relationships (employees reporting to other employees)

3. **Business Partner System**:
   - Unified business partner table for both clients and suppliers
   - Business partner categories with CHECK constraints (CLIENT/SUPPLIER)
   - Client-specific data with order amounts from last year
   - Supplier-specific data with procurement amounts from last year

4. **Product Management**:
   - Brand master table with unique brand names
   - Item categories for product classification
   - Items with manufacturer part numbers as primary keys
   - Items linked to brands and categories
   - Supplier-brand handling relationships

Please design a normalized database schema with proper primary keys, foreign key relationships, and constraints to support these business operations effectively.

✅ [INFO] 2025-08-15T02:52:22.590Z AI response: Generated 15 use cases for testing and validation

✅ [INFO] 2025-08-15T02:54:15.119Z AI response: Generated 15 use cases for testing and validation

✅ [INFO] 2025-08-15T02:54:16.259Z AI response: Generated 15 use cases for testing and validation

✅ [INFO] 2025-08-15T02:54:54.461Z AI response: Summary of the database design workflow

Main user requirements analyzed:
- Organization hierarchy with self-referencing parent-child, unique organization code and name.
- Position and employee masters with unique codes/names; employee affiliations to orgs and positions; employee-to-employee reporting lines.
- Unified business partner master covering clients and suppliers with category enforcement (CLIENT/SUPPLIER) and last-year amounts per type.
- Product management with unique brand names, item categories, items keyed by MPN, items linked to brand/category, and supplier–brand handling relationships.

Key design decisions:
- Surrogate UUID primary keys for all masters except Items (natural PK: MPN).
- bp_category enum (CLIENT, SUPPLIER) to strictly constrain partner categories.
- Self-referencing FKs: organizations.parent_id (ON DELETE RESTRICT), employees.supervisor_id (ON DELETE SET NULL) plus a CHECK to prevent self-supervision.
- Employee affiliations as a separate link table with a composite UNIQUE (employee, organization, position) and ON DELETE CASCADE from employee.
- Partner-specific tables (client_data, supplier_data) reference business_partners via composite FK (partner_id, category) with CHECK/default to enforce correct category.
- Amount fields constrained non-negative with sensible defaults.
- UNIQUE constraints on organization_code/name, position_code/name, brand_name, item_category name; employee_code unique.
- Indexes added on common FK columns for performance.

Schemas/tables/data structures created:
- Enum: bp_category (CLIENT, SUPPLIER).
- organizations(id PK UUID, org_code UNIQUE, org_name UNIQUE, parent_id self-FK).
- positions(id PK UUID, position_code UNIQUE, position_name UNIQUE).
- employees(id PK UUID, employee_code UNIQUE, employee_name, supervisor_id self-FK, CHECK not self).
- employee_affiliations(id PK UUID, employee_id FK CASCADE, organization_id FK, position_id FK, UNIQUE(employee_id, organization_id, position_id)).
- business_partners(id PK UUID, partner_name, category bp_category, UNIQUE(id, category)).
- client_data(partner_id PK/FK, category default/CK CLIENT, last_year_order_amount numeric >= 0).
- supplier_data(partner_id PK/FK, category default/CK SUPPLIER, last_year_procurement_amount numeric >= 0).
- brands(id PK UUID, brand_name UNIQUE).
- item_categories(id PK UUID, category_name UNIQUE).
- items(mpn PK, brand_id FK, category_id FK).
- supplier_brand_handling(partner_id, brand_id composite PK, category default/CK SUPPLIER, FKs to business_partners and brands).
- Indexes on key FKs: org parent_id, employee supervisor_id, affiliations FKs, items.brand_id/category_id, supplier_brand_handling.brand_id.

Important outcomes/results:
- Requirements captured and saved to artifact.
- Initial DDL CHECK syntax issue identified and fixed; final DDL validated successfully and applied.
- A normalized schema (up to 3NF) with full referential integrity, constraints, and indexes delivered.
- 15 use cases generated for testing and validation.

✅ [INFO] 2025-08-15T02:54:54.463Z Deep Modeling workflow completed successfully

✅ [INFO] 2025-08-15T02:54:54.463Z Workflow Messages:

✅ [INFO] 2025-08-15T02:54:54.463Z   1. [human] Design a business management system database with the following core requirements:

1. **Organization Structure**:
   - Hierarchical organizations with self-referencing parent-child relationships
   -...

✅ [INFO] 2025-08-15T02:54:54.463Z   2. [ai] Planned steps:
- Clarify and structure the user's stated needs into business-focused, testable requirements.
- Organize requirements into categories reflecting core business domains.
- Specify keys, r...

✅ [INFO] 2025-08-15T02:54:54.464Z   3. [tool] Requirements saved successfully to artifact

✅ [INFO] 2025-08-15T02:54:54.464Z   4. [ai] Requirements analysis complete and saved to artifact.

✅ [INFO] 2025-08-15T02:54:54.464Z   5. [ai] Purpose: Create a normalized schema for organizations, positions, employees, business partners, products, and related relationships; inputs: enum and table definitions with primary keys, unique constr...

❌ [ERROR] 2025-08-15T02:54:54.464Z   6. [tool] Error: DDL execution validation failed: SQL: CREATE TYPE "bp_category" AS ENUM ('CLIENT', 'SUPPLIER');

COMMENT ON TYPE "bp_category" IS 'Business partner category enumeration';

CREATE TABLE "organiz...

✅ [INFO] 2025-08-15T02:54:54.464Z   7. [ai] Purpose: Create the complete normalized schema (tables, enums, constraints, indexes) for the business management system; minimal inputs: definitions for enums, tables with columns, PKs, FKs, UNIQUEs, ...

✅ [INFO] 2025-08-15T02:54:54.464Z   8. [tool] Schema successfully updated. The operations have been applied to the database schema, DDL validation successful (98/98 statements executed successfully), and new version created.

✅ [INFO] 2025-08-15T02:54:54.464Z   9. [ai] Checklist:
- Create enum and master tables with required unique constraints.
- Define self-referencing keys for organizations and employee reporting.
- Add affiliation and relationship tables with com...

✅ [INFO] 2025-08-15T02:54:54.464Z   10. [ai] Generated 15 use cases for testing and validation

✅ [INFO] 2025-08-15T02:54:54.464Z   11. [ai] Summary of the database design workflow

Main user requirements analyzed:
- Organization hierarchy with self-referencing parent-child, unique organization code and name.
- Position and employee master...

✅ [INFO] 2025-08-15T02:54:54.464Z RESULT: 11 tables created - organizations, employees, employee_affiliations, items, supplier_brand_handling, positions, business_partners, client_data, supplier_data, brands, item_categories

Status: Completed successfully

Finished at: 2025-08-15 02:54:54 UTC

@vercel vercel bot temporarily deployed to Preview – liam-erd-sample August 15, 2025 01:43 Inactive
@MH4GF MH4GF marked this pull request as ready for review August 15, 2025 02:09
@Copilot Copilot AI review requested due to automatic review settings August 15, 2025 02:09
@MH4GF MH4GF requested a review from a team as a code owner August 15, 2025 02:09
@MH4GF MH4GF requested review from hoshinotsuyoshi, FunamaYukina, junkisai and NoritakaIkeda and removed request for a team August 15, 2025 02:09
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR refactors the PM Analysis Agent from a class-based approach to a functional LangGraph subgraph pattern, aligning it with the existing DB Agent architecture for better consistency and maintainability.

  • Replaced PMAnalysisAgent class with functional invokePmAnalysisAgent approach
  • Created dedicated PM Agent subgraph with proper node organization
  • Updated file structure by moving PM Agent nodes to dedicated directory

Reviewed Changes

Copilot reviewed 10 out of 11 changed files in this pull request and generated no comments.

Show a summary per file
File Description
frontend/internal-packages/agent/src/pm-agent/nodes/analyzeRequirementsNode.ts Updated imports and replaced PMAnalysisAgent class usage with invokePmAnalysisAgent function
frontend/internal-packages/agent/src/pm-agent/invokePmAnalysisAgent.ts New functional implementation of PM analysis logic, replacing the class-based approach
frontend/internal-packages/agent/src/pm-agent/createPmAgentGraph.ts New subgraph creation function with retry policies and node configuration
frontend/internal-packages/agent/src/langchain/agents/pmAnalysisAgent/index.ts Removed export of deprecated PMAnalysisAgent class
frontend/internal-packages/agent/src/langchain/agents/pmAnalysisAgent/agent.ts Deleted PMAnalysisAgent class implementation
frontend/internal-packages/agent/src/langchain/agents/index.ts Removed PMAnalysisAgent export from agents index
frontend/internal-packages/agent/src/createGraph.ts Integrated PM Agent subgraph into main graph structure
frontend/internal-packages/agent/src/createGraph.test.ts Updated test expectations to reflect new subgraph structure
frontend/internal-packages/agent/src/chat/workflow/nodes/index.ts Removed exports of PM agent nodes from workflow nodes
frontend/internal-packages/agent/src/chat/workflow/README.md Updated documentation to reflect new PM Agent subgraph architecture

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🔭 Outside diff range comments (1)
frontend/internal-packages/agent/src/chat/workflow/README.md (1)

186-189: Make edge logic reflect subgraph encapsulation and unify node names.

The README mixes top-level edge language with internal subgraph node names: the file documents invokeSaveArtifactTool / saveRequirementsToArtifactTool but the conditional bullets use saveRequirementToArtifact. Please scope edges to the pmAgent subgraph and use consistent node/tool names.

Locations to update:

  • frontend/internal-packages/agent/src/chat/workflow/README.md — Nodes list (≈lines 74–78)
  • Node graph/flow (≈lines 92–100)
  • invokeSaveArtifactTool node section (≈lines 113–117) — shows "Performed by: saveRequirementsToArtifactTool"
  • Conditional Edge Logic block (≈lines 184–189) — currently inconsistent

Proposed replacement diff for the Conditional Edge Logic bullets:

- **analyzeRequirements**: Routes to `saveRequirementToArtifact` when requirements are successfully analyzed, retries `analyzeRequirements` with retry count tracking (max 3 attempts), fallback to `finalizeArtifacts` when max retries exceeded
- **saveRequirementToArtifact**: Always routes to `dbAgent` after processing artifacts (workflow termination node pattern)
+ **pmAgent**: Internally routes between `analyzeRequirements` and `invokeSaveArtifactTool`. On successful analysis it persists artifacts via the `saveRequirementsToArtifactTool`; it retries `analyzeRequirements` up to 3 attempts. On max retries/critical error, control flows to `finalizeArtifacts`.
+ **invokeSaveArtifactTool (internal)**: After saving, the subgraph exits and the main workflow proceeds to `dbAgent`.
 - **dbAgent**: DB Agent subgraph handles internal routing between designSchema and invokeSchemaDesignTool nodes, routes to `generateUsecase` on completion
 - **validateSchema**: Routes to `finalizeArtifacts` on success, `dbAgent` on validation error

Please apply the naming consistently (use invokeSaveArtifactTool for the node and saveRequirementsToArtifactTool for the performer) and ensure the diagram/flow text reflects subgraph encapsulation.

🧹 Nitpick comments (5)
frontend/internal-packages/agent/src/createGraph.test.ts (1)

30-36: Test asserts the generated graph exactly matches the expected diagram.

Looks good and deterministic for this graph. If you ever see flaky failures due to whitespace differences from upstream LangGraph changes, consider trimming both sides before comparison.

frontend/internal-packages/agent/src/pm-agent/invokePmAnalysisAgent.ts (1)

52-56: Guard against missing additional_kwargs to avoid runtime TypeError.

Accessing response.additional_kwargs['reasoning'] can throw if additional_kwargs is undefined. Optional chaining is safer and keeps behavior (safeParse will just fail and return null reasoning).

-    const parsedReasoning = v.safeParse(
-      reasoningSchema,
-      response.additional_kwargs['reasoning'],
-    )
+    const parsedReasoning = v.safeParse(
+      reasoningSchema,
+      response.additional_kwargs?.['reasoning'],
+    )
frontend/internal-packages/agent/src/chat/workflow/README.md (3)

76-82: Tighten node descriptions and fix minor grammar.

Clarify “performed by dbAgent” (tautological) and fix “to database” → “to the database”.

-2. **dbAgent**: DB Agent subgraph that handles database schema design - contains designSchema and invokeSchemaDesignTool nodes (performed by dbAgent)
+2. **dbAgent**: DB Agent subgraph for database schema design — internal nodes: designSchema and invokeSchemaDesignTool
...
-6. **finalizeArtifacts**: Generates and saves comprehensive artifacts to database, handles error timeline items (performed by dbAgentArtifactGen)
+6. **finalizeArtifacts**: Generates and saves comprehensive artifacts to the database, and handles error timeline items (performed by dbAgentArtifactGen)

92-103: Replace hard tabs with spaces in PM Agent subgraph diagram (MD010).

Same lint concern as the top-level diagram; use spaces for consistent rendering.

-	__start__([<p>__start__</p>]):::first
-	analyzeRequirements(analyzeRequirements)
-	invokeSaveArtifactTool(invokeSaveArtifactTool)
-	__end__([<p>__end__</p>]):::last
-	__start__ --> analyzeRequirements;
-	invokeSaveArtifactTool --> analyzeRequirements;
-	analyzeRequirements -.-> invokeSaveArtifactTool;
-	analyzeRequirements -.-> __end__;
-	classDef default fill:#f2f0ff,line-height:1.2;
-	classDef first fill-opacity:0;
-	classDef last fill:#bfb6fc;
+  __start__([<p>__start__</p>]):::first
+  analyzeRequirements(analyzeRequirements)
+  invokeSaveArtifactTool(invokeSaveArtifactTool)
+  __end__([<p>__end__</p>]):::last
+  __start__ --> analyzeRequirements;
+  invokeSaveArtifactTool --> analyzeRequirements;
+  analyzeRequirements -.-> invokeSaveArtifactTool;
+  analyzeRequirements -.-> __end__;
+  classDef default fill:#f2f0ff,line-height:1.2;
+  classDef first fill-opacity:0;
+  classDef last fill:#bfb6fc;

107-118: Align terminology with the refactor (functional API) and fix minor grammar.

Replace class-based phrasing and model/version mention with the new functional API; clarify database phrasing.

 #### 1. analyzeRequirements Node
 - **Purpose**: Analyzes and structures user requirements into BRDs
-- **Performed by**: PM Analysis Agent with GPT-5
+- **Performed by**: invokePmAnalysisAgent (functional API)
 - **Retry Policy**: maxAttempts: 3 (internal to subgraph)
 - **Timeline Sync**: Automatic message synchronization
 ...
 #### 2. invokeSaveArtifactTool Node
-- **Purpose**: Saves analyzed requirements as artifacts to database
-- **Performed by**: saveRequirementsToArtifactTool
+- **Purpose**: Saves analyzed requirements as artifacts to the database
+- **Performed by**: saveRequirementsToArtifactTool (tool)
 - **Retry Policy**: maxAttempts: 3 (internal to subgraph)
 - **Tool Integration**: Direct database artifact storage
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between c6eeb83 and b9b1c47.

📒 Files selected for processing (10)
  • frontend/internal-packages/agent/src/chat/workflow/README.md (2 hunks)
  • frontend/internal-packages/agent/src/chat/workflow/nodes/index.ts (0 hunks)
  • frontend/internal-packages/agent/src/createGraph.test.ts (1 hunks)
  • frontend/internal-packages/agent/src/createGraph.ts (3 hunks)
  • frontend/internal-packages/agent/src/langchain/agents/index.ts (0 hunks)
  • frontend/internal-packages/agent/src/langchain/agents/pmAnalysisAgent/agent.ts (0 hunks)
  • frontend/internal-packages/agent/src/langchain/agents/pmAnalysisAgent/index.ts (0 hunks)
  • frontend/internal-packages/agent/src/pm-agent/createPmAgentGraph.ts (1 hunks)
  • frontend/internal-packages/agent/src/pm-agent/invokePmAnalysisAgent.ts (1 hunks)
  • frontend/internal-packages/agent/src/pm-agent/nodes/analyzeRequirementsNode.ts (2 hunks)
💤 Files with no reviewable changes (4)
  • frontend/internal-packages/agent/src/langchain/agents/pmAnalysisAgent/index.ts
  • frontend/internal-packages/agent/src/langchain/agents/index.ts
  • frontend/internal-packages/agent/src/chat/workflow/nodes/index.ts
  • frontend/internal-packages/agent/src/langchain/agents/pmAnalysisAgent/agent.ts
🧰 Additional context used
📓 Path-based instructions (3)
**/*.{ts,tsx}

📄 CodeRabbit Inference Engine (.cursorrules)

**/*.{ts,tsx}: Use TypeScript for all components and functions.
Use runtime type validation with valibot for API responses and external data.
Use early returns whenever possible to make the code more readable.
Use descriptive variable and function/const names. Also, event functions should be named with a "handle" prefix, like "handleClick" for onClick and "handleKeyDown" for onKeyDown.
Use consts instead of functions, for example, "const toggle = () =>". Also, define a type if possible.
Follow the tsconfig.json paths settings and always use the correct alias for import paths.
Avoid using default export; always use named export.
Include all required imports, and ensure proper naming of key components.

**/*.{ts,tsx}: Use TypeScript for all components and functions.
Avoid using type assertions (as keyword) in TypeScript code.
Use runtime type validation with valibot instead of type assertions for API responses and external data.
Use type predicates or instanceof checks for DOM element type narrowing.
Follow the tsconfig.json paths settings and always use the correct alias for import paths.
Avoid wrapping standard Supabase.js calls in try-catch blocks unnecessarily; check the error property instead.

**/*.{ts,tsx}: Use runtime type validation with valibot for external data validation
Use early returns for readability
Follow existing import patterns and tsconfig paths
Use consts instead of functions for declarations (e.g., const toggle = () => {})

Files:

  • frontend/internal-packages/agent/src/pm-agent/createPmAgentGraph.ts
  • frontend/internal-packages/agent/src/pm-agent/nodes/analyzeRequirementsNode.ts
  • frontend/internal-packages/agent/src/createGraph.test.ts
  • frontend/internal-packages/agent/src/pm-agent/invokePmAnalysisAgent.ts
  • frontend/internal-packages/agent/src/createGraph.ts
**/*.{ts,tsx,js,jsx}

📄 CodeRabbit Inference Engine (.clinerules/general.md)

**/*.{ts,tsx,js,jsx}: Use early returns whenever possible to make the code more readable.
Use descriptive variable and function/const names. Event functions should be named with a 'handle' prefix, like 'handleClick' for onClick and 'handleKeyDown' for onKeyDown.
Use consts instead of functions (e.g., 'const toggle = () =>'), and define a type if possible.
Avoid using default export; always use named export.

Files:

  • frontend/internal-packages/agent/src/pm-agent/createPmAgentGraph.ts
  • frontend/internal-packages/agent/src/pm-agent/nodes/analyzeRequirementsNode.ts
  • frontend/internal-packages/agent/src/createGraph.test.ts
  • frontend/internal-packages/agent/src/pm-agent/invokePmAnalysisAgent.ts
  • frontend/internal-packages/agent/src/createGraph.ts
frontend/**/*.{ts,tsx}

📄 CodeRabbit Inference Engine (CLAUDE.md)

Use named exports only (no default exports)

Files:

  • frontend/internal-packages/agent/src/pm-agent/createPmAgentGraph.ts
  • frontend/internal-packages/agent/src/pm-agent/nodes/analyzeRequirementsNode.ts
  • frontend/internal-packages/agent/src/createGraph.test.ts
  • frontend/internal-packages/agent/src/pm-agent/invokePmAnalysisAgent.ts
  • frontend/internal-packages/agent/src/createGraph.ts
🧠 Learnings (1)
📚 Learning: 2025-08-06T08:16:37.158Z
Learnt from: MH4GF
PR: liam-hq/liam#2926
File: frontend/internal-packages/agent/scripts/executeDesignProcess.ts:42-48
Timestamp: 2025-08-06T08:16:37.158Z
Learning: In frontend/internal-packages/agent/scripts/executeDesignProcess.ts, the checkpointer is intentionally not passed to createDbAgentGraph() because this is scaffolding work - the checkpoint functionality hasn't been implemented yet and will be done in future PRs.

Applied to files:

  • frontend/internal-packages/agent/src/pm-agent/createPmAgentGraph.ts
  • frontend/internal-packages/agent/src/createGraph.test.ts
  • frontend/internal-packages/agent/src/createGraph.ts
🧬 Code Graph Analysis (4)
frontend/internal-packages/agent/src/pm-agent/createPmAgentGraph.ts (5)
frontend/internal-packages/agent/src/shared/errorHandling.ts (1)
  • RETRY_POLICY (22-32)
frontend/internal-packages/agent/src/chat/workflow/shared/langGraphUtils.ts (1)
  • createAnnotations (29-63)
frontend/internal-packages/agent/src/pm-agent/nodes/analyzeRequirementsNode.ts (1)
  • analyzeRequirementsNode (13-62)
frontend/internal-packages/agent/src/pm-agent/nodes/invokeSaveArtifactToolNode.ts (1)
  • invokeSaveArtifactToolNode (10-22)
frontend/internal-packages/agent/src/pm-agent/routing/routeAfterAnalyzeRequirements.ts (1)
  • routeAfterAnalyzeRequirements (8-20)
frontend/internal-packages/agent/src/pm-agent/nodes/analyzeRequirementsNode.ts (1)
frontend/internal-packages/agent/src/pm-agent/invokePmAnalysisAgent.ts (1)
  • invokePmAnalysisAgent (25-63)
frontend/internal-packages/agent/src/pm-agent/invokePmAnalysisAgent.ts (7)
frontend/internal-packages/agent/src/langchain/utils/types.ts (1)
  • Reasoning (8-8)
frontend/internal-packages/agent/src/chat/workflow/types.ts (1)
  • WorkflowConfigurable (42-48)
frontend/internal-packages/agent/src/utils/messageCleanup.ts (1)
  • removeReasoningFromMessages (60-64)
frontend/internal-packages/agent/src/pm-agent/prompts/pmAnalysisPrompts.ts (1)
  • PM_ANALYSIS_SYSTEM_MESSAGE (5-91)
frontend/internal-packages/agent/src/pm-agent/tools/saveRequirementsToArtifactTool.ts (1)
  • saveRequirementsToArtifactTool (117-183)
frontend/internal-packages/agent/src/langchain/utils/schema.ts (1)
  • reasoningSchema (3-11)
frontend/internal-packages/agent/src/langchain/agents/pmAnalysisAgent/agent.ts (1)
  • PMAnalysisAgent (21-65)
frontend/internal-packages/agent/src/createGraph.ts (2)
frontend/internal-packages/agent/src/pm-agent/createPmAgentGraph.ts (1)
  • createPmAgentGraph (25-47)
frontend/internal-packages/agent/src/db-agent/createDbAgentGraph.ts (1)
  • createDbAgentGraph (25-47)
🪛 markdownlint-cli2 (0.17.2)
frontend/internal-packages/agent/src/chat/workflow/README.md

11-11: Hard tabs
Column: 1

(MD010, no-hard-tabs)


12-12: Hard tabs
Column: 1

(MD010, no-hard-tabs)


13-13: Hard tabs
Column: 1

(MD010, no-hard-tabs)


14-14: Hard tabs
Column: 1

(MD010, no-hard-tabs)


15-15: Hard tabs
Column: 1

(MD010, no-hard-tabs)


16-16: Hard tabs
Column: 1

(MD010, no-hard-tabs)


17-17: Hard tabs
Column: 1

(MD010, no-hard-tabs)


18-18: Hard tabs
Column: 1

(MD010, no-hard-tabs)


19-19: Hard tabs
Column: 1

(MD010, no-hard-tabs)


20-20: Hard tabs
Column: 1

(MD010, no-hard-tabs)


21-21: Hard tabs
Column: 1

(MD010, no-hard-tabs)


22-22: Hard tabs
Column: 1

(MD010, no-hard-tabs)


92-92: Hard tabs
Column: 1

(MD010, no-hard-tabs)


93-93: Hard tabs
Column: 1

(MD010, no-hard-tabs)


94-94: Hard tabs
Column: 1

(MD010, no-hard-tabs)


95-95: Hard tabs
Column: 1

(MD010, no-hard-tabs)


96-96: Hard tabs
Column: 1

(MD010, no-hard-tabs)


97-97: Hard tabs
Column: 1

(MD010, no-hard-tabs)


98-98: Hard tabs
Column: 1

(MD010, no-hard-tabs)


99-99: Hard tabs
Column: 1

(MD010, no-hard-tabs)


100-100: Hard tabs
Column: 1

(MD010, no-hard-tabs)


101-101: Hard tabs
Column: 1

(MD010, no-hard-tabs)


102-102: Hard tabs
Column: 1

(MD010, no-hard-tabs)

🪛 LanguageTool
frontend/internal-packages/agent/src/chat/workflow/README.md

[grammar] ~81-~81: There might be a mistake here.
Context: ...rates and saves comprehensive artifacts to database, handles error timeline items ...

(QB_NEW_EN)


[grammar] ~107-~107: There might be a mistake here.
Context: ...onents #### 1. analyzeRequirements Node - Purpose: Analyzes and structures user ...

(QB_NEW_EN)


[grammar] ~109-~109: There might be a mistake here.
Context: ...ormed by**: PM Analysis Agent with GPT-5 - Retry Policy: maxAttempts: 3 (internal...

(QB_NEW_EN)


[grammar] ~110-~110: There might be a mistake here.
Context: ...*: maxAttempts: 3 (internal to subgraph) - Timeline Sync: Automatic message synch...

(QB_NEW_EN)


[grammar] ~113-~113: There might be a mistake here.
Context: ...ion #### 2. invokeSaveArtifactTool Node - Purpose: Saves analyzed requirements a...

(QB_NEW_EN)


[grammar] ~114-~114: There might be a mistake here.
Context: ...aves analyzed requirements as artifacts to database - Performed by: saveRequir...

(QB_NEW_EN)


[grammar] ~115-~115: There might be a mistake here.
Context: ...med by**: saveRequirementsToArtifactTool - Retry Policy: maxAttempts: 3 (internal...

(QB_NEW_EN)


[grammar] ~116-~116: There might be a mistake here.
Context: ...*: maxAttempts: 3 (internal to subgraph) - Tool Integration: Direct database arti...

(QB_NEW_EN)


[grammar] ~121-~121: There might be a mistake here.
Context: ...(when requirements are fully analyzed) 2. **Iterative Saving**:START → analyzeRequ...

(QB_NEW_EN)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: Supabase Preview
  • GitHub Check: Supabase Preview
🔇 Additional comments (13)
frontend/internal-packages/agent/src/createGraph.test.ts (2)

10-22: Mermaid diagram update aligns with new PM Agent subgraph.

The replacement of analyzeRequirements/invokeSaveArtifactTool with a single pmAgent node and the updated edges (START → pmAgent, pmAgent → dbAgent) look correct and consistent with the new architecture.


39-44: README diagram consistency check is helpful.

Asserting the README contains the expected Mermaid block ensures documentation stays honest with the code.

frontend/internal-packages/agent/src/pm-agent/nodes/analyzeRequirementsNode.ts (3)

34-37: Refactor to functional invokePmAnalysisAgent is clean and improves testability.

Dropping the PMAnalysisAgent class usage for a pure function call is simpler and keeps the node lean. Error handling and configuration extraction remain intact.


58-61: Confirm intent to replace messages array with only the latest AI response.

Setting messages: [response] discards prior conversation context. This is fine if downstream routing (e.g., routeAfterAnalyzeRequirements) only needs the last AI message, but it will prevent accumulation/history within the subgraph.

If you intended to preserve history, change to appending:

-  return {
-    ...state,
-    messages: [response],
-  }
+  return {
+    ...state,
+    messages: [...state.messages, response],
+  }

18-26: Configurable extraction and error mapping are handled correctly.

Good use of getConfigurable and WorkflowTerminationError to halt on bad configuration early.

frontend/internal-packages/agent/src/createGraph.ts (3)

22-27: Embedding pmAgent as a subgraph keeps the top-level workflow concise.

The composition pattern mirrors the DB Agent and improves modularity. Node naming is consistent with the tests and README.


41-46: Start and wiring updates are correct.

START → pmAgent → dbAgent, then dbAgent → generateUsecase → prepareDML → validateSchema preserves the existing flow order with the new PM Agent entry point.


20-24: Verify checkpointer usage across nested graphs.

You pass the same checkpointer into both subgraphs and also compile the top-level graph with it. Depending on LangGraph internals, double-wiring the same checkpointer may be redundant or could lead to unexpected state behavior.

If the intended design is a single checkpointer at the root, consider compiling subgraphs without a checkpointer and only supplying it at the top level.

frontend/internal-packages/agent/src/pm-agent/createPmAgentGraph.ts (2)

37-42: Verify exit condition mapping from subgraph to parent.

Routing 'dbAgent' → END within the subgraph is correct if the parent graph always connects pmAgent → dbAgent, which it does. Just ensure no other parent edges assume internal pmAgent states.


29-35: Node registration with retry policy looks good.

Once unified with shared RETRY_POLICY, this will mirror DB Agent’s resilience profile.

frontend/internal-packages/agent/src/pm-agent/invokePmAnalysisAgent.ts (2)

25-63: Solid functional API with valibot validation and neverthrow ResultAsync.

  • Good practice removing prior reasoning from messages and adding a domain-specific system prompt.
  • Tools are bound explicitly; response parsing via valibot safeParse avoids throwing.
  • Returning ResultAsync<AnalysisWithReasoning, Error> integrates cleanly with node error handling.

41-46: Tool binding config is explicit and consistent with prior agent behavior.

parallel_tool_calls: false and tool_choice: 'required' match the intent to force a single, explicit tool call path when needed.

frontend/internal-packages/agent/src/chat/workflow/README.md (1)

121-122: PM Agent flow patterns read clearly and match the subgraph diagram.

No issues spotted.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

♻️ Duplicate comments (1)
frontend/internal-packages/agent/src/pm-agent/createPmAgentGraph.ts (1)

4-4: Shared RETRY_POLICY import aligned with DB Agent — LGTM

Switching to the shared RETRY_POLICY resolves the prior inconsistency and ensures WorkflowTerminationError is not retried, matching DB Agent behavior.

🧹 Nitpick comments (1)
frontend/internal-packages/agent/src/pm-agent/createPmAgentGraph.ts (1)

20-21: Nit: prefer lower camelCase for variables

ChatStateAnnotation is a value, not a type. Using lower camelCase avoids type/value naming ambiguity.

Apply:

-  const ChatStateAnnotation = createAnnotations()
-  const pmAgentGraph = new StateGraph(ChatStateAnnotation)
+  const chatStateAnnotation = createAnnotations()
+  const pmAgentGraph = new StateGraph(chatStateAnnotation)
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between b9b1c47 and 1ab66ea.

📒 Files selected for processing (1)
  • frontend/internal-packages/agent/src/pm-agent/createPmAgentGraph.ts (1 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
**/*.{ts,tsx}

📄 CodeRabbit Inference Engine (.cursorrules)

**/*.{ts,tsx}: Use TypeScript for all components and functions.
Use runtime type validation with valibot for API responses and external data.
Use early returns whenever possible to make the code more readable.
Use descriptive variable and function/const names. Also, event functions should be named with a "handle" prefix, like "handleClick" for onClick and "handleKeyDown" for onKeyDown.
Use consts instead of functions, for example, "const toggle = () =>". Also, define a type if possible.
Follow the tsconfig.json paths settings and always use the correct alias for import paths.
Avoid using default export; always use named export.
Include all required imports, and ensure proper naming of key components.

**/*.{ts,tsx}: Use TypeScript for all components and functions.
Avoid using type assertions (as keyword) in TypeScript code.
Use runtime type validation with valibot instead of type assertions for API responses and external data.
Use type predicates or instanceof checks for DOM element type narrowing.
Follow the tsconfig.json paths settings and always use the correct alias for import paths.
Avoid wrapping standard Supabase.js calls in try-catch blocks unnecessarily; check the error property instead.

**/*.{ts,tsx}: Use runtime type validation with valibot for external data validation
Use early returns for readability
Follow existing import patterns and tsconfig paths
Use consts instead of functions for declarations (e.g., const toggle = () => {})

Files:

  • frontend/internal-packages/agent/src/pm-agent/createPmAgentGraph.ts
**/*.{ts,tsx,js,jsx}

📄 CodeRabbit Inference Engine (.clinerules/general.md)

**/*.{ts,tsx,js,jsx}: Use early returns whenever possible to make the code more readable.
Use descriptive variable and function/const names. Event functions should be named with a 'handle' prefix, like 'handleClick' for onClick and 'handleKeyDown' for onKeyDown.
Use consts instead of functions (e.g., 'const toggle = () =>'), and define a type if possible.
Avoid using default export; always use named export.

Files:

  • frontend/internal-packages/agent/src/pm-agent/createPmAgentGraph.ts
frontend/**/*.{ts,tsx}

📄 CodeRabbit Inference Engine (CLAUDE.md)

Use named exports only (no default exports)

Files:

  • frontend/internal-packages/agent/src/pm-agent/createPmAgentGraph.ts
🧠 Learnings (2)
📓 Common learnings
Learnt from: MH4GF
PR: liam-hq/liam#3018
File: frontend/internal-packages/agent/src/chat/workflow/README.md:11-22
Timestamp: 2025-08-15T02:21:21.491Z
Learning: In the LIAM codebase, Mermaid diagrams in README files (particularly in frontend/internal-packages/agent/src/chat/workflow/README.md) are automatically generated by LangGraph. These diagrams should not be manually edited as it would corrupt the output. Formatting issues like hard tabs (MD010) in these auto-generated Mermaid blocks should not be flagged in code reviews.
📚 Learning: 2025-08-06T08:16:37.158Z
Learnt from: MH4GF
PR: liam-hq/liam#2926
File: frontend/internal-packages/agent/scripts/executeDesignProcess.ts:42-48
Timestamp: 2025-08-06T08:16:37.158Z
Learning: In frontend/internal-packages/agent/scripts/executeDesignProcess.ts, the checkpointer is intentionally not passed to createDbAgentGraph() because this is scaffolding work - the checkpoint functionality hasn't been implemented yet and will be done in future PRs.

Applied to files:

  • frontend/internal-packages/agent/src/pm-agent/createPmAgentGraph.ts
🧬 Code Graph Analysis (1)
frontend/internal-packages/agent/src/pm-agent/createPmAgentGraph.ts (5)
frontend/internal-packages/agent/src/chat/workflow/shared/langGraphUtils.ts (1)
  • createAnnotations (29-63)
frontend/internal-packages/agent/src/pm-agent/nodes/analyzeRequirementsNode.ts (1)
  • analyzeRequirementsNode (13-62)
frontend/internal-packages/agent/src/shared/errorHandling.ts (1)
  • RETRY_POLICY (22-32)
frontend/internal-packages/agent/src/pm-agent/nodes/invokeSaveArtifactToolNode.ts (1)
  • invokeSaveArtifactToolNode (10-22)
frontend/internal-packages/agent/src/pm-agent/routing/routeAfterAnalyzeRequirements.ts (1)
  • routeAfterAnalyzeRequirements (8-20)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (6)
  • GitHub Check: Supabase Preview
  • GitHub Check: frontend-lint
  • GitHub Check: frontend-ci
  • GitHub Check: codeql / languages (javascript) / Perform CodeQL for javascript
  • GitHub Check: agent-deep-modeling
  • GitHub Check: Supabase Preview
🔇 Additional comments (3)
frontend/internal-packages/agent/src/pm-agent/createPmAgentGraph.ts (3)

23-29: Consistent retryPolicy on both nodes — LGTM

Both analyzeRequirements and invokeSaveArtifactTool nodes now uniformly use the shared retry policy.


31-36: Conditional routing looks correct

Mapping 'dbAgent' to END is appropriate for a subgraph and matches routeAfterAnalyzeRequirements return values. This lets the parent graph wire pmAgent → dbAgent cleanly.


19-21: No change needed — PM and DB subgraphs already use the same optional checkpointer pattern

Both subgraphs accept an optional BaseCheckpointSaver and the top-level graph passes the parent checkpointer into each — so the parity concern is incorrect.

  • frontend/internal-packages/agent/src/pm-agent/createPmAgentGraph.ts — accepts checkpointer and returns: checkpointer ? pmAgentGraph.compile({ checkpointer }) : pmAgentGraph.compile()
  • frontend/internal-packages/agent/src/db-agent/createDbAgentGraph.ts — same pattern: checkpointer ? dbAgentGraph.compile({ checkpointer }) : dbAgentGraph.compile()
  • frontend/internal-packages/agent/src/createGraph.ts — passes checkpointer into both subgraphs (createPmAgentGraph(checkpointer), createDbAgentGraph(checkpointer)) and compiles the top-level graph with it (return checkpointer ? graph.compile({ checkpointer }) : graph.compile())

Action: ignore the suggested diff — no changes required here.

Likely an incorrect or invalid review comment.

MH4GF and others added 2 commits August 15, 2025 11:37
- Replace PMAnalysisAgent class with functional invokePmAnalysisAgent
- Create dedicated PM Agent subgraph with createPmAgentGraph
- Move PM Agent nodes to pm-agent/nodes directory for better organization
- Add proper retry policies for PM Agent nodes
- Simplify main graph by using PM Agent as a subgraph
- Update tests and documentation to reflect new architecture

This change aligns the PM Agent architecture with the DB Agent pattern,
making the codebase more consistent and maintainable.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
…solution

The tool_choice: 'required' configuration from PR #3013 was accidentally
removed during the refactoring. This commit restores it to ensure
the PM Analysis Agent always uses tools as intended.
Remove local RETRY_POLICY definition and import shared version from
errorHandling module to align with DB Agent and ensure consistent
retry behavior including WorkflowTerminationError handling.

Co-authored-by: Hirotaka Miyagi <MH4GF@users.noreply.github.com>
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (3)
frontend/internal-packages/agent/src/chat/workflow/README.md (3)

76-82: Minor grammar/polish in Nodes list

Tighten phrasing in the finalizeArtifacts description.

Apply this diff:

-6. **finalizeArtifacts**: Generates and saves comprehensive artifacts to database, handles error timeline items (performed by dbAgentArtifactGen)
+6. **finalizeArtifacts**: Generates and saves comprehensive artifacts to the database; handles error timeline items (performed by dbAgentArtifactGen)

105-118: Avoid hard-coding a specific model in docs ("GPT-5")

Model names change; keeping it generic reduces future doc churn and vendor lock-in signals.

Apply this diff:

-- **Performed by**: PM Analysis Agent with GPT-5
+- **Performed by**: PM Analysis Agent (LLM-backed)

186-190: Fix: “Conditional Edge Logic” references internal pmAgent nodes; align to subgraph boundaries and naming

This section mixes top-level workflow edges with internal pmAgent node names and uses the outdated saveRequirementToArtifact identifier. Recommend describing top-level edges and explicitly noting that pmAgent encapsulates its own internal routing and retries.

Apply this diff:

-- **analyzeRequirements**: Routes to `saveRequirementToArtifact` when requirements are successfully analyzed, retries `analyzeRequirements` with retry count tracking (max 3 attempts), fallback to `finalizeArtifacts` when max retries exceeded
-- **saveRequirementToArtifact**: Always routes to `dbAgent` after processing artifacts (workflow termination node pattern)
-- **dbAgent**: DB Agent subgraph handles internal routing between designSchema and invokeSchemaDesignTool nodes, routes to `generateUsecase` on completion
-- **validateSchema**: Routes to `finalizeArtifacts` on success, `dbAgent` on validation error
+- **pmAgent**: Internally routes between `analyzeRequirements` and `invokeSaveArtifactTool` with retry policy (max 3 attempts). On successful completion, routes to `dbAgent`. Falls back to `finalizeArtifacts` on unrecoverable errors.
+- **dbAgent**: Subgraph handles internal routing between `designSchema` and `invokeSchemaDesignTool`; routes to `generateUsecase` on completion.
+- **validateSchema**: Routes to `finalizeArtifacts` on success, or back to `dbAgent` on validation error.
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 1ab66ea and 9b0d4cd.

📒 Files selected for processing (10)
  • frontend/internal-packages/agent/src/chat/workflow/README.md (2 hunks)
  • frontend/internal-packages/agent/src/chat/workflow/nodes/index.ts (0 hunks)
  • frontend/internal-packages/agent/src/createGraph.test.ts (1 hunks)
  • frontend/internal-packages/agent/src/createGraph.ts (3 hunks)
  • frontend/internal-packages/agent/src/langchain/agents/index.ts (0 hunks)
  • frontend/internal-packages/agent/src/langchain/agents/pmAnalysisAgent/agent.ts (0 hunks)
  • frontend/internal-packages/agent/src/langchain/agents/pmAnalysisAgent/index.ts (0 hunks)
  • frontend/internal-packages/agent/src/pm-agent/createPmAgentGraph.ts (1 hunks)
  • frontend/internal-packages/agent/src/pm-agent/invokePmAnalysisAgent.ts (1 hunks)
  • frontend/internal-packages/agent/src/pm-agent/nodes/analyzeRequirementsNode.ts (2 hunks)
💤 Files with no reviewable changes (4)
  • frontend/internal-packages/agent/src/chat/workflow/nodes/index.ts
  • frontend/internal-packages/agent/src/langchain/agents/index.ts
  • frontend/internal-packages/agent/src/langchain/agents/pmAnalysisAgent/index.ts
  • frontend/internal-packages/agent/src/langchain/agents/pmAnalysisAgent/agent.ts
🚧 Files skipped from review as they are similar to previous changes (5)
  • frontend/internal-packages/agent/src/pm-agent/createPmAgentGraph.ts
  • frontend/internal-packages/agent/src/pm-agent/nodes/analyzeRequirementsNode.ts
  • frontend/internal-packages/agent/src/createGraph.test.ts
  • frontend/internal-packages/agent/src/createGraph.ts
  • frontend/internal-packages/agent/src/pm-agent/invokePmAnalysisAgent.ts
🧰 Additional context used
🧠 Learnings (3)
📓 Common learnings
Learnt from: MH4GF
PR: liam-hq/liam#3018
File: frontend/internal-packages/agent/src/chat/workflow/README.md:11-22
Timestamp: 2025-08-15T02:21:21.491Z
Learning: In the LIAM codebase, Mermaid diagrams in README files (particularly in frontend/internal-packages/agent/src/chat/workflow/README.md) are automatically generated by LangGraph. These diagrams should not be manually edited as it would corrupt the output. Formatting issues like hard tabs (MD010) in these auto-generated Mermaid blocks should not be flagged in code reviews.
📚 Learning: 2025-08-15T02:21:21.491Z
Learnt from: MH4GF
PR: liam-hq/liam#3018
File: frontend/internal-packages/agent/src/chat/workflow/README.md:11-22
Timestamp: 2025-08-15T02:21:21.491Z
Learning: In the LIAM codebase, Mermaid diagrams in README files (particularly in frontend/internal-packages/agent/src/chat/workflow/README.md) are automatically generated by LangGraph. These diagrams should not be manually edited as it would corrupt the output. Formatting issues like hard tabs (MD010) in these auto-generated Mermaid blocks should not be flagged in code reviews.

Applied to files:

  • frontend/internal-packages/agent/src/chat/workflow/README.md
📚 Learning: 2025-07-29T09:15:54.413Z
Learnt from: MH4GF
PR: liam-hq/liam#2753
File: frontend/internal-packages/agent/src/chat/workflow/README.md:106-109
Timestamp: 2025-07-29T09:15:54.413Z
Learning: In the LIAM codebase, HTML entities like `&nbsp;` in Mermaid diagram edge labels are intentionally kept as-is, even though they may render as literal text rather than parsed entities. The user MH4GF has confirmed this syntax should remain unchanged in the README documentation.

Applied to files:

  • frontend/internal-packages/agent/src/chat/workflow/README.md
🪛 markdownlint-cli2 (0.17.2)
frontend/internal-packages/agent/src/chat/workflow/README.md

11-11: Hard tabs
Column: 1

(MD010, no-hard-tabs)


12-12: Hard tabs
Column: 1

(MD010, no-hard-tabs)


13-13: Hard tabs
Column: 1

(MD010, no-hard-tabs)


14-14: Hard tabs
Column: 1

(MD010, no-hard-tabs)


15-15: Hard tabs
Column: 1

(MD010, no-hard-tabs)


16-16: Hard tabs
Column: 1

(MD010, no-hard-tabs)


17-17: Hard tabs
Column: 1

(MD010, no-hard-tabs)


18-18: Hard tabs
Column: 1

(MD010, no-hard-tabs)


19-19: Hard tabs
Column: 1

(MD010, no-hard-tabs)


20-20: Hard tabs
Column: 1

(MD010, no-hard-tabs)


21-21: Hard tabs
Column: 1

(MD010, no-hard-tabs)


22-22: Hard tabs
Column: 1

(MD010, no-hard-tabs)


92-92: Hard tabs
Column: 1

(MD010, no-hard-tabs)


93-93: Hard tabs
Column: 1

(MD010, no-hard-tabs)


94-94: Hard tabs
Column: 1

(MD010, no-hard-tabs)


95-95: Hard tabs
Column: 1

(MD010, no-hard-tabs)


96-96: Hard tabs
Column: 1

(MD010, no-hard-tabs)


97-97: Hard tabs
Column: 1

(MD010, no-hard-tabs)


98-98: Hard tabs
Column: 1

(MD010, no-hard-tabs)


99-99: Hard tabs
Column: 1

(MD010, no-hard-tabs)


100-100: Hard tabs
Column: 1

(MD010, no-hard-tabs)


101-101: Hard tabs
Column: 1

(MD010, no-hard-tabs)


102-102: Hard tabs
Column: 1

(MD010, no-hard-tabs)

🪛 LanguageTool
frontend/internal-packages/agent/src/chat/workflow/README.md

[grammar] ~81-~81: There might be a mistake here.
Context: ...rates and saves comprehensive artifacts to database, handles error timeline items ...

(QB_NEW_EN)


[grammar] ~107-~107: There might be a mistake here.
Context: ...onents #### 1. analyzeRequirements Node - Purpose: Analyzes and structures user ...

(QB_NEW_EN)


[grammar] ~109-~109: There might be a mistake here.
Context: ...ormed by**: PM Analysis Agent with GPT-5 - Retry Policy: maxAttempts: 3 (internal...

(QB_NEW_EN)


[grammar] ~110-~110: There might be a mistake here.
Context: ...*: maxAttempts: 3 (internal to subgraph) - Timeline Sync: Automatic message synch...

(QB_NEW_EN)


[grammar] ~113-~113: There might be a mistake here.
Context: ...ion #### 2. invokeSaveArtifactTool Node - Purpose: Saves analyzed requirements a...

(QB_NEW_EN)


[grammar] ~115-~115: There might be a mistake here.
Context: ...med by**: saveRequirementsToArtifactTool - Retry Policy: maxAttempts: 3 (internal...

(QB_NEW_EN)


[grammar] ~116-~116: There might be a mistake here.
Context: ...*: maxAttempts: 3 (internal to subgraph) - Tool Integration: Direct database arti...

(QB_NEW_EN)


[grammar] ~121-~121: There might be a mistake here.
Context: ...(when requirements are fully analyzed) 2. **Iterative Saving**:START → analyzeRequ...

(QB_NEW_EN)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (6)
  • GitHub Check: Supabase Preview
  • GitHub Check: codeql / languages (javascript) / Perform CodeQL for javascript
  • GitHub Check: frontend-lint
  • GitHub Check: frontend-ci
  • GitHub Check: agent-deep-modeling
  • GitHub Check: Supabase Preview
🔇 Additional comments (3)
frontend/internal-packages/agent/src/chat/workflow/README.md (3)

11-23: Architecture diagram update aligns with new pmAgent entry and routing

The top-level flow now starts at pmAgent and routes to dbAgent, matching the subgraph refactor intent.


83-103: PM Agent subgraph section reads clearly and matches the refactor

Diagrams and section structure accurately present analyzeRequirements and invokeSaveArtifactTool as internal pmAgent nodes with subgraph boundaries.


119-123: PM Agent flow patterns look correct and consistent with subgraph design

The Simple and Iterative patterns reflect internal pmAgent routing without leaking into the top-level graph.

Copy link
Member

@FunamaYukina FunamaYukina left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you so much!✨
I confirmed that it became the same flow as the db agent.
It worked in the preview environment.
ss 3729

@FunamaYukina FunamaYukina added this pull request to the merge queue Aug 15, 2025
Merged via the queue into main with commit f0357d0 Aug 15, 2025
28 checks passed
@FunamaYukina FunamaYukina deleted the refactor-pm-agent-to-subgraph branch August 15, 2025 06:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants