Skip to content

[WIP] Refactor agent classes to data classes and organize modules#20

Closed
Copilot wants to merge 1 commit into
parallelfrom
copilot/refactor-agent-classes-to-data-classes
Closed

[WIP] Refactor agent classes to data classes and organize modules#20
Copilot wants to merge 1 commit into
parallelfrom
copilot/refactor-agent-classes-to-data-classes

Conversation

Copilot AI commented Dec 16, 2025

Copy link
Copy Markdown
Contributor

Refactoring Plan: Agent Classes to Data Classes with Ray Parallelization

Phase 1: Convert Agent Classes to Data Classes

  • Create data class for base agent with all attributes
  • Create data class for page agent extending base agent data
  • Create data class for fake agents
  • Remove all methods from agent classes (keep only data)

Phase 2: Extract Methods to Functional Modules

  • Create agent_actions.py module for CPU-bound operations (post, comment, share, reaction, follow)
  • Create agent_llm_operations.py module for GPU-bound LLM operations
  • Create agent_data_operations.py module for data retrieval operations
  • Create agent_utils.py module for utility functions
  • Organize functions into logical groups

Phase 3: Ray Integration

  • Add ray to requirements
  • Create ray remote functions for CPU-bound operations
  • Create ray remote functions for GPU-bound LLM operations
  • Update client to use ray.get() for parallel execution
  • Configure ray with appropriate resources (CPU/GPU)

Phase 4: Testing and Validation

  • Test agent creation and initialization
  • Test individual agent actions
  • Test simulation execution
  • Validate parallelization improvements

Notes:

  • GPU-bound functions: post, comment, share, reaction (with LLM calls), select_action (with LLM), emotion_annotation, news (for page agents)
  • CPU-bound functions: follow, read, search, data retrieval/API calls
  • Keep minimal changes to maintain backwards compatibility
Original prompt

Rewrite the agent classes to become data classes. Make the method functions in one or more neatly organized modules.

Implement parallelization with ray: use agent data classes and make the functions use them efficiently. Differentiate from CPU bound and GPU bound functions (the ones interacting with LLMs).


💡 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 requested a review from GiulioRossetti December 16, 2025 16:08
@GiulioRossetti GiulioRossetti marked this pull request as ready for review December 16, 2025 16:09
@GiulioRossetti GiulioRossetti deleted the copilot/refactor-agent-classes-to-data-classes branch December 16, 2025 16:09
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