Skip to content

Conversation

MH4GF
Copy link
Member

@MH4GF MH4GF commented Sep 16, 2025

Issue

Why is this change needed?

This PR implements a priority-based routing system in the LangGraph workflow to automatically direct messages to the DB Agent when schema validation issues are detected. This ensures that schema problems are addressed before continuing with other workflow stages.

Problem

Previously, when the QA Agent detected schema issues during test case validation, there was no automated mechanism to route the workflow back to the DB Agent for fixes. This required manual intervention and could lead to incomplete schemas progressing through the workflow.

Solution

Implement classification logic in the Lead Agent that:

  1. Prioritizes DB Agent routing when schema issues exist (highest priority)
  2. Routes to workflow summarization when QA test cases are complete and no schema issues remain (second priority)
  3. Defaults to PM Agent for initial requirements analysis (default case)

Key Changes

Graph Architecture

  • Add dbAgent conditional edge to main graph in createGraph.ts
  • Update Mermaid architecture diagrams to reflect new routing path

Classification Logic

  • Enhance classifyMessage with priority-based routing system
  • Add shouldRouteDBAgent helper to check for schema issues
  • Add hasSchemaIssues utility to validate workflow state

Schema Issues Management

  • Separate schemaIssues annotation for workflow-level and QA agent-level tracking
  • Use replace (not concat) semantics for workflow-level schema issues to prevent duplicates
  • Clear schema issues after DB agent processing completes

DB Agent Prompt Improvements

  • Rename "Test Cases" section to "Requirements" for clarity
  • Add "Schema Issues to Fix" section to DB Agent prompt when issues exist
  • Filter requirements to only show those related to schema issues

Recursion Limit

  • Temporarily set recursion limit to 10 (down from default 25) to prevent runaway retry loops
  • This is a temporary measure while we refine the routing logic
  • Future work will implement more sophisticated termination conditions

Testing

  • Add comprehensive unit tests for all routing scenarios
  • Add integration tests for workflow-level schema issues annotation
  • Update snapshots for new prompt format

Test Plan

  • ✅ Route to dbAgent when schema issues exist
  • ✅ Route to dbAgent when multiple schema issues exist
  • ✅ Prioritize schema issues over QA completion
  • ✅ Route to summarizeWorkflow when QA completed and no schema issues
  • ✅ Route to pmAgent when no schema issues and QA not completed
  • ✅ Clear schema issues after DB agent processing
  • ✅ Schema issues annotation properly tracked at workflow level
  • ✅ Integration tests verify end-to-end routing behavior

🤖 Generated with Claude Code

Co-Authored-By: Claude noreply@anthropic.com

Summary by CodeRabbit

  • New Features

    • Lead assistant now routes to the database assistant when workflow schema issues exist.
    • Database prompts renamed "Requirements" and optionally include a "Schema Issues to Fix" section.
    • Introduced a workflow-level schema-issues annotation and related public SchemaIssue type.
  • Bug Fixes

    • Workflow-level schema-issue semantics changed to replace (not concat) previous issues.
    • Lowered workflow recursion limit to 10 to reduce runaway retry loops.
  • Documentation

    • Architecture diagram updated to show lead → db routing.
  • Tests

    • Added/updated unit and integration tests and prompt snapshots for routing and schema-issue behavior.

Copy link

changeset-bot bot commented Sep 16, 2025

⚠️ No Changeset found

Latest commit: ef10307

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

vercel bot commented Sep 16, 2025

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

Project Deployment Preview Comments Updated (UTC)
liam-app Ready Ready Preview Comment Oct 10, 2025 7:10am
liam-assets Ready Ready Preview Comment Oct 10, 2025 7:10am
liam-docs Ready Ready Preview Comment Oct 10, 2025 7:10am
liam-erd-sample Ready Ready Preview Oct 10, 2025 7:10am
liam-storybook Ready Ready Preview Comment Oct 10, 2025 7:10am

Copy link
Contributor

coderabbitai bot commented Sep 16, 2025

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.

Walkthrough

Adds routing from leadAgent to dbAgent when workflow-level schemaIssues exist, clears schemaIssues after DB calls, introduces a workflow-level schemaIssues annotation (replacement semantics) and a QA-level concat annotation, renames "Test Cases" to "Requirements" in DB prompts, and adjusts tests, diagram, and recursion limit.

Changes

Cohort / File(s) Summary of Changes
Lead-agent routing & tests
frontend/internal-packages/agent/src/lead-agent/classifyMessage/index.ts, frontend/internal-packages/agent/src/lead-agent/classifyMessage/index.test.ts, frontend/internal-packages/agent/src/lead-agent/utils/workflowStatus.ts
Adds shouldRouteDBAgent (uses hasSchemaIssues) and makes DB routing the top priority in classifyMessage; preserves QA routing second. Adds unit tests covering routing outcomes (schemaIssues vs QA completion).
Graph wiring, callDbAgent, docs & tests
frontend/internal-packages/agent/src/createGraph.ts, frontend/internal-packages/agent/src/createGraph.test.ts, frontend/internal-packages/agent/README.md
Adds conditional graph edge leadAgent -.-> dbAgent; updates test/diagram expectations; changes callDbAgent to return merged state+output and explicitly set schemaIssues: [].
DB-agent prompt formatting & tests
frontend/internal-packages/agent/src/db-agent/utils/convertAnalyzedRequirementsToPrompt.ts, frontend/internal-packages/agent/src/db-agent/utils/convertAnalyzedRequirementsToPrompt.test.ts
Renames "## Test Cases" header to "## Requirements" and conditionally appends a "## Schema Issues to Fix" section; updates snapshots and expectations.
Schema issues annotations & workflow behavior
frontend/internal-packages/agent/src/qa-agent/shared/qaAgentAnnotation.ts, frontend/internal-packages/agent/src/qa-agent/testcaseGeneration/testcaseAnnotation.ts, frontend/internal-packages/agent/src/workflowAnnotation.ts, frontend/internal-packages/agent/src/workflowSchemaIssuesAnnotation.ts, frontend/internal-packages/agent/src/workflowSchemaIssuesAnnotation.test.ts
Introduces workflowSchemaIssuesAnnotation and public SchemaIssue type (replacement reducer: next ?? prev) for workflow-level schemaIssues; adds qaSchemaIssuesAnnotation (concat) for QA-level accumulation; switches annotations and adds tests verifying replace/clear/preserve semantics.
Constants & integration usage
frontend/internal-packages/agent/src/constants.ts, frontend/internal-packages/agent/src/createGraph.integration.test.ts
Lowers DEFAULT_RECURSION_LIMIT from 50 to 10 and passes it into graph.streamEvents in the integration test.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor User
  participant LeadAgent
  participant DBAgent
  participant PMAgent
  participant Summarizer as SummarizeWorkflow

  Note over LeadAgent: Decision order\n1) shouldRouteDBAgent? (workflow.schemaIssues)\n2) isQACompleted?
  User->>LeadAgent: Incoming message + WorkflowState
  alt schemaIssues present
    LeadAgent-->>DBAgent: Route (goto END, update.next='dbAgent')
    Note right of DBAgent #A9D18E: callDbAgent returns merged state+output\nwith `schemaIssues: []` (cleared)
    DBAgent-->>LeadAgent: Result (schemaIssues: [])
  else QA completed
    LeadAgent-->>Summarizer: Route to summarizeWorkflow
  else default
    LeadAgent-->>PMAgent: Route to pmAgent
  end
  Note over LeadAgent: Graph contains conditional edge `leadAgent -.-> dbAgent`
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested labels

Review effort 3/5

Suggested reviewers

  • hoshinotsuyoshi
  • FunamaYukina
  • NoritakaIkeda
  • junkisai

Poem

I twitch my nose at schema blight,
Hop to the DB to make it right.
Requirements listed, issues cleared away,
The graph redirects where rabbits play.
Carrots and tests — a tidy day! 🥕🐇

Pre-merge checks and finishing touches

❌ Failed checks (2 warnings)
Check name Status Explanation Resolution
Linked Issues Check ⚠️ Warning The only linked issue (#3475) requires bumping Node.js to version 22.19.0, but the pull request contains no updates to Node.js version references, engines, or related dependency configurations, so it does not meet the coding requirement from the linked issue. Update the Node.js version in package.json (and any CI or engine constraints) to 22.19.0 as specified in issue #3475 or remove the reference to that issue if it is not intended to be addressed in this pull request.
Out of Scope Changes Check ⚠️ Warning Most of the code changes implement DB Agent routing logic, diagram updates, prompt reformatting, and schema annotation adjustments, none of which relate to the Node.js version bump described in the linked issue, making these modifications out of scope. Separate the DB Agent routing and annotation enhancements into their own pull request and restrict this pull request to the Node.js dependency update, or adjust the linked issue to match the intended scope of changes.
✅ Passed checks (3 passed)
Check name Status Explanation
Title Check ✅ Passed The title precisely states the primary feature being introduced—DB Agent routing in the LangGraph workflow—and uses clear, concise language that aligns with the main change described in the pull request.
Description Check ✅ Passed The pull request description follows the repository template by including an Issue section with the linked issue number and a Why is this change needed section, and it provides detailed Problem, Solution, Key Changes, and Test Plan entries, fulfilling the required structure and information.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch classify-message-to-db-agent

📜 Recent review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ef10307 and 4376bcb.

📒 Files selected for processing (4)
  • frontend/internal-packages/agent/src/createGraph.integration.test.ts (2 hunks)
  • frontend/internal-packages/agent/src/lead-agent/classifyMessage/index.test.ts (1 hunks)
  • frontend/internal-packages/agent/src/qa-agent/shared/qaAgentAnnotation.ts (2 hunks)
  • frontend/internal-packages/agent/src/workflowAnnotation.ts (2 hunks)
🧰 Additional context used
📓 Path-based instructions (4)
**/*.ts

📄 CodeRabbit inference engine (AGENTS.md)

Name utility files in camelCase (e.g., mergeSchema.ts)

Files:

  • frontend/internal-packages/agent/src/createGraph.integration.test.ts
  • frontend/internal-packages/agent/src/lead-agent/classifyMessage/index.test.ts
  • frontend/internal-packages/agent/src/qa-agent/shared/qaAgentAnnotation.ts
  • frontend/internal-packages/agent/src/workflowAnnotation.ts
**/*.test.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

Write unit tests with filenames ending in .test.ts or .test.tsx colocated near source

Files:

  • frontend/internal-packages/agent/src/createGraph.integration.test.ts
  • frontend/internal-packages/agent/src/lead-agent/classifyMessage/index.test.ts
**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

Use TypeScript/TSX across the codebase

**/*.{ts,tsx}: Use runtime type validation with valibot for external data validation
Prefer early returns for readability
Write simple, direct code without backward compatibility shims; update all call sites together
Use const-assigned arrow functions instead of function declarations for small utilities (e.g., const toggle = () => {})
Follow existing import patterns and tsconfig path aliases

Files:

  • frontend/internal-packages/agent/src/createGraph.integration.test.ts
  • frontend/internal-packages/agent/src/lead-agent/classifyMessage/index.test.ts
  • frontend/internal-packages/agent/src/qa-agent/shared/qaAgentAnnotation.ts
  • frontend/internal-packages/agent/src/workflowAnnotation.ts
frontend/internal-packages/**

📄 CodeRabbit inference engine (AGENTS.md)

Infra and tooling (e2e, configs, storybook, agent) live under frontend/internal-packages

Files:

  • frontend/internal-packages/agent/src/createGraph.integration.test.ts
  • frontend/internal-packages/agent/src/lead-agent/classifyMessage/index.test.ts
  • frontend/internal-packages/agent/src/qa-agent/shared/qaAgentAnnotation.ts
  • frontend/internal-packages/agent/src/workflowAnnotation.ts
🧬 Code graph analysis (4)
frontend/internal-packages/agent/src/createGraph.integration.test.ts (1)
frontend/internal-packages/agent/src/constants.ts (1)
  • DEFAULT_RECURSION_LIMIT (22-22)
frontend/internal-packages/agent/src/lead-agent/classifyMessage/index.test.ts (3)
frontend/internal-packages/agent/src/types.ts (1)
  • WorkflowState (8-8)
frontend/internal-packages/agent/src/lead-agent/classifyMessage/index.ts (1)
  • classifyMessage (5-24)
frontend/internal-packages/agent/src/lead-agent/classifyMessage/index.integration.test.ts (1)
  • it (42-132)
frontend/internal-packages/agent/src/qa-agent/shared/qaAgentAnnotation.ts (1)
frontend/internal-packages/agent/src/qa-agent/testcaseGeneration/testcaseAnnotation.ts (1)
  • qaSchemaIssuesAnnotation (17-20)
frontend/internal-packages/agent/src/workflowAnnotation.ts (1)
frontend/internal-packages/agent/src/workflowSchemaIssuesAnnotation.ts (1)
  • workflowSchemaIssuesAnnotation (19-22)
⏰ 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). (5)
  • GitHub Check: Supabase Preview
  • GitHub Check: frontend-lint
  • GitHub Check: frontend-ci
  • GitHub Check: agent-deep-modeling
  • GitHub Check: Supabase Preview
🔇 Additional comments (8)
frontend/internal-packages/agent/src/createGraph.integration.test.ts (2)

9-9: LGTM!

Importing the recursion limit constant from a centralized location improves maintainability.


39-39: LGTM!

Using the shared constant ensures the integration test matches production behavior and makes future adjustments easier.

frontend/internal-packages/agent/src/lead-agent/classifyMessage/index.test.ts (2)

6-21: Well-designed mock helper.

The createMockState helper provides sensible defaults and allows targeted overrides for each test scenario. This is a clean pattern that reduces boilerplate and makes tests more maintainable.


23-123: Comprehensive routing test coverage.

The test suite thoroughly validates the priority-based routing logic:

  1. DB agent routing (highest priority) - covered in tests at lines 24-82
  2. QA completion routing (second priority) - covered at lines 84-107
  3. Default PM agent routing - covered at lines 109-122

The test at lines 57-82 specifically confirms that schema issues take precedence over QA completion, which is critical for the routing behavior described in the PR objectives.

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

4-4: LGTM: Import updated for workflow-level annotation.

The import change correctly switches to workflowSchemaIssuesAnnotation, which uses replacement semantics appropriate for workflow-level schema issues.


19-19: LGTM: Field correctly references the new workflow-level annotation.

The field update properly uses workflowSchemaIssuesAnnotation, enabling replacement semantics for workflow-level schema issues while maintaining the same field name and type.

frontend/internal-packages/agent/src/qa-agent/shared/qaAgentAnnotation.ts (2)

6-6: LGTM: Import updated for QA-level annotation.

The import change correctly switches to qaSchemaIssuesAnnotation, which uses concatenation semantics appropriate for accumulating QA-level schema issues.


29-29: LGTM: Field correctly references the new QA-level annotation.

The field update properly uses qaSchemaIssuesAnnotation, enabling concatenation semantics for QA-level schema issues. This intentionally differs from the workflow-level replacement semantics, allowing QA issues to accumulate.


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

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

supabase bot commented Sep 16, 2025

Updates to Preview Branch (classify-message-to-db-agent) ↗︎

Deployments Status Updated
Database Fri, 10 Oct 2025 07:03:57 UTC
Services Fri, 10 Oct 2025 07:03:57 UTC
APIs Fri, 10 Oct 2025 07:03:57 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, 10 Oct 2025 07:03:58 UTC
Migrations Fri, 10 Oct 2025 07:03:58 UTC
Seeding Fri, 10 Oct 2025 07:03:58 UTC
Edge Functions Fri, 10 Oct 2025 07:03:58 UTC

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

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: 1

🧹 Nitpick comments (4)
frontend/internal-packages/agent/src/createGraph.ts (2)

70-74: instanceof AIMessage may fail after serialization; prefer predicate helper.

If messages are deserialized, instanceof can be unreliable. Use isAIMessage(msg) from @langchain/core/messages.

-import { AIMessage } from '@langchain/core/messages'
+import { AIMessage, isAIMessage } from '@langchain/core/messages'
...
-const isFirstExecution = !state.messages.some((msg) => msg instanceof AIMessage)
+const isFirstExecution = !state.messages.some((msg) => isAIMessage(msg))

23-34: Avoid recreating the DB subgraph per call.

Minor perf: createDbAgentGraph(checkpointer) likely does non-trivial setup. Hoist and reuse like you do for leadAgentSubgraph, unless the subgraph isn’t re-entrant.

Suggested pattern:

// near other subgraph creations
const dbAgentSubgraph = createDbAgentGraph(checkpointer)

// inside callDbAgent(...)
const output = await dbAgentSubgraph.invoke(modifiedState, config)

If re-entrancy is a concern, confirm and keep as-is.

frontend/internal-packages/agent/src/lead-agent/utils/workflowStatus.ts (1)

7-13: Use arrow functions + add null‑safety on arrays.

Aligns with guidelines (prefer const arrows) and avoids crashes if fields are ever undefined.

-export function isQACompleted(state: WorkflowState): boolean {
-  return state.testcases.length > 0
-}
+export const isQACompleted = (state: WorkflowState): boolean =>
+  (state.testcases?.length ?? 0) > 0
-
-function hasSchemaIssues(state: WorkflowState): boolean {
-  return state.schemaIssues.length > 0
-}
+const hasSchemaIssues = (state: WorkflowState): boolean =>
+  (state.schemaIssues?.length ?? 0) > 0
-
-export function shouldRouteDBAgent(state: WorkflowState): boolean {
-  return hasSchemaIssues(state)
-}
+export const shouldRouteDBAgent = (state: WorkflowState): boolean =>
+  hasSchemaIssues(state)
frontend/internal-packages/agent/src/lead-agent/classifyMessage/index.test.ts (1)

117-127: Add an integration test to catch unintended pmAgent → dbAgent hops.

Given the current graph edge, PM always flows to DB. Add a graph‑level test (mock subgraphs) to assert that when schemaIssues is empty, PM does not trigger DB.

I can provide a test that vi.mocks createDbAgentGraph to record invocations and runs one PM cycle to ensure zero calls when schemaIssues.length === 0. Want me to draft it?

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between fa6b1f7 and a685a4d.

📒 Files selected for processing (4)
  • frontend/internal-packages/agent/src/createGraph.ts (1 hunks)
  • frontend/internal-packages/agent/src/lead-agent/classifyMessage/index.test.ts (1 hunks)
  • frontend/internal-packages/agent/src/lead-agent/classifyMessage/index.ts (1 hunks)
  • frontend/internal-packages/agent/src/lead-agent/utils/workflowStatus.ts (1 hunks)
🧰 Additional context used
📓 Path-based instructions (5)
**/*.ts

📄 CodeRabbit inference engine (AGENTS.md)

Name utility files in camelCase (e.g., mergeSchema.ts)

Files:

  • frontend/internal-packages/agent/src/lead-agent/utils/workflowStatus.ts
  • frontend/internal-packages/agent/src/createGraph.ts
  • frontend/internal-packages/agent/src/lead-agent/classifyMessage/index.test.ts
  • frontend/internal-packages/agent/src/lead-agent/classifyMessage/index.ts
**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

Use TypeScript/TSX across the codebase

**/*.{ts,tsx}: Use runtime type validation with valibot for external data validation
Use early returns for readability
Write simple, direct code without backward compatibility concerns—update all call sites together
Use named exports only (no default exports)
Follow existing import patterns and tsconfig paths
Prefer const arrow functions instead of function declarations for simple utilities (e.g., const toggle = () => {})

Files:

  • frontend/internal-packages/agent/src/lead-agent/utils/workflowStatus.ts
  • frontend/internal-packages/agent/src/createGraph.ts
  • frontend/internal-packages/agent/src/lead-agent/classifyMessage/index.test.ts
  • frontend/internal-packages/agent/src/lead-agent/classifyMessage/index.ts
frontend/internal-packages/**

📄 CodeRabbit inference engine (AGENTS.md)

Infra and tooling (e2e, configs, storybook, agent) live under frontend/internal-packages

Files:

  • frontend/internal-packages/agent/src/lead-agent/utils/workflowStatus.ts
  • frontend/internal-packages/agent/src/createGraph.ts
  • frontend/internal-packages/agent/src/lead-agent/classifyMessage/index.test.ts
  • frontend/internal-packages/agent/src/lead-agent/classifyMessage/index.ts
frontend/**/*.{ts,tsx}

📄 CodeRabbit inference engine (CLAUDE.md)

frontend/**/*.{ts,tsx}: Import UI components from @liam-hq/ui when available
Import icons from @liam-hq/ui

Files:

  • frontend/internal-packages/agent/src/lead-agent/utils/workflowStatus.ts
  • frontend/internal-packages/agent/src/createGraph.ts
  • frontend/internal-packages/agent/src/lead-agent/classifyMessage/index.test.ts
  • frontend/internal-packages/agent/src/lead-agent/classifyMessage/index.ts
**/*.test.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

Write unit tests with filenames ending in .test.ts or .test.tsx colocated near source

Files:

  • frontend/internal-packages/agent/src/lead-agent/classifyMessage/index.test.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/createGraph.ts
🧬 Code graph analysis (3)
frontend/internal-packages/agent/src/lead-agent/utils/workflowStatus.ts (1)
frontend/internal-packages/agent/src/types.ts (1)
  • WorkflowState (8-8)
frontend/internal-packages/agent/src/lead-agent/classifyMessage/index.test.ts (2)
frontend/internal-packages/agent/src/types.ts (1)
  • WorkflowState (8-8)
frontend/internal-packages/agent/src/lead-agent/classifyMessage/index.ts (1)
  • classifyMessage (5-24)
frontend/internal-packages/agent/src/lead-agent/classifyMessage/index.ts (2)
frontend/internal-packages/agent/src/types.ts (1)
  • WorkflowState (8-8)
frontend/internal-packages/agent/src/lead-agent/utils/workflowStatus.ts (2)
  • shouldRouteDBAgent (11-13)
  • isQACompleted (3-5)
⏰ 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: frontend-lint
  • GitHub Check: frontend-ci
  • GitHub Check: codeql / languages (javascript) / Perform CodeQL for javascript
  • GitHub Check: agent-deep-modeling
  • GitHub Check: security-review
  • GitHub Check: Supabase Preview
🔇 Additional comments (6)
frontend/internal-packages/agent/src/createGraph.ts (3)

82-86: LGTM: leadAgent now recognizes dbAgent as a next hop.

Matches classifyMessage’s update.next = 'dbAgent' path and keeps END support intact.


46-53: Double-check resetting analyzedRequirementsRetryCount to 0 each PM run.

If PM can loop, this may defeat backoff/limits. If intentional, add a brief comment.


23-25: Approve: passing checkpointer to createDbAgentGraph is safe.
Signature is createDbAgentGraph(checkpointer?: BaseCheckpointSaver) (frontend/internal-packages/agent/src/db-agent/createDbAgentGraph.ts:26), so passing checkpointer from createGraph.ts won't cause runtime errors.

frontend/internal-packages/agent/src/lead-agent/classifyMessage/index.ts (2)

6-12: LGTM: clear priority routing with early returns.

Correctly sets update.next = 'dbAgent' and exits via END when schema issues exist.


14-17: LGTM: QA and PM paths behave as specified.

Routes to summarizeWorkflow when QA completed; otherwise defaults to PM via END.

Also applies to: 19-23

frontend/internal-packages/agent/src/lead-agent/classifyMessage/index.test.ts (1)

27-88: Solid coverage of DB‑priority cases.

Tests correctly assert DB routing even when QA testcases exist.

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
frontend/internal-packages/agent/README.md (2)

96-101: Update “Routing” text to reflect new DB‑first priority.

The classify node description still says it routes to pmAgent for DB tasks. Please align it with the new shouldRouteDBAgent pre‑check and dbAgent priority.

Apply this diff:

- - **Routing**: Routes to pmAgent for database design tasks or summarizeWorkflow after QA completion
+ - **Routing**: Routes to dbAgent when schema issues exist (highest priority), to summarizeWorkflow after QA completion (when no schema issues), otherwise to pmAgent.

353-357: Fix contradictions in “Conditional Edge Logic” (QA route + node names).

This section says QA “always routes to finalizeArtifacts,” but the diagram shows qaAgent → leadAgent. It also references outdated nodes (generateDml/invokeSaveDmlTool) rather than validateSchema/invokeRunTestTool.

- **qaAgent**: QA Agent subgraph handles internal routing between generateTestcase, generateDml, invokeSaveDmlTool, and validateSchema nodes, always routes to `finalizeArtifacts`
+ **qaAgent**: QA Agent subgraph handles internal routing between testcaseGeneration, validateSchema, and invokeRunTestTool nodes, and routes to `leadAgent` (summarize) on completion.
🧹 Nitpick comments (2)
frontend/internal-packages/agent/README.md (1)

110-113: Refresh Lead Agent flow patterns to include DB‑priority path.

Reflect the new ordering and outcomes for clarity.

-1. **Database Design Request**: `START → classify → END` (routes to pmAgent via Command)
-2. **Non-Database Request**: `START → classify → END` (responds directly without routing)
-3. **Workflow Summarization**: `START → classify → summarizeWorkflow → END` (after QA completion)
+1. **Schema Issues Detected**: `START → classify → END` (routes to dbAgent via Command; highest priority)
+2. **QA Completed (no schema issues)**: `START → classify → summarizeWorkflow → END`
+3. **All Other Requests**: `START → classify → END` (routes to pmAgent via Command)
frontend/internal-packages/agent/src/createGraph.test.ts (1)

30-36: Reduce brittleness: assert critical edges/nodes instead of full‑string equality.

Full equality on the Mermaid string is fragile to harmless formatting changes. Assert key snippets instead.

-    const graph = await compiledStateGraph.getGraphAsync()
-    const mermaid = graph.drawMermaid()
-    expect(mermaid).toEqual(expectedMermaidDiagram)
+    const graph = await compiledStateGraph.getGraphAsync()
+    const mermaid = graph.drawMermaid()
+    // Assert critical structure to avoid brittleness on whitespace/order.
+    const requiredSnippets = [
+      '__start__', 'validateInitialSchema', 'leadAgent', 'pmAgent', 'dbAgent', 'qaAgent', '__end__',
+      'leadAgent -.-> pmAgent;',
+      'leadAgent -.-> dbAgent;',
+      'dbAgent --> qaAgent;',
+      'pmAgent --> dbAgent;',
+      'qaAgent --> leadAgent;',
+    ]
+    for (const s of requiredSnippets) expect(mermaid).toContain(s)
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a685a4d and cd91d33.

📒 Files selected for processing (3)
  • frontend/internal-packages/agent/README.md (1 hunks)
  • frontend/internal-packages/agent/src/createGraph.test.ts (1 hunks)
  • frontend/internal-packages/agent/src/createGraph.ts (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • frontend/internal-packages/agent/src/createGraph.ts
🧰 Additional context used
📓 Path-based instructions (5)
**/*.ts

📄 CodeRabbit inference engine (AGENTS.md)

Name utility files in camelCase (e.g., mergeSchema.ts)

Files:

  • frontend/internal-packages/agent/src/createGraph.test.ts
**/*.test.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

Write unit tests with filenames ending in .test.ts or .test.tsx colocated near source

Files:

  • frontend/internal-packages/agent/src/createGraph.test.ts
**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

Use TypeScript/TSX across the codebase

**/*.{ts,tsx}: Use runtime type validation with valibot for external data validation
Use early returns for readability
Write simple, direct code without backward compatibility concerns—update all call sites together
Use named exports only (no default exports)
Follow existing import patterns and tsconfig paths
Prefer const arrow functions instead of function declarations for simple utilities (e.g., const toggle = () => {})

Files:

  • frontend/internal-packages/agent/src/createGraph.test.ts
frontend/internal-packages/**

📄 CodeRabbit inference engine (AGENTS.md)

Infra and tooling (e2e, configs, storybook, agent) live under frontend/internal-packages

Files:

  • frontend/internal-packages/agent/src/createGraph.test.ts
  • frontend/internal-packages/agent/README.md
frontend/**/*.{ts,tsx}

📄 CodeRabbit inference engine (CLAUDE.md)

frontend/**/*.{ts,tsx}: Import UI components from @liam-hq/ui when available
Import icons from @liam-hq/ui

Files:

  • frontend/internal-packages/agent/src/createGraph.test.ts
🧠 Learnings (2)
📚 Learning: 2025-08-15T02:21:21.531Z
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.531Z
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/createGraph.test.ts
📚 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/createGraph.test.ts
🪛 markdownlint-cli2 (0.17.2)
frontend/internal-packages/agent/README.md

24-24: Hard tabs
Column: 1

(MD010, no-hard-tabs)

⏰ 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). (4)
  • GitHub Check: Supabase Preview
  • GitHub Check: agent-deep-modeling
  • GitHub Check: frontend-ci
  • GitHub Check: Supabase Preview
🔇 Additional comments (3)
frontend/internal-packages/agent/README.md (1)

24-24: New leadAgent → dbAgent edge documented — looks correct.

Matches the PR’s routing priority (DB Agent on schema issues) and the test updates. Note: leave Mermaid indentation/tabs as‑is; these blocks are auto‑generated in this repo and lint MD010 should be ignored.

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

38-44: README diagram containment check — OK.

Keeps the doc diagram in sync with the generated one; given these blocks are auto‑generated in this repo, this safeguard is useful.


23-23: Approved — wiring verified: leadAgent → dbAgent, DB pre-check routing, schemaIssues cleared

createGraph.test.ts contains the leadAgent → dbAgent edge; classifyMessage (frontend/internal-packages/agent/src/lead-agent/classifyMessage/index.ts) routes to 'dbAgent' via shouldRouteDBAgent; createGraph.ts clears schemaIssues after dbAgent processing to prevent loops.

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 (2)
frontend/internal-packages/agent/README.md (1)

33-49: Doc drift: WorkflowState is missing schemaIssues used by routing.

Please add schemaIssues: SchemaIssue[] (or similar) to this example interface so docs align with code.

frontend/internal-packages/agent/src/lead-agent/utils/workflowStatus.ts (1)

7-13: Harden schemaIssues check and align with arrow-function style.

state.schemaIssues may be undefined; .length would throw. Also, utilities prefer const arrow functions per guidelines.

Apply within this hunk:

-function hasSchemaIssues(state: WorkflowState): boolean {
-  return state.schemaIssues.length > 0
-}
-
-export function shouldRouteDBAgent(state: WorkflowState): boolean {
-  return hasSchemaIssues(state)
-}
+const hasSchemaIssues = (state: WorkflowState): boolean =>
+  Array.isArray((state as any).schemaIssues) && state.schemaIssues.length > 0
+
+export const shouldRouteDBAgent = (state: WorkflowState): boolean =>
+  hasSchemaIssues(state)

Optionally, mirror this style for isQACompleted in a follow-up for consistency.

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between cd91d33 and 58614db.

📒 Files selected for processing (6)
  • frontend/internal-packages/agent/README.md (1 hunks)
  • frontend/internal-packages/agent/src/createGraph.test.ts (1 hunks)
  • frontend/internal-packages/agent/src/createGraph.ts (2 hunks)
  • frontend/internal-packages/agent/src/lead-agent/classifyMessage/index.test.ts (1 hunks)
  • frontend/internal-packages/agent/src/lead-agent/classifyMessage/index.ts (1 hunks)
  • frontend/internal-packages/agent/src/lead-agent/utils/workflowStatus.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (3)
  • frontend/internal-packages/agent/src/createGraph.test.ts
  • frontend/internal-packages/agent/src/createGraph.ts
  • frontend/internal-packages/agent/src/lead-agent/classifyMessage/index.test.ts
🧰 Additional context used
📓 Path-based instructions (4)
**/*.ts

📄 CodeRabbit inference engine (AGENTS.md)

Name utility files in camelCase (e.g., mergeSchema.ts)

Files:

  • frontend/internal-packages/agent/src/lead-agent/utils/workflowStatus.ts
  • frontend/internal-packages/agent/src/lead-agent/classifyMessage/index.ts
**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

Use TypeScript/TSX across the codebase

**/*.{ts,tsx}: Use runtime type validation with valibot for external data validation
Use early returns for readability
Write simple, direct code without backward compatibility concerns—update all call sites together
Use named exports only (no default exports)
Follow existing import patterns and tsconfig paths
Prefer const arrow functions instead of function declarations for simple utilities (e.g., const toggle = () => {})

Files:

  • frontend/internal-packages/agent/src/lead-agent/utils/workflowStatus.ts
  • frontend/internal-packages/agent/src/lead-agent/classifyMessage/index.ts
frontend/internal-packages/**

📄 CodeRabbit inference engine (AGENTS.md)

Infra and tooling (e2e, configs, storybook, agent) live under frontend/internal-packages

Files:

  • frontend/internal-packages/agent/src/lead-agent/utils/workflowStatus.ts
  • frontend/internal-packages/agent/src/lead-agent/classifyMessage/index.ts
  • frontend/internal-packages/agent/README.md
frontend/**/*.{ts,tsx}

📄 CodeRabbit inference engine (CLAUDE.md)

frontend/**/*.{ts,tsx}: Import UI components from @liam-hq/ui when available
Import icons from @liam-hq/ui

Files:

  • frontend/internal-packages/agent/src/lead-agent/utils/workflowStatus.ts
  • frontend/internal-packages/agent/src/lead-agent/classifyMessage/index.ts
🧠 Learnings (1)
📚 Learning: 2025-08-15T02:21:21.531Z
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.531Z
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/README.md
🧬 Code graph analysis (2)
frontend/internal-packages/agent/src/lead-agent/utils/workflowStatus.ts (1)
frontend/internal-packages/agent/src/types.ts (1)
  • WorkflowState (8-8)
frontend/internal-packages/agent/src/lead-agent/classifyMessage/index.ts (2)
frontend/internal-packages/agent/src/types.ts (1)
  • WorkflowState (8-8)
frontend/internal-packages/agent/src/lead-agent/utils/workflowStatus.ts (2)
  • shouldRouteDBAgent (11-13)
  • isQACompleted (3-5)
🪛 markdownlint-cli2 (0.17.2)
frontend/internal-packages/agent/README.md

24-24: Hard tabs
Column: 1

(MD010, no-hard-tabs)

⏰ 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: Supabase Preview
  • GitHub Check: frontend-lint
  • GitHub Check: frontend-ci
  • GitHub Check: agent-deep-modeling
  • GitHub Check: Supabase Preview
🔇 Additional comments (4)
frontend/internal-packages/agent/README.md (1)

24-24: Mermaid edge addition matches new routing (leadAgent → dbAgent).

LGTM. Per prior learnings, Mermaid blocks here are auto-generated—don’t hand-edit; ignore MD010 hard‑tab lint in this block.

frontend/internal-packages/agent/src/lead-agent/classifyMessage/index.ts (2)

20-23: Default route to pmAgent is consistent with prior pattern.

LGTM.


6-13: Priority routing to DB Agent: confirmed — transition exists and loop-break implemented.
createGraph.ts invokes dbAgentSubgraph and returns the state with schemaIssues: [] (frontend/internal-packages/agent/src/createGraph.ts:34), preventing re-routing loops.

frontend/internal-packages/agent/src/lead-agent/utils/workflowStatus.ts (1)

7-13: No action needed — schemaIssues is an array and is cleared after DB agent.

Verified: schemaIssuesAnnotation = Annotation<Array> (frontend/internal-packages/agent/src/qa-agent/testcaseGeneration/testcaseAnnotation.ts), workflowAnnotation includes schemaIssues: schemaIssuesAnnotation (frontend/internal-packages/agent/src/workflowAnnotation.ts), WorkflowState = typeof workflowAnnotation.State (frontend/internal-packages/agent/src/types.ts), and createGraph clears it to [] (frontend/internal-packages/agent/src/createGraph.ts).

@MH4GF MH4GF marked this pull request as ready for review September 17, 2025 07:02
@MH4GF MH4GF requested a review from a team as a code owner September 17, 2025 07:02
@MH4GF MH4GF requested review from Copilot and hoshinotsuyoshi and removed request for a team September 17, 2025 07:02
MH4GF and others added 4 commits October 9, 2025 17:59
Add tests to verify replacement reducer behavior:
- Replace operation (not concat)
- Clear with empty array
- Preserve value when not updated

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

Co-Authored-By: Claude <noreply@anthropic.com>
Change the prompt text from "Test Cases:" to "Requirements:" to better
reflect the DB Agent's role of designing schemas based on requirements
rather than executing tests.

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

Co-Authored-By: Claude <noreply@anthropic.com>
Add a new section that lists schema issues when schemaIssues are present.
This helps DB Agent understand what specific problems need to be fixed.

Prompt structure:
- Session Goal
- Requirements (filtered by schemaIssues if present)
- Schema Issues to Fix (numbered list, only shown when issues exist)

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

Co-Authored-By: Claude <noreply@anthropic.com>
- Set DEFAULT_RECURSION_LIMIT to 10 to prevent infinite loops
- Added detailed documentation explaining temporary limitation
- Updated integration test to explicitly use DEFAULT_RECURSION_LIMIT

The recursion limit of 10 allows multiple iterations of the workflow
(PM Agent → DB Agent → QA Agent → Lead Agent → DB Agent) while
preventing infinite loops caused by schemaDesignTool issues.

This provides more opportunities for the DB Agent to refine the schema
compared to the previous limit of 3, while still preventing long-running
failures.

See: route06/liam-internal#5642

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

Co-Authored-By: Claude <noreply@anthropic.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

♻️ Duplicate comments (1)
frontend/internal-packages/agent/README.md (1)

24-24: Fix the hard tab character.

This line contains a hard tab character. Replace it with spaces for consistency with the rest of the file.

As per coding guidelines (markdownlint-cli2 MD010).

Apply this diff:

-	leadAgent -.-> dbAgent;
+  leadAgent -.-> dbAgent;
🧹 Nitpick comments (1)
frontend/internal-packages/agent/src/db-agent/utils/convertAnalyzedRequirementsToPrompt.ts (1)

8-8: LGTM! Clean implementation of schema issues parameter.

The optional schemaIssues parameter and formatting logic correctly implements the DB Agent routing functionality described in the PR objectives. The conditional section rendering and numbered formatting are appropriate.

Consider extracting the inline type to a shared interface if this structure is used elsewhere in the workflow:

export interface SchemaIssue {
  testcaseId: string;
  description: string;
}

Then update the parameter:

-  schemaIssues?: Array<{ testcaseId: string; description: string }>,
+  schemaIssues?: SchemaIssue[],

This would improve maintainability if the schema issue structure is used across multiple files.

Also applies to: 40-43, 55-55

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between beb1f3b and 895ca3d.

📒 Files selected for processing (15)
  • frontend/internal-packages/agent/README.md (1 hunks)
  • frontend/internal-packages/agent/src/constants.ts (1 hunks)
  • frontend/internal-packages/agent/src/createGraph.integration.test.ts (2 hunks)
  • frontend/internal-packages/agent/src/createGraph.test.ts (1 hunks)
  • frontend/internal-packages/agent/src/createGraph.ts (2 hunks)
  • frontend/internal-packages/agent/src/db-agent/utils/convertAnalyzedRequirementsToPrompt.test.ts (7 hunks)
  • frontend/internal-packages/agent/src/db-agent/utils/convertAnalyzedRequirementsToPrompt.ts (2 hunks)
  • frontend/internal-packages/agent/src/lead-agent/classifyMessage/index.test.ts (1 hunks)
  • frontend/internal-packages/agent/src/lead-agent/classifyMessage/index.ts (1 hunks)
  • frontend/internal-packages/agent/src/lead-agent/utils/workflowStatus.ts (1 hunks)
  • frontend/internal-packages/agent/src/qa-agent/shared/qaAgentAnnotation.ts (2 hunks)
  • frontend/internal-packages/agent/src/qa-agent/testcaseGeneration/testcaseAnnotation.ts (2 hunks)
  • frontend/internal-packages/agent/src/workflowAnnotation.ts (2 hunks)
  • frontend/internal-packages/agent/src/workflowSchemaIssuesAnnotation.test.ts (1 hunks)
  • frontend/internal-packages/agent/src/workflowSchemaIssuesAnnotation.ts (1 hunks)
✅ Files skipped from review due to trivial changes (2)
  • frontend/internal-packages/agent/src/db-agent/utils/convertAnalyzedRequirementsToPrompt.test.ts
  • frontend/internal-packages/agent/src/lead-agent/classifyMessage/index.test.ts
🚧 Files skipped from review as they are similar to previous changes (3)
  • frontend/internal-packages/agent/src/constants.ts
  • frontend/internal-packages/agent/src/workflowSchemaIssuesAnnotation.test.ts
  • frontend/internal-packages/agent/src/createGraph.integration.test.ts
🧰 Additional context used
📓 Path-based instructions (4)
**/*.ts

📄 CodeRabbit inference engine (AGENTS.md)

Name utility files in camelCase (e.g., mergeSchema.ts)

Files:

  • frontend/internal-packages/agent/src/workflowSchemaIssuesAnnotation.ts
  • frontend/internal-packages/agent/src/lead-agent/utils/workflowStatus.ts
  • frontend/internal-packages/agent/src/qa-agent/shared/qaAgentAnnotation.ts
  • frontend/internal-packages/agent/src/createGraph.ts
  • frontend/internal-packages/agent/src/workflowAnnotation.ts
  • frontend/internal-packages/agent/src/db-agent/utils/convertAnalyzedRequirementsToPrompt.ts
  • frontend/internal-packages/agent/src/lead-agent/classifyMessage/index.ts
  • frontend/internal-packages/agent/src/createGraph.test.ts
  • frontend/internal-packages/agent/src/qa-agent/testcaseGeneration/testcaseAnnotation.ts
**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

Use TypeScript/TSX across the codebase

**/*.{ts,tsx}: Use runtime type validation with valibot for external data validation
Prefer early returns for readability
Write simple, direct code without backward compatibility shims; update all call sites together
Use const-assigned arrow functions instead of function declarations for small utilities (e.g., const toggle = () => {})
Follow existing import patterns and tsconfig path aliases

Files:

  • frontend/internal-packages/agent/src/workflowSchemaIssuesAnnotation.ts
  • frontend/internal-packages/agent/src/lead-agent/utils/workflowStatus.ts
  • frontend/internal-packages/agent/src/qa-agent/shared/qaAgentAnnotation.ts
  • frontend/internal-packages/agent/src/createGraph.ts
  • frontend/internal-packages/agent/src/workflowAnnotation.ts
  • frontend/internal-packages/agent/src/db-agent/utils/convertAnalyzedRequirementsToPrompt.ts
  • frontend/internal-packages/agent/src/lead-agent/classifyMessage/index.ts
  • frontend/internal-packages/agent/src/createGraph.test.ts
  • frontend/internal-packages/agent/src/qa-agent/testcaseGeneration/testcaseAnnotation.ts
frontend/internal-packages/**

📄 CodeRabbit inference engine (AGENTS.md)

Infra and tooling (e2e, configs, storybook, agent) live under frontend/internal-packages

Files:

  • frontend/internal-packages/agent/src/workflowSchemaIssuesAnnotation.ts
  • frontend/internal-packages/agent/src/lead-agent/utils/workflowStatus.ts
  • frontend/internal-packages/agent/src/qa-agent/shared/qaAgentAnnotation.ts
  • frontend/internal-packages/agent/src/createGraph.ts
  • frontend/internal-packages/agent/src/workflowAnnotation.ts
  • frontend/internal-packages/agent/src/db-agent/utils/convertAnalyzedRequirementsToPrompt.ts
  • frontend/internal-packages/agent/src/lead-agent/classifyMessage/index.ts
  • frontend/internal-packages/agent/src/createGraph.test.ts
  • frontend/internal-packages/agent/src/qa-agent/testcaseGeneration/testcaseAnnotation.ts
  • frontend/internal-packages/agent/README.md
**/*.test.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

Write unit tests with filenames ending in .test.ts or .test.tsx colocated near source

Files:

  • frontend/internal-packages/agent/src/createGraph.test.ts
🧬 Code graph analysis (5)
frontend/internal-packages/agent/src/lead-agent/utils/workflowStatus.ts (1)
frontend/internal-packages/agent/src/types.ts (1)
  • WorkflowState (8-8)
frontend/internal-packages/agent/src/qa-agent/shared/qaAgentAnnotation.ts (1)
frontend/internal-packages/agent/src/qa-agent/testcaseGeneration/testcaseAnnotation.ts (1)
  • qaSchemaIssuesAnnotation (17-20)
frontend/internal-packages/agent/src/workflowAnnotation.ts (1)
frontend/internal-packages/agent/src/workflowSchemaIssuesAnnotation.ts (1)
  • workflowSchemaIssuesAnnotation (19-22)
frontend/internal-packages/agent/src/lead-agent/classifyMessage/index.ts (2)
frontend/internal-packages/agent/src/types.ts (1)
  • WorkflowState (8-8)
frontend/internal-packages/agent/src/lead-agent/utils/workflowStatus.ts (2)
  • shouldRouteDBAgent (22-24)
  • isQACompleted (3-16)
frontend/internal-packages/agent/src/qa-agent/testcaseGeneration/testcaseAnnotation.ts (1)
frontend/internal-packages/agent/src/workflowSchemaIssuesAnnotation.ts (1)
  • SchemaIssue (3-6)
🪛 markdownlint-cli2 (0.18.1)
frontend/internal-packages/agent/README.md

24-24: Hard tabs
Column: 1

(MD010, no-hard-tabs)

⏰ 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-ci
  • GitHub Check: frontend-lint
  • GitHub Check: codeql / languages (javascript) / Perform CodeQL for javascript
  • GitHub Check: agent-deep-modeling
  • GitHub Check: Supabase Preview
🔇 Additional comments (13)
frontend/internal-packages/agent/src/db-agent/utils/convertAnalyzedRequirementsToPrompt.ts (2)

12-31: Efficient filtering logic.

The testcase filtering implementation correctly identifies and preserves only testcases referenced in schema issues while maintaining the category structure. Using a Set for ID lookups is an appropriate optimization.


53-53: Good semantic improvement.

Renaming the section from "Test Cases" to "Requirements" better represents the content, especially since the section can now be filtered to show only testcases with schema issues.

frontend/internal-packages/agent/src/lead-agent/utils/workflowStatus.ts (1)

18-24: LGTM! Clean separation of concerns.

The private hasSchemaIssues helper combined with the public shouldRouteDBAgent function provides a clear, intent-revealing API. The simple delegation pattern is appropriate for this use case.

frontend/internal-packages/agent/src/lead-agent/classifyMessage/index.ts (1)

5-24: LGTM! Clear priority-based routing implementation.

The three-tier priority system is well-implemented with clear comments:

  1. DB Agent for schema issues (highest priority)
  2. QA completion for workflow summarization (second priority)
  3. PM Agent as the default route

The use of early returns and the Command pattern makes the routing logic easy to follow.

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

39-40: LGTM! Essential infinite loop prevention.

Clearing schemaIssues after DB agent processing is critical to prevent infinite routing loops. This ensures the DB Agent is invoked only once per set of schema issues, then control returns to the Lead Agent for the next routing decision.


94-97: LGTM! Enables priority-based DB routing.

The addition of dbAgent to the conditional edges correctly implements the new routing path from leadAgent to dbAgent when schema issues are detected by classifyMessage.

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

23-23: LGTM! Test updated to match new routing edge.

The expected Mermaid diagram correctly includes the new leadAgent -.-> dbAgent conditional edge, ensuring the test validates the updated graph structure.

frontend/internal-packages/agent/src/qa-agent/shared/qaAgentAnnotation.ts (1)

6-6: LGTM! Improved naming clarity.

The rename to qaSchemaIssuesAnnotation clearly distinguishes QA-level schema issues from workflow-level issues, improving code organization and maintainability.

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

4-4: LGTM! Clear separation of workflow-level schema issues.

The switch to workflowSchemaIssuesAnnotation establishes a clear distinction between workflow-level and QA-level schema issue handling. This separation enables different reducer semantics (replacement vs. concat) appropriate for each level.

Also applies to: 20-20

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

1-22: LGTM! Well-designed annotation with clear documentation.

This new workflow-level annotation is well-implemented:

  1. Correct reducer semantics: The replacement reducer (next ?? prev) enables clearing schema issues by setting schemaIssues: [], which is essential for preventing infinite routing loops after DB agent processing.

  2. Clear documentation: The inline comments explain the rationale for using replacement instead of concat, and contrast it with the QA agent's annotation, which helps maintainers understand the design decision.

  3. Simple type definition: The SchemaIssue type with testcaseId and description is appropriate for tracking schema validation issues.

frontend/internal-packages/agent/src/qa-agent/testcaseGeneration/testcaseAnnotation.ts (3)

3-3: LGTM! Type centralization improves maintainability.

Importing SchemaIssue from a shared location eliminates duplication and ensures consistency across the workflow and QA-level annotations.


6-20: Excellent documentation explaining the concat reducer choice. The doc comment clearly articulates why concat is used for parallel processing and how this differs from the workflow-level annotation, which uses replacement semantics (next ?? prev).


17-17: Approve rename – qaSchemaIssuesAnnotation is clear, usage at line 37 updated, and no stale schemaIssuesAnnotation references remain.

Update test snapshots to match the new Schema Issues section format:
- Add blank lines between Requirements and Schema Issues sections
- Update test to verify Schema Issues are displayed (not hidden)

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

Co-Authored-By: Claude <noreply@anthropic.com>
Copy link
Member

@junkisai junkisai left a comment

Choose a reason for hiding this comment

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

It seems good that the implementation returns to the dbAgent when an issue occurs!

Comment on lines +7 to +12
if (shouldRouteDBAgent(state)) {
return new Command({
update: { next: 'dbAgent' },
goto: END,
})
}
Copy link
Member

Choose a reason for hiding this comment

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

👍

@junkisai
Copy link
Member

@MH4GF
It seems a conflict has occurred, so could you please resolve it? 🙏

@MH4GF
Copy link
Member Author

MH4GF commented Oct 10, 2025

@junkisai Thanks! I'll fix the conflicts and merge it!

…b-agent

> Conflicts:
>	frontend/internal-packages/agent/src/qa-agent/shared/qaAgentAnnotation.ts
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