Skip to content

Conversation

Copy link

Copilot AI commented Nov 15, 2025

Converts tweet_agent.py from one-off script to autonomous agent that continuously generates and posts tweets in Moon Dev's writing style, following the phased transformation workflow specified in the issue.

Changes

Personality Customization

  • Updated TWEET_PROMPT manifest with 14-point personality profile: lowercase style, strategic emoji use (🚀 🌙 💰 🤖 ⚡ 🎯), tech jargon with simple explanations, community-focused language, focus on AI/trading/crypto/futurism

Continuous Operation Architecture

  • Added while True: loop in main block following sentiment_agent.py pattern
  • Configurable intervals via TWEET_INTERVAL_SECONDS (default: 900s) and TWEET_POST_DELAY_SECONDS (default: 10s) in config.py
  • Graceful shutdown on keyboard interrupt with error recovery

Twitter API Integration

  • Implemented post_tweet() method with Twitter API v2 via tweepy
  • 280-character validation with automatic truncation
  • Graceful degradation: operates in safe mode without credentials (file-only output)
  • Rate limit protection via configurable delays between posts

Path Portability

  • Replaced hardcoded paths (/Users/md/Dropbox/...) with PROJECT_ROOT-relative paths
  • Changed USE_TEXT_FILE default to False for standalone operation

Configuration & Documentation

  • Added Twitter credential placeholders to config.py and .env_example
  • Comprehensive documentation in docs/tweet_agent.md with quick start, customization, and troubleshooting

Usage

Safe mode (no posting):

python src/agents/tweet_agent.py

Auto-posting mode:

# Add to .env:
TWITTER_API_KEY=...
TWITTER_API_SECRET=...
TWITTER_ACCESS_TOKEN=...
TWITTER_ACCESS_TOKEN_SECRET=...

# Run:
python src/agents/tweet_agent.py

Agent generates tweets every 15 minutes, posts if credentials provided, saves to src/data/tweets/generated_tweets_TIMESTAMP.txt, continues until interrupted.

Files Modified

  • src/agents/tweet_agent.py (+177/-35): Core implementation
  • src/config.py (+12): Twitter settings
  • .env_example (+8): Credential template
  • docs/tweet_agent.md (+276/-37): Documentation

Note: tweepy already in requirements.txt (v4.14.0), no new dependencies required.

Original prompt

Agent Workflow Prompt: Autonomous Personality-Driven Twitter Agent

Project Goal: Transform the moondevonyt/moon-dev-ai-agents repository into an autonomous agent that emulates a specific user's writing style and Twitter personality, generating and posting tweets continuously throughout the day.

Workflow Structure: This workflow follows a phased approach. Each task is designed to be executed sequentially by an AI agent (e.g., @copilot). The output of each task serves as the input for the next, ensuring a cohesive final product.


Phase 1: Foundation & Personality Customization

Objective: To adapt the existing tweet_agent.py to understand and replicate a specific user's unique writing style.

Task 1.1: Analyze Writing Style & Create a Personality Manifest

  • Agent Persona: @copilot/agents/personality-analyst - An expert in linguistic analysis and creative writing, skilled at identifying and codifying an individual's tone, style, and personality from text.
  • Task: Analyze a provided body of text (e.g., user's blog posts, existing tweets, articles) to define their unique writing personality.
  • Input: A collection of text written by the user mostlyfutures.
  • Steps:
    1. Read and analyze the provided text samples.
    2. Identify key characteristics of the writing style:
      • Tone: (e.g., humorous, serious, cynical, optimistic, technical).
      • Vocabulary: (e.g., use of slang, jargon, formal language, specific keywords).
      • Sentence Structure: (e.g., short and punchy, long and descriptive, simple, complex).
      • Formatting: (e.g., use of emojis, hashtags, capitalization, line breaks, punctuation style).
      • Common Themes: (e.g., technology, finance, AI, futurism).
  • Goal: To produce a detailed "Personality Manifest".
  • Format Output: A Markdown section formatted exactly like the Manifest in tweet_agent.py, but tailored to the user.
    • Example Output:
      Manifest:
      - Witty and slightly cynical tone.
      - Uses tech jargon but explains it simply.
      - Prefers short, declarative sentences.
      - Frequently uses the '🤔' and '🚀' emojis.
      - Avoids capitalization for a more casual feel.
      - Often talks about AI, decentralization, and market trends.
      - Hashtags should be lowercase and appended at the very end (e.g., #aifuture).

Task 1.2: Implement the Personality Manifest

  • Agent Persona: @copilot/agents/python-expert - A developer specializing in modifying and refactoring existing Python code.
  • Task: Hardcode the new, personalized Manifest into the tweet_agent.py script.
  • Input: The tweet_agent.py file and the Personality Manifest from Task 1.1.
  • Steps:
    1. Open src/agents/tweet_agent.py.
    2. Locate the TWEET_PROMPT multi-line string variable.
    3. Replace the entire existing Manifest: block with the new Personality Manifest created in the previous task.
  • Goal: To permanently alter the agent's core personality prompt.
  • Format Output: The modified src/agents/tweet_agent.py file.

Phase 2: Architectural Transformation for Continuous Operation

Objective: To refactor the agent from a one-off script into a service that runs continuously and posts automatically.

Task 2.1: Design Continuous Scheduling & Automated Posting Architecture

  • Agent Persona: @copilot/agents/system-architect - A senior engineer who designs robust, scalable, and fault-tolerant systems.
  • Task: Design the architectural changes needed for the TweetAgent to run on a schedule and post to Twitter automatically.
  • Input: The entire moondevonyt/moon-dev-ai-agents repository structure.
  • Steps:
    1. Scheduling: Propose a scheduling mechanism. Draw inspiration from sentiment_agent.py's CHECK_INTERVAL_MINUTES. The main execution block should contain a while True: loop with a time.sleep() call to pause between runs. The interval should be configurable.
    2. Auto-Posting: Propose integrating a Twitter API client. The recommended library is tweepy. The design should include a new function, e.g., post_tweet(text), within the TweetAgent class.
    3. Configuration: Propose a centralized configuration file (config.py or similar) to store TWITTER_API_KEY, TWITTER_API_SECRET, ACCESS_TOKEN, ACCESS_TOKEN_SECRET, and TWEET_INTERVAL_SECONDS. This avoids hardcoding secrets.
    4. Error Handling: Plan for potential errors like API rate limits, network failures, or invalid credentials. The agent should log errors and continue running.
  • Goal: A clear architectural plan for the transformation.
  • Format Output: A Markdown document outlining the plan with code snippets for the proposed main loop, new functions, and configuration structure.

**...


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 3 commits November 15, 2025 22:09
…ontinuous posting

Co-authored-by: mostlyfutures <199047654+mostlyfutures@users.noreply.github.com>
Co-authored-by: mostlyfutures <199047654+mostlyfutures@users.noreply.github.com>
Co-authored-by: mostlyfutures <199047654+mostlyfutures@users.noreply.github.com>
Copilot AI changed the title [WIP] Update tweet agent for user writing style adaptation Transform tweet agent into autonomous personality-driven continuous posting system Nov 15, 2025
Copilot AI requested a review from mostlyfutures November 15, 2025 22:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants