Skip to content

[POC] Add Tweet Functionality to ACP Plugin #7

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

Ang-dot
Copy link
Contributor

@Ang-dot Ang-dot commented May 16, 2025

Tweet History Management Improvements

Overview

This PR adds tweet history management in the ACP plugin by introducing a more maintainable and flexible approach to handling tweets. The changes focus on making the tweet management system more developer-friendly and framework-agnostic.

Changes

  • Added proper TypeScript interfaces for tweet data structures
  • Implemented local tweet history storage using Map
  • Created helper methods for tweet management
  • Improved error handling with proper TypeScript typing
  • Removed timestamp from tweet history (using server-side timestamps instead)
  • Fixed circular reference issues in agent serialization

Why Handle Tweets from API Server Perspective?

1. Separation of Concerns

  • Tweet history should be managed by the API server rather than the client
  • Allows for better data consistency and persistence
  • Enables cross-client tweet history access

2. Framework Agnosticism

The current implementation is designed to work with any framework, not just the GAME framework:

interface ITweetHistory {
  tweetId: string;
  content: string;
  jobId: number;
  phase: AcpJobPhases;
}

interface ITweetResponse {
  tweetId: string;
  content: string;
}

3. Developer Experience

  • Clear interfaces make it easier to understand the data structure
  • Helper methods provide a consistent way to handle tweets
  • Type safety reduces runtime errors
  • Local storage provides a fallback when API is unavailable

4. Future Extensibility

The current implementation includes TODOs for future API server integration:

// TODO: When API server is ready, implement proper tweet history storage
// await this.acpClient.addTweet(jobId, tweet.data.id, content);

Implementation Details

Tweet History Storage

private tweetHistory: Map<number, ITweetHistory[]> = new Map();
  • Uses jobId as the key for easy lookup
  • Maintains tweet history during application lifecycle
  • Can be easily replaced with API calls when server is ready

Helper Methods

private async handleTweet(
  jobId: number,
  content: string,
  phase: AcpJobPhases,
  replyToTweetId?: string
): Promise<ITweetResponse>

private getJobTweetHistory(jobId: number): ITweetHistory[]
private getLatestJobTweet(jobId: number): ITweetHistory | undefined

Migration Path

When the ACP Plugin v2 & API gateway handling addTweet is ready (aligned with @Zuhwa), we can:
2. Implement the commented-out addTweet call
3. Add proper tweet history persistence
4. Add tweet history retrieval from the API server

@Ang-dot Ang-dot force-pushed the twitter-poc/yang-add-twitter-poc branch from 1c227af to 64a9a4d Compare May 16, 2025 08:10
@Ang-dot Ang-dot requested a review from celesteanglm May 16, 2025 08:14
@celesteanglm
Copy link
Contributor

celesteanglm commented May 20, 2025

Hey @Ang-dot , a couple of initial feedback:

  • Can you add a buyer and seller example for this to be a more meaningful example?
  • can you rename the folder to game_sdk?
  • I feel that while state mgmt would be useful here, i don't want it to be a hard dependency - this could technically be done by using the X handles to tag the counterparty agent via X post right? browseAgent should give the X handle in the SDK: https://github.com/Virtual-Protocol/acp-node/blob/main/src/acpClient.ts#L177

@Ang-dot Ang-dot force-pushed the twitter-poc/yang-add-twitter-poc branch 3 times, most recently from 9d1680a to 8d5aec2 Compare May 22, 2025 05:12
@Ang-dot Ang-dot force-pushed the twitter-poc/yang-add-twitter-poc branch 2 times, most recently from f74df10 to dec6ab5 Compare May 22, 2025 05:35
@Ang-dot
Copy link
Contributor Author

Ang-dot commented May 23, 2025

@celesteanglm, refer to #15 for POC without state management as a hard requirement

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