Testing Image Analysis

This guide explains how to verify that the image analysis feature is working correctly when monitoring Twitter timelines.

Prerequisites

  1. OpenAI API Key: Ensure OPENAI_API_KEY is set in your .env file

  2. Twitter Authentication: Run bun run auth:twitter if not already authenticated

  3. Database Access: Supabase credentials configured

Testing Methods

Method 1: Check Current Status

Run the check script to see current image analysis status:

bun run agent/plugins/twitter/scripts/check-image-analysis.ts

This shows:

  • Total tweets with images

  • How many were AI-analyzed

  • Screenshot detection stats

  • Account-specific analysis

Method 2: Manual Timeline Monitoring

Trigger timeline monitoring for a specific account:

This will:

  1. Fetch recent tweets from the account

  2. Process any images found

  3. Show you the analysis results

Method 3: Database Query

Run SQL queries directly in Supabase (see agent/plugins/twitter/sql/check-image-analysis.sql for more queries):

Method 4: Watch Timeline Monitoring Logs

When the Twitter plugin is running, it monitors timelines every 30 minutes. Watch the logs:

Understanding Results

Successful AI Analysis

When image analysis is working, you'll see descriptions like:

Or for screenshots:

Default Description

If you see "Image attached to tweet", it means:

  • Image wasn't analyzed (no OpenAI key or error)

  • Analysis failed

  • Image already had alt text

Troubleshooting

  1. All images show "Image attached to tweet"

    • Check: Is OPENAI_API_KEY set?

    • Run: echo $OPENAI_API_KEY to verify

    • Test: bun run agent/plugins/twitter/tests/ImageAnalysisService.test.ts

  2. Some images fail

    • Check logs for "Error analyzing image"

    • Common issues:

      • Image URL not accessible

      • Image too large

      • Rate limiting

  3. No tweets with images found

    • Monitor accounts that post images frequently

    • Try: elonmusk, NASA, NatGeo

Expected Performance

  • Analysis Time: 2-3 seconds per image

  • Batch Processing: 2 images concurrently

  • Rate Limiting: 1.5s delay between batches

  • Cache: Previously analyzed images are cached

Testing Image Analysis Service Directly

Monitoring in Production

  1. Regular Checks: Run check script daily

  2. SQL Monitoring: Use provided SQL queries

  3. Log Analysis: Monitor for analysis errors

  4. Cost Tracking: Monitor OpenAI API usage

Important Accounts to Monitor

For best testing results, monitor these accounts:

  • @realDonaldTrump: Truth Social screenshots

  • @elonmusk: Memes and charts

  • @naval: Quote images

  • @NatGeo: High-quality photos

  • @NASA: Space images

Success Metrics

Image analysis is working well when:

  • ✅ 80%+ of images have AI descriptions

  • ✅ Screenshots are detected with text extraction

  • ✅ Topics and sentiment are identified

  • ✅ No repeated API errors in logs

Last updated