Docs/r3-x/AI Agent System

AI Agent System

How the multi-step AI agent creates content for your social media posts.


Overview

R3-X uses a multi-step AI agent built with the Vercel AI SDK's ToolLoopAgent. The agent has access to specialized tools that it calls in sequence to create optimized social media content.

Agent Workflow

The agent follows this general flow:

  1. Get Previous Posts — Retrieves your recent posts to maintain consistency
  2. Analyze Images — Uses vision AI to understand your uploaded photos
  3. Think in Steps — Plans the content strategy
  4. Select Images — Chooses the best photos for the post
  5. Create Images (optional) — Generates new AI images with Gemini
  6. Deliver Content — Outputs platform-specific captions and selected images

Tools

getPreviousPosts

Retrieves your most recent posts to help the AI maintain brand consistency and avoid repetitive content.

analyzeImages

Uses vision AI to analyze uploaded photos. The agent understands:

  • What's in the image (objects, people, scenes)
  • Image quality and composition
  • Which images work best together
  • Color palettes and visual themes

selectImages

Selects the best images from your uploads based on the content strategy. The agent considers:

  • Relevance to the post topic
  • Image quality
  • Visual variety in carousel posts

createImage

Generates new AI images using Gemini. Supports two modes:

  • Compose mode — Sends your reference photos directly to Gemini to create new images that incorporate elements from your originals
  • Reference mode — Uses your photos as style references for generating new scenes

Images are generated at 2K resolution for maximum quality.

askQuestion

When the agent needs clarification, it can ask you questions before proceeding. This ensures the output matches your intent.

deliverContent

The final tool that outputs:

  • Platform-specific captions (X/Twitter, Instagram, Facebook)
  • Selected image indices
  • Hashtag suggestions

Personas

Personas define how the AI writes content. Each persona has:

  • Name — e.g., "Professional", "Casual", "Witty"
  • Description — The tone and style guidelines
  • Platform preferences — How to adapt content for each platform

Tips

  • Upload high-quality photos for better AI analysis
  • Be specific in your prompts for better results
  • Use personas to maintain consistent brand voice
  • The agent works best with 3-10 uploaded photos