feat: thread reply edit vs generate logic (REC-68)#439
feat: thread reply edit vs generate logic (REC-68)#439recoup-coding-agent wants to merge 1 commit intotestfrom
Conversation
When a user tags the Recoup Content Agent in the thread of existing content, the bot now: - Classifies user intent as "edit" or "generate" using an AI agent - For edits: parses natural-language edit instructions into ffmpeg operations (trim, crop, resize, overlay_text) and triggers the ffmpeg-edit task with the previously generated video URL - For new generation: re-runs the full content creation pipeline with new parameters parsed from the reply Key changes: - ContentAgentThreadState stores videoUrls on completion - handleContentAgentCallback persists video URLs in thread state - New AI agents: createContentIntentAgent (edit vs generate), createEditOperationsAgent (NL to ffmpeg ops) - registerOnSubscribedMessage handles completed/failed/timeout states - triggerEditContent wraps ffmpeg-edit task triggering Co-Authored-By: Paperclip <noreply@paperclip.ing>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Warning Rate limit exceeded
Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 59 minutes and 42 seconds. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (8)
✨ Finishing Touches🧪 Generate unit tests (beta)
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 |
There was a problem hiding this comment.
2 issues found across 8 files
Confidence score: 3/5
- There is a concrete regression risk in
lib/agents/content/createEditOperationsAgent.ts:cropoperations may pass validation without crop parameters, which can send invalid payloads to the ffmpeg edit task and fail at runtime. lib/agents/content/handlers/registerOnSubscribedMessage.tsis flagged for maintainability (over 100 lines, mixed responsibilities), which increases future change risk even if it may not immediately break behavior.- Given a medium-severity runtime validation gap plus structural complexity concerns, this is mergeable with caution but carries some user-impacting risk if unaddressed.
- Pay close attention to
lib/agents/content/createEditOperationsAgent.tsandlib/agents/content/handlers/registerOnSubscribedMessage.ts- crop validation correctness and module split/readability are the key risk areas.
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="lib/agents/content/handlers/registerOnSubscribedMessage.ts">
<violation number="1" location="lib/agents/content/handlers/registerOnSubscribedMessage.ts:2">
P1: Custom agent: **Enforce Clear Code Style and Maintainability Practices**
This file now exceeds the 100-line limit and bundles multiple responsibilities in one module. Split the edit/generate helpers into smaller files to keep this file under 100 lines as required by the maintainability rule.</violation>
</file>
<file name="lib/agents/content/createEditOperationsAgent.ts">
<violation number="1" location="lib/agents/content/createEditOperationsAgent.ts:13">
P2: `crop` operations can validate without any crop parameters, allowing invalid edit payloads to be sent to the ffmpeg edit task.</violation>
</file>
Architecture diagram
sequenceDiagram
participant User as User (Slack/Client)
participant Bot as Content Agent
participant State as Thread State Store
participant AI as AI Agents (Intent/Edit)
participant Tasks as Trigger.dev (Tasks)
participant Callback as handleContentAgentCallback
User->>Bot: Replies to existing thread
Bot->>State: Fetch thread state
State-->>Bot: { status, videoUrls, artistAccountId, ... }
alt status == "running"
Bot-->>User: "Still generating..."
else status == "failed" / "timeout"
Bot-->>User: "Please start a new thread"
else status == "completed"
Note over Bot,AI: NEW: Decision Logic (REC-68)
Bot->>AI: NEW: parseContentIntent(message, context)
AI-->>Bot: { action: "edit" | "generate" }
alt action == "edit"
Bot->>AI: NEW: parseEditOperations(message)
AI-->>Bot: { operations, template }
Note over Bot,Tasks: NEW: Edit Execution Flow
Bot->>Tasks: NEW: triggerEditContent(videoUrl, operations)
Tasks-->>Bot: runId
else action == "generate"
Note over Bot,Tasks: Re-run Generation Flow
Bot->>Tasks: triggerCreateContent(newParams)
Tasks-->>Bot: runIds
end
Bot->>State: updateState({ status: "running", runIds })
Bot->>Tasks: triggerPollContentRun(runIds, threadId)
Bot-->>User: Post Task Card ("Started")
end
Note over Tasks,Callback: Background Processing
Tasks->>Callback: Task Success (Webhook)
Callback->>State: CHANGED: Persist videoUrls in state
Callback->>State: updateState({ status: "completed" })
Callback-->>User: Post final media results
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review, or fix all with cubic.
| @@ -1,8 +1,42 @@ | |||
| import type { ContentAgentBot } from "../bot"; | |||
There was a problem hiding this comment.
P1: Custom agent: Enforce Clear Code Style and Maintainability Practices
This file now exceeds the 100-line limit and bundles multiple responsibilities in one module. Split the edit/generate helpers into smaller files to keep this file under 100 lines as required by the maintainability rule.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At lib/agents/content/handlers/registerOnSubscribedMessage.ts, line 2:
<comment>This file now exceeds the 100-line limit and bundles multiple responsibilities in one module. Split the edit/generate helpers into smaller files to keep this file under 100 lines as required by the maintainability rule.</comment>
<file context>
@@ -1,8 +1,42 @@
import type { ContentAgentBot } from "../bot";
+import type { ContentAgentThreadState } from "../types";
+import { parseContentIntent } from "../parseContentIntent";
+import { parseEditOperations } from "../parseEditOperations";
</file context>
| duration: z.number().positive().describe("Duration in seconds."), | ||
| }), | ||
| z.object({ | ||
| type: z.literal("crop"), |
There was a problem hiding this comment.
P2: crop operations can validate without any crop parameters, allowing invalid edit payloads to be sent to the ffmpeg edit task.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At lib/agents/content/createEditOperationsAgent.ts, line 13:
<comment>`crop` operations can validate without any crop parameters, allowing invalid edit payloads to be sent to the ffmpeg edit task.</comment>
<file context>
@@ -0,0 +1,87 @@
+ duration: z.number().positive().describe("Duration in seconds."),
+ }),
+ z.object({
+ type: z.literal("crop"),
+ aspect: z.string().optional().describe('Aspect ratio like "9:16", "1:1", "16:9".'),
+ width: z.number().int().positive().optional(),
</file context>
Summary
Changes
lib/agents/content/types.ts— AddvideoUrlsandimageUrlstoContentAgentThreadStatelib/agents/content/handleContentAgentCallback.ts— Store video URLs in thread state on completionlib/agents/content/createContentIntentAgent.ts— New AI agent for edit vs generate classificationlib/agents/content/parseContentIntent.ts— Wrapper for intent classificationlib/agents/content/createEditOperationsAgent.ts— New AI agent for parsing NL edit instructions into ffmpeg opslib/agents/content/parseEditOperations.ts— Wrapper for edit operations parsinglib/trigger/triggerEditContent.ts— New trigger function for ffmpeg-edit tasklib/agents/content/handlers/registerOnSubscribedMessage.ts— Full rewrite with edit/generate/running/failed state handlingRelated
Test plan
🤖 Generated with Claude Code
Summary by cubic
Implements REC-68 by letting the Content Agent classify thread replies as “edit” or “generate” and run the right flow. Adds NL-to-ffmpeg edit parsing and persists video URLs for smooth follow-up edits.
editorgenerateto meet REC-68.ffmpeg-editvia@trigger.dev/sdk, and polls results.videoUrls/imageUrlsin thread state on completion for chained edits.Written for commit 3506958. Summary will update on new commits.