-
Notifications
You must be signed in to change notification settings - Fork 176
feat: implement DB Agent routing in LangGraph workflow #3496
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
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Note Other AI code review bot(s) detectedCodeRabbit 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. WalkthroughAdds 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
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`
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
Pre-merge checks and finishing touches❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro 📒 Files selected for processing (4)
🧰 Additional context used📓 Path-based instructions (4)**/*.ts📄 CodeRabbit inference engine (AGENTS.md)
Files:
**/*.test.{ts,tsx}📄 CodeRabbit inference engine (AGENTS.md)
Files:
**/*.{ts,tsx}📄 CodeRabbit inference engine (AGENTS.md)
Files:
frontend/internal-packages/**📄 CodeRabbit inference engine (AGENTS.md)
Files:
🧬 Code graph analysis (4)frontend/internal-packages/agent/src/createGraph.integration.test.ts (1)
frontend/internal-packages/agent/src/lead-agent/classifyMessage/index.test.ts (3)
frontend/internal-packages/agent/src/qa-agent/shared/qaAgentAnnotation.ts (1)
frontend/internal-packages/agent/src/workflowAnnotation.ts (1)
⏰ 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)
🔇 Additional comments (8)
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. Comment |
Updates to Preview Branch (classify-message-to-db-agent) ↗︎
Tasks are run on every commit but only new migration files are pushed.
View logs for this Workflow Run ↗︎. |
There was a problem hiding this 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. UseisAIMessage(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 forleadAgentSubgraph
, 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.mock
screateDbAgentGraph
to record invocations and runs one PM cycle to ensure zero calls whenschemaIssues.length === 0
. Want me to draft it?
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 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 resettinganalyzedRequirementsRetryCount
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 viaEND
when schema issues exist.
14-17
: LGTM: QA and PM paths behave as specified.Routes to
summarizeWorkflow
when QA completed; otherwise defaults to PM viaEND
.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.
There was a problem hiding this 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
📒 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 clearedcreateGraph.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.
cd91d33
to
58614db
Compare
There was a problem hiding this 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
📒 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).
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>
beb1f3b
to
895ca3d
Compare
There was a problem hiding this 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
📒 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 publicshouldRouteDBAgent
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:
- DB Agent for schema issues (highest priority)
- QA completion for workflow summarization (second priority)
- 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 fromleadAgent
todbAgent
when schema issues are detected byclassifyMessage
.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:
Correct reducer semantics: The replacement reducer (
next ?? prev
) enables clearing schema issues by settingschemaIssues: []
, which is essential for preventing infinite routing loops after DB agent processing.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.
Simple type definition: The
SchemaIssue
type withtestcaseId
anddescription
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 staleschemaIssuesAnnotation
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>
There was a problem hiding this 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!
if (shouldRouteDBAgent(state)) { | ||
return new Command({ | ||
update: { next: 'dbAgent' }, | ||
goto: END, | ||
}) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
@MH4GF |
@junkisai Thanks! I'll fix the conflicts and merge it! |
…b-agent > Conflicts: > frontend/internal-packages/agent/src/qa-agent/shared/qaAgentAnnotation.ts
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:
Key Changes
Graph Architecture
dbAgent
conditional edge to main graph increateGraph.ts
Classification Logic
classifyMessage
with priority-based routing systemshouldRouteDBAgent
helper to check for schema issueshasSchemaIssues
utility to validate workflow stateSchema Issues Management
schemaIssues
annotation for workflow-level and QA agent-level trackingDB Agent Prompt Improvements
Recursion Limit
Testing
Test Plan
🤖 Generated with Claude Code
Co-Authored-By: Claude noreply@anthropic.com
Summary by CodeRabbit
New Features
Bug Fixes
Documentation
Tests