Skip to content

feat: add email-agent kit — AI-powered email verifier and reply drafter#246

Open
kr1shnaakhurana wants to merge 13 commits into
Lamatic:mainfrom
kr1shnaakhurana:feat/email-agent
Open

feat: add email-agent kit — AI-powered email verifier and reply drafter#246
kr1shnaakhurana wants to merge 13 commits into
Lamatic:mainfrom
kr1shnaakhurana:feat/email-agent

Conversation

@kr1shnaakhurana

@kr1shnaakhurana kr1shnaakhurana commented Jul 14, 2026

Copy link
Copy Markdown

Summary

Adds the Email Agent kit — an AI-powered email workspace built on Lamatic with two flows:

  1. Email Verifier — Analyzes emails for legitimacy, intent, urgency. Returns verdict (legit/suspicious/spam) with confidence score and reasons.
  2. Email Replier — Drafts context-aware professional replies using verification summary as context (sequential pipeline).

What's Included

  • lamatic.config.ts — Kit metadata
  • flows/ — Verifier + replier flow definitions
  • prompts/ — LLM system prompts
  • apps/ — Next.js 16 dashboard (verify + reply modes, dark mode, shadcn/ui)

How It Works

User inputs email → Verifier flow → verdict JSON → (for reply) Replier flow → draft reply

Field Value
Author Krishna Khurana
Version 1.0.0
Tags email, verification, reply, support
  • Adds Email Agent Kit v1.0.0 (Lamatic kit) with a Next.js dashboard for email verification and context-aware reply drafting.
  • Adds kit config/docs/env:
    • kits/email-agent/lamatic.config.ts
    • kits/email-agent/README.md
    • kits/email-agent/agent.md
    • kits/email-agent/constitutions/default.md
    • kits/email-agent/.env.example
    • kits/email-agent/.gitignore
  • Adds Lamatic flow definitions (no flow.json in this kit; flows are defined in TS):
    • kits/email-agent/flows/email-verifier.ts
      • Nodes/edges: triggerNode_1 (uses advance_schema for sender/subject/body) → LLMNode_100 (“Verify Email”) → graphqlResponseNode_200 (maps LLMNode_100.output.generatedResponse to output)
      • High level: calls verifier LLM with the verifier system prompt/constitution and returns structured Markdown verification output.
    • kits/email-agent/flows/email-replier.ts
      • Nodes/edges: triggerNode_1 (uses advance_schema for sender/subject/body, with optional verdict/confidence/reasons) → LLMNode_100 (“Draft Reply”) → graphqlResponseNode_200 (maps LLMNode_100.output.generatedResponse to output)
      • High level: injects verifier results into the replier prompt as “Verification Audit” and returns the drafted reply text.
  • Adds LLM model config + system prompts:
    • kits/email-agent/model-configs/email-verifier_generate-text.ts
    • kits/email-agent/model-configs/email-replier_generate-text.ts
    • kits/email-agent/prompts/email-verifier_generate-text_system.md
    • kits/email-agent/prompts/email-replier_generate-text_system.md
  • Adds Next.js dashboard app + orchestration:
    • kits/email-agent/apps/.env.example
    • kits/email-agent/apps/.gitignore
    • kits/email-agent/apps/package.json
    • kits/email-agent/apps/package-lock.json
    • kits/email-agent/apps/tsconfig.json
    • kits/email-agent/apps/next-env.d.ts
    • kits/email-agent/apps/next.config.mjs
    • kits/email-agent/apps/postcss.config.mjs
    • kits/email-agent/apps/components.json
    • kits/email-agent/apps/orchestrate.js (sequential orchestration: verifierreplier, both mode: "sync", with expectedOutput: "output")
    • kits/email-agent/apps/actions/orchestrate.ts
      • verifyEmail(...): executes verifier flow and formats output as a Markdown verdict (parses serialized JSON when needed).
      • replyEmail(...): executes verifier first, extracts verdict/confidence/reasons from parsed output, then executes replier flow with these values.
    • kits/email-agent/apps/test-api.js (manual GraphQL executeWorkflow tester)
    • kits/email-agent/apps/app/layout.tsx
    • kits/email-agent/apps/app/page.tsx (UI with verify vs reply modes, loading/error handling, copy/reset)
    • kits/email-agent/apps/app/globals.css (Tailwind + dark mode tokens)
    • kits/email-agent/apps/components/header.tsx
    • kits/email-agent/apps/components/theme-provider.tsx
    • kits/email-agent/apps/lib/lamatic-client.ts (env validation + Lamatic client)
    • kits/email-agent/apps/lib/utils.ts (cn Tailwind class merger)
    • kits/email-agent/apps/components/ui/button.tsx
    • kits/email-agent/apps/components/ui/card.tsx
    • kits/email-agent/apps/components/ui/input.tsx
    • kits/email-agent/apps/components/ui/label.tsx
    • kits/email-agent/apps/components/ui/select.tsx
    • kits/email-agent/apps/components/ui/textarea.tsx

@coderabbitai

coderabbitai Bot commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

@kr1shnaakhurana, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 22 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Repository UI (base), Organization UI (inherited)

Review profile: ASSERTIVE

Plan: Pro

Run ID: cf9f1091-9b36-4a7f-b12d-ea238ad65821

📥 Commits

Reviewing files that changed from the base of the PR and between 1b6d77c and 5fb703f.

📒 Files selected for processing (1)
  • kits/email-agent/apps/actions/orchestrate.ts

Walkthrough

Changes

The Email Agent kit adds Lamatic verifier and replier workflows, credentialed execution, a Next.js dashboard for submitting emails and viewing results, and setup documentation and configuration.

Changes

Email Agent

Layer / File(s) Summary
Email workflow definitions
kits/email-agent/constitutions/default.md, kits/email-agent/flows/*, kits/email-agent/model-configs/*, kits/email-agent/prompts/*
Defines verifier and replier flows, LLM nodes, prompts, model references, input schemas, output mappings, and behavioral rules.
Workflow execution integration
kits/email-agent/apps/actions/orchestrate.ts, kits/email-agent/apps/orchestrate.js, kits/email-agent/apps/lib/*, kits/email-agent/apps/test-api.js
Configures workflow execution, validates credentials, formats verification results, drafts replies using verification context, and provides an API test script.
Next.js dashboard interface
kits/email-agent/apps/app/*, kits/email-agent/apps/components/*, kits/email-agent/apps/lib/utils.ts
Adds the email workspace UI, mode switching, form validation, result rendering, copy/reset actions, theme styling, reusable controls, navigation, and class-name utilities.
Kit packaging and setup
kits/email-agent/README.md, kits/email-agent/agent.md, kits/email-agent/lamatic.config.ts, kits/email-agent/apps/package.json, kits/email-agent/apps/tsconfig.json, kits/email-agent/apps/next.config.mjs, kits/email-agent/apps/postcss.config.mjs, kits/email-agent/apps/components.json, kits/email-agent/.env.example, kits/email-agent/**/.gitignore, kits/email-agent/apps/next-env.d.ts
Documents installation and environment setup, declares kit metadata and workflow steps, configures the application toolchain, and ignores local or generated artifacts.

Suggested reviewers: amanintech, d-pamneja

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description summarizes the kit, but it omits the required PR Checklist sections and several template items. Restructure the description to match the template: add the PR Checklist sections, select contribution type, and cover config/files/env/validation requirements.
✅ Passed checks (4 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly names the kit and its main purpose, matching the email verifier/replier changes.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@github-actions

github-actions Bot commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

:robot_face: AgentKit Structural Validation

New Contributions Detected

  • Kit: kits/email-agent

Check Results

Check Status
No edits to existing kits ✅ Pass
Required root files present ✅ Pass
Flow .ts files present ✅ Pass
lamatic.config.ts valid ✅ Pass
No changes outside kits/ ✅ Pass

🎉 All checks passed! This contribution follows the AgentKit structure.

@coderabbitai

coderabbitai Bot commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

Caution

Failed to replace (edit) comment. This is likely due to insufficient permissions or the comment being deleted.

Error details
putComment timed out

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 12

Caution

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

⚠️ Outside diff range comments (1)
kits/email-agent/constitutions/default.md (1)

1-18: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Update the template generator to resolve formatting warnings.

Good morning, Agent. Our analysts have intercepted several MD022 (blanks-around-headings) warnings within this document. Based on learnings, this file is auto-generated from a template. Your mission, should you choose to accept it, is to infiltrate the template/source level and ensure blank lines are added after headings so all future kits inherit the corrected formatting rather than patching just this file.

This message will self-destruct in five seconds.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@kits/email-agent/constitutions/default.md` around lines 1 - 18, Update the
source template used to generate the default constitution, rather than editing
the generated default.md directly, and ensure every heading in the generated
output has a blank line after it to satisfy MD022. Preserve the existing heading
content and generation behavior.

Source: Learnings

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@kits/email-agent/apps/actions/orchestrate.ts`:
- Around line 55-57: Update the result extraction in
kits/email-agent/apps/actions/orchestrate.ts at lines 55-57 to use
resData?.result?.output, at line 101 to use verifierRes?.result?.output if that
reconnaissance step remains, and at lines 118-119 to use
replierRes?.result?.output; preserve the surrounding missing-report handling.
- Line 4: Update the import in orchestrate.ts to use ../../lamatic.config
instead of ../orchestrate.js, ensuring the action reads step definitions from
the parent kit’s configuration.
- Around line 83-115: Remove the verifier workflow lookup, validation,
execution, response extraction, and summary-generation logic from replyEmail.
Start directly with the replier execution using only the configured
replierFlow.workflowId and the supported sender, subject, and body payload
fields; also remove the unused summary and email variables and related logging.

In `@kits/email-agent/apps/app/layout.tsx`:
- Around line 6-23: Update RootLayout to apply both initialized font variables,
_geist and _geistMono, to the body className alongside the existing font-sans
and antialiased classes, ensuring the loaded typography assets are injected into
the document.

In `@kits/email-agent/apps/app/page.tsx`:
- Around line 18-20: Replace the sender, subject, and body useState form
management with react-hook-form’s useForm configured with zodResolver and a zod
schema. Update the form fields and submission flow to use the form registration,
validation, and errors while preserving the existing form behavior.

In `@kits/email-agent/apps/components/ui/button.tsx`:
- Around line 39-58: Add React.forwardRef and displayName to Button in
kits/email-agent/apps/components/ui/button.tsx:39-58, forwarding the ref to the
selected button or Slot component; wrap Card, CardHeader, CardTitle,
CardDescription, CardAction, CardContent, and CardFooter similarly in
kits/email-agent/apps/components/ui/card.tsx:5-82; wrap Label in
kits/email-agent/apps/components/ui/label.tsx:8-22, forwarding each ref to its
underlying element and exposing the corresponding displayName.

In `@kits/email-agent/apps/components/ui/input.tsx`:
- Around line 5-19: Wrap the exposed Input component in React.forwardRef while
preserving its props and className handling; apply the same ref-forwarding
pattern to Textarea in kits/email-agent/apps/components/ui/textarea.tsx (lines
5-16) and SelectTrigger plus the other exposed Select subcomponents in
kits/email-agent/apps/components/ui/select.tsx (lines 27-51). Ensure each
forwarded ref targets its underlying DOM element and existing behavior remains
unchanged.

In `@kits/email-agent/apps/next.config.mjs`:
- Around line 3-5: Remove the ignoreBuildErrors setting from the Next.js
typescript configuration so builds perform normal TypeScript verification.
Update the visible typescript configuration block in next.config.mjs without
adding another bypass or changing unrelated build settings.

In `@kits/email-agent/apps/package.json`:
- Around line 53-61: Pin the lamatic and react-markdown dependencies in
package.json to specific stable versions instead of the latest tag, preserving
the existing dependency declarations and using versions compatible with the
application.
- Line 46: Remove the autoprefixer dependency entry from the package manifest,
leaving the remaining dependencies unchanged. Do not add or modify PostCSS
configuration, since the existing setup does not reference autoprefixer.

In `@kits/email-agent/apps/test-api.js`:
- Around line 3-5: Remove the unused config import from test-api.js and update
its execution directive to invoke Node with the built-in --env-file option
targeting .env.local, while preserving the script entry point.

In `@kits/email-agent/apps/tsconfig.json`:
- Around line 36-39: Remove the two redundant malformed Windows-style
".next\\dev/types/**/*.ts" entries from the tsconfig include list, leaving the
single valid forward-slash ".next/dev/types/**/*.ts" directive unchanged.

---

Outside diff comments:
In `@kits/email-agent/constitutions/default.md`:
- Around line 1-18: Update the source template used to generate the default
constitution, rather than editing the generated default.md directly, and ensure
every heading in the generated output has a blank line after it to satisfy
MD022. Preserve the existing heading content and generation behavior.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI (base), Organization UI (inherited)

Review profile: ASSERTIVE

Plan: Pro

Run ID: 16e57db4-06b5-4795-ad74-905eea0112a6

📥 Commits

Reviewing files that changed from the base of the PR and between aabc909 and 0122aab.

⛔ Files ignored due to path filters (1)
  • kits/email-agent/apps/package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (35)
  • kits/email-agent/.gitignore
  • kits/email-agent/README.md
  • kits/email-agent/agent.md
  • kits/email-agent/apps/.env.example
  • kits/email-agent/apps/.gitignore
  • kits/email-agent/apps/actions/orchestrate.ts
  • kits/email-agent/apps/app/globals.css
  • kits/email-agent/apps/app/layout.tsx
  • kits/email-agent/apps/app/page.tsx
  • kits/email-agent/apps/components.json
  • kits/email-agent/apps/components/header.tsx
  • kits/email-agent/apps/components/theme-provider.tsx
  • kits/email-agent/apps/components/ui/button.tsx
  • kits/email-agent/apps/components/ui/card.tsx
  • kits/email-agent/apps/components/ui/input.tsx
  • kits/email-agent/apps/components/ui/label.tsx
  • kits/email-agent/apps/components/ui/select.tsx
  • kits/email-agent/apps/components/ui/textarea.tsx
  • kits/email-agent/apps/lib/lamatic-client.ts
  • kits/email-agent/apps/lib/utils.ts
  • kits/email-agent/apps/next-env.d.ts
  • kits/email-agent/apps/next.config.mjs
  • kits/email-agent/apps/orchestrate.js
  • kits/email-agent/apps/package.json
  • kits/email-agent/apps/postcss.config.mjs
  • kits/email-agent/apps/test-api.js
  • kits/email-agent/apps/tsconfig.json
  • kits/email-agent/constitutions/default.md
  • kits/email-agent/flows/email-replier.ts
  • kits/email-agent/flows/email-verifier.ts
  • kits/email-agent/lamatic.config.ts
  • kits/email-agent/model-configs/email-replier_generate-text.ts
  • kits/email-agent/model-configs/email-verifier_generate-text.ts
  • kits/email-agent/prompts/email-replier_generate-text_system.md
  • kits/email-agent/prompts/email-verifier_generate-text_system.md

Comment thread kits/email-agent/apps/actions/orchestrate.ts Outdated
Comment thread kits/email-agent/apps/actions/orchestrate.ts Outdated
Comment thread kits/email-agent/apps/actions/orchestrate.ts Outdated
Comment thread kits/email-agent/apps/app/layout.tsx
Comment thread kits/email-agent/apps/app/page.tsx
Comment thread kits/email-agent/apps/next.config.mjs
Comment thread kits/email-agent/apps/package.json
Comment thread kits/email-agent/apps/package.json
Comment thread kits/email-agent/apps/test-api.js Outdated
Comment thread kits/email-agent/apps/tsconfig.json Outdated
@akshatvirmani

Copy link
Copy Markdown
Contributor

@kr1shnaakhurana please fix the comments above

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Caution

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

⚠️ Outside diff range comments (1)
kits/email-agent/flows/email-replier.ts (1)

67-80: 🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win

Mission: route the verifier payload into the reply draft. kits/email-agent/flows/email-replier.ts:67-80 still only accepts sender, subject, and body, and kits/email-agent/apps/actions/orchestrate.ts only forwards summary, so verdict, confidence, and reasons never reach the reply prompt. Thread those fields through both stages.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@kits/email-agent/flows/email-replier.ts` around lines 67 - 80, Extend the
`inputs` definition in `email-replier.ts` to accept the verifier fields
`verdict`, `confidence`, and `reasons` alongside the existing email fields, then
update the forwarding logic in `orchestrate.ts` to pass those values into the
reply draft flow rather than forwarding only `summary`.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@kits/email-agent/flows/email-replier.ts`:
- Around line 67-80: Extend the `inputs` definition in `email-replier.ts` to
accept the verifier fields `verdict`, `confidence`, and `reasons` alongside the
existing email fields, then update the forwarding logic in `orchestrate.ts` to
pass those values into the reply draft flow rather than forwarding only
`summary`.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI (base), Organization UI (inherited)

Review profile: ASSERTIVE

Plan: Pro

Run ID: e01dfd7c-6c84-4595-a5ce-2d5f7062c53a

📥 Commits

Reviewing files that changed from the base of the PR and between dfed743 and 27bc4f3.

📒 Files selected for processing (7)
  • kits/email-agent/apps/app/page.tsx
  • kits/email-agent/apps/components/header.tsx
  • kits/email-agent/apps/next-env.d.ts
  • kits/email-agent/apps/test-api.js
  • kits/email-agent/apps/tsconfig.json
  • kits/email-agent/flows/email-replier.ts
  • kits/email-agent/flows/email-verifier.ts

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Caution

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

⚠️ Outside diff range comments (2)
kits/email-agent/apps/orchestrate.js (1)

4-38: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Align orchestrator configuration with flow specifications.

Agent, intel indicates our orchestrator config is out of sync with the updated flow definitions:

  1. The output key is the correct extraction target for both flows, not response. Update expectedOutput and outputSchema to match.
  2. The replier flow no longer utilizes the summary and email input fields. Scrub them from the inputSchema to prevent smuggling ghost variables.
🕵️ Proposed mission patch
     verifier: {
       name: "Email Verifier",
       workflowId: process.env.EMAIL_VERIFIER_FLOW_ID,
       description: "Verifies and analyzes email sender, subject, and content.",
       mode: "sync",
-      expectedOutput: "response",
+      expectedOutput: "output",
       inputSchema: {
         sender: "string",
         subject: "string",
         body: "string"
       },
       outputSchema: {
-        response: "string"
+        output: "string"
       }
     },
     replier: {
       name: "Email Replier",
       workflowId: process.env.EMAIL_REPLIER_FLOW_ID,
       description: "Generates context-aware reply drafts to inbound emails.",
       mode: "sync",
-      expectedOutput: "response",
+      expectedOutput: "output",
       inputSchema: {
         sender: "string",
         subject: "string",
         body: "string",
-        summary: "string",
-        email: "string",   // combined string: {{email}} in prompt
         verdict: "string",
         confidence: "number",
         reasons: "array"
       },
       outputSchema: {
-        response: "string"
+        output: "string"
       }
     }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@kits/email-agent/apps/orchestrate.js` around lines 4 - 38, Update both the
verifier and replier configurations to use output as the expectedOutput value
and outputSchema key instead of response. In the replier inputSchema, remove the
obsolete summary and email fields while preserving all remaining inputs.
kits/email-agent/apps/actions/orchestrate.ts (1)

100-134: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Abort transmission of ghost variables.

Agent, our latest intel confirms that the email-replier flow has evolved and no longer utilizes the summary and email variables in its prompt. Scrub these fields and their setup logic from your execution payload to keep our communications lean and untraceable.

🕵️ Proposed mission patch
-    // Extract verifier payload fields — if object, pull individual fields; else use as-is
+    // Extract verifier payload fields
     const verifierResponse = verifierRes?.result?.response
     let verdict = ""
     let confidence = 0
     let reasons: string[] = []
-    let summary = ""
 
     if (typeof verifierResponse === "object" && verifierResponse !== null) {
       const r = verifierResponse as {
         verdict?: string
         confidence?: number
         reasons?: string[]
-        summary?: string
       }
       verdict = r.verdict ?? ""
       confidence = r.confidence ?? 0
       reasons = r.reasons ?? []
-      summary = r.summary ?? ""
-    } else {
-      summary = String(verifierResponse ?? "")
     }
 
-    // Step 2: Run replier — generate-reply prompt uses {{email}} single variable
-    const emailText = `From: ${sender}\nSubject: ${subject}\n\n${body}`
-    console.log("[Email Agent] Step 2 — Running replier with email:", emailText)
+    // Step 2: Run replier
+    console.log("[Email Agent] Step 2 — Running replier...")
     const replierRes = await lamaticClient.executeFlow(replierFlow.workflowId, {
       sender,
       subject,
       body,
-      summary,
-      email: emailText,  // matches {{email}} in generate-reply_llmnode-934_user_1.md
       verdict,
       confidence,
       reasons,
     })
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@kits/email-agent/apps/actions/orchestrate.ts` around lines 100 - 134, Remove
the unused summary extraction and emailText construction from the orchestration
flow, including the summary and email fields passed to replierFlow.executeFlow.
Keep the verifier fields verdict, confidence, and reasons, along with sender,
subject, and body, unchanged in the replier payload.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@kits/email-agent/apps/actions/orchestrate.ts`:
- Around line 100-134: Remove the unused summary extraction and emailText
construction from the orchestration flow, including the summary and email fields
passed to replierFlow.executeFlow. Keep the verifier fields verdict, confidence,
and reasons, along with sender, subject, and body, unchanged in the replier
payload.

In `@kits/email-agent/apps/orchestrate.js`:
- Around line 4-38: Update both the verifier and replier configurations to use
output as the expectedOutput value and outputSchema key instead of response. In
the replier inputSchema, remove the obsolete summary and email fields while
preserving all remaining inputs.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI (base), Organization UI (inherited)

Review profile: ASSERTIVE

Plan: Pro

Run ID: a384d8d9-1145-4cfa-a2a5-31e6e44d2aaf

📥 Commits

Reviewing files that changed from the base of the PR and between 27bc4f3 and a7bbe47.

📒 Files selected for processing (3)
  • kits/email-agent/apps/actions/orchestrate.ts
  • kits/email-agent/apps/orchestrate.js
  • kits/email-agent/flows/email-replier.ts

@kr1shnaakhurana

Copy link
Copy Markdown
Author

I’ve gone through all the review comments and fixed everything I could find. Pushed the latest changes as well. If I’ve missed anything specific, just let me know and I’ll update it.

@github-actions

Copy link
Copy Markdown
Contributor

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 15, 2026

Copy link
Copy Markdown
Contributor
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Caution

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

⚠️ Outside diff range comments (2)
kits/email-agent/apps/actions/orchestrate.ts (2)

6-7: 🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win

Mission critical: Decrypt the JSON string payloads.

Agent, we have a critical flaw in your intelligence extraction. Headquarters defined outputSchema: { output: "string" } for the verifier, meaning lamaticClient.executeFlow will yield a string payload. However, your logic directly attempts to read properties from an object (or skips formatting entirely if it spots a string). This will leave you empty-handed if the payload contains a serialized JSON report.

Your mission is to safely JSON.parse() the string payload before extracting the tactical variables.

  • kits/email-agent/apps/actions/orchestrate.ts#L6-L7: Attempt to JSON.parse(response) if it's a string inside a try-catch block. If parsing succeeds, format the object into markdown; if it fails, return the string as-is. This prevents raw JSON strings from leaking into the dashboard UI.
  • kits/email-agent/apps/actions/orchestrate.ts#L101-L101: Apply a similar try-catch parsing step to verifierResponse before performing the typeof === "object" check, ensuring verdict, confidence, and reasons are properly populated for the replier flow instead of being sent as empty defaults.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@kits/email-agent/apps/actions/orchestrate.ts` around lines 6 - 7, Parse
string payloads with JSON.parse inside try-catch before processing them. In
formatVerifierResult, format successfully parsed objects into markdown and
return the original string when parsing fails; also apply the same parsing
before the typeof check on verifierResponse so verdict, confidence, and reasons
are populated. Both affected sites are in
kits/email-agent/apps/actions/orchestrate.ts: lines 6-7 and 101.

30-30: 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Import ../../lamatic.config here. kits/email-agent/apps/actions/orchestrate.ts is still pulling config from ../orchestrate.js; this action file should read the parent kit’s step definitions from ../../lamatic.config instead.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@kits/email-agent/apps/actions/orchestrate.ts` at line 30, Update the imports
used by verifyEmail in orchestrate.ts to load config from ../../lamatic.config
instead of ../orchestrate.js, ensuring the action reads the parent kit’s step
definitions.

Source: Coding guidelines

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@kits/email-agent/apps/actions/orchestrate.ts`:
- Around line 6-7: Parse string payloads with JSON.parse inside try-catch before
processing them. In formatVerifierResult, format successfully parsed objects
into markdown and return the original string when parsing fails; also apply the
same parsing before the typeof check on verifierResponse so verdict, confidence,
and reasons are populated. Both affected sites are in
kits/email-agent/apps/actions/orchestrate.ts: lines 6-7 and 101.
- Line 30: Update the imports used by verifyEmail in orchestrate.ts to load
config from ../../lamatic.config instead of ../orchestrate.js, ensuring the
action reads the parent kit’s step definitions.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI (base), Organization UI (inherited)

Review profile: ASSERTIVE

Plan: Pro

Run ID: 8712f67c-d470-4a24-9cd0-b11cad5313cf

📥 Commits

Reviewing files that changed from the base of the PR and between a7bbe47 and 4f5b594.

📒 Files selected for processing (8)
  • kits/email-agent/apps/actions/orchestrate.ts
  • kits/email-agent/apps/app/page.tsx
  • kits/email-agent/apps/orchestrate.js
  • kits/email-agent/apps/test-api.js
  • kits/email-agent/flows/email-replier.ts
  • kits/email-agent/flows/email-verifier.ts
  • kits/email-agent/model-configs/email-replier_generate-text.ts
  • kits/email-agent/model-configs/email-verifier_generate-text.ts
💤 Files with no reviewable changes (5)
  • kits/email-agent/apps/test-api.js
  • kits/email-agent/model-configs/email-replier_generate-text.ts
  • kits/email-agent/model-configs/email-verifier_generate-text.ts
  • kits/email-agent/flows/email-verifier.ts
  • kits/email-agent/flows/email-replier.ts

- formatVerifierResult: attempt JSON.parse on string responses
  before extracting verdict/confidence/reasons/summary fields;
  fall back to raw string if parsing fails, preventing serialised
  JSON from leaking into the dashboard UI as plain text.

- replyEmail: apply the same try-catch JSON.parse step on
  verifierRaw before the typeof check so verdict, confidence, and
  reasons are properly populated for the replier flow instead of
  being sent as empty defaults ('', 0, []).

Fixes: outputSchema { output: 'string' } means executeFlow always
yields a JSON string, not a plain object.
@kr1shnaakhurana

Copy link
Copy Markdown
Author

@coderabbitai resume

@coderabbitai

coderabbitai Bot commented Jul 16, 2026

Copy link
Copy Markdown
Contributor
✅ Action performed

Reviews resumed.

@kr1shnaakhurana

Copy link
Copy Markdown
Author

@coderabbitai resume

@coderabbitai

coderabbitai Bot commented Jul 16, 2026

Copy link
Copy Markdown
Contributor
✅ Action performed

Reviews resumed.

…nd remove redundant verifier call

- Replace import from ../orchestrate.js with ../../lamatic.config.
  Workflow IDs are now resolved via steps[].envKey + process.env,
  extracted into a getWorkflowId() helper for DRY access.

- Remove unnecessary verifier execution from replyEmail. The
  email-replier flow only uses sender/subject/body in its prompt
  and ignores verdict/confidence/reasons, so running the verifier
  as Step 1 was wasteful. replyEmail now calls the replier
  directly in a single flow execution.
@kr1shnaakhurana

Copy link
Copy Markdown
Author

@coderabbitai resume

@coderabbitai

coderabbitai Bot commented Jul 16, 2026

Copy link
Copy Markdown
Contributor
✅ Action performed

Reviews resumed.

@kr1shnaakhurana

Copy link
Copy Markdown
Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 16, 2026

Copy link
Copy Markdown
Contributor
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@kr1shnaakhurana

Copy link
Copy Markdown
Author

@coderabbitai resolve

@coderabbitai

coderabbitai Bot commented Jul 16, 2026

Copy link
Copy Markdown
Contributor
✅ Action performed

Comments resolved and changes approved.

@kr1shnaakhurana

Copy link
Copy Markdown
Author

@akshatvirmani

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants