Skip to content
Notifications
Clear all

Guide: Building a simple social media content calendar planner with three agents.

2 Posts
2 Users
0 Reactions
3 Views
(@alexh82)
Estimable Member
Joined: 1 week ago
Posts: 128
Topic starter   [#10818]

Building a multi-agent system for a concrete, well-scoped task is often the most effective way to learn the AutoGen framework. This guide details the construction of a simple social media content calendar planner, demonstrating how three distinct agents can collaborate to transform a high-level idea into a scheduled, actionable plan. We will focus on separation of concerns, clear conversation patterns, and practical configuration.

The system comprises three agents:
* **The Planner Agent:** Responsible for high-level ideation and breaking down a broad theme into specific post concepts.
* **The Copywriter Agent:** Takes a post concept and generates engaging copy, including multiple headline options and body text.
* **The Scheduler Agent:** Analyzes the generated copy and proposed timing to produce a structured calendar (e.g., a CSV or JSON output).

Below is a foundational configuration for these agents. We assume the use of the `GroupChat` and `AssistantAgent` classes.

```python
from autogen import AssistantAgent, UserProxyAgent, GroupChat, GroupChatManager

config_list = [
{
'model': 'gpt-4',
'api_key': 'YOUR_API_KEY',
}
]

llm_config = {"config_list": config_list, "temperature": 0.7}

# 1. The Planner Agent
planner = AssistantAgent(
name="Planner",
system_message="You are a strategic content planner. Your task is to take a broad social media theme (e.g., 'Q3 Product Launches', 'Cybersecurity Awareness Month') and generate a list of 5 specific post concepts. For each concept, provide a one-sentence description and the desired post type (e.g., 'Infographic', 'Customer Story', 'Quick Tip'). Return only the list.",
llm_config=llm_config,
)

# 2. The Copywriter Agent
copywriter = AssistantAgent(
name="Copywriter",
system_message="You are a professional social media copywriter. Given a post concept (description and type), you will generate: 1) Three compelling headline options, 2) Engaging body copy (approx. 2-3 sentences) optimized for the platform, and 3) 3 relevant hashtags. Format your response clearly.",
llm_config=llm_config,
)

# 3. The Scheduler Agent
scheduler = AssistantAgent(
name="Scheduler",
system_message="You are a meticulous content scheduler. You will receive a series of posts (headline and body). Your job is to arrange them logically across a given timeframe (e.g., one week), assign each a proposed day/time (e.g., 'Tuesday, 10:00 AM'), and output the final calendar in a structured CSV format. Begin your output with 'FINAL_CALENDAR:' followed by the CSV.",
llm_config=llm_config,
)

user_proxy = UserProxyAgent(
name="Admin",
human_input_mode="TERMINATE",
code_execution_config=False,
)
```

The workflow is orchestrated via a `GroupChatManager`. The key to success is defining a clear `GroupChat` with a speaker order that enforces the desired pipeline: `Admin` -> `Planner` -> `Copywriter` -> `Scheduler`.

```python
groupchat = GroupChat(
agents=[user_proxy, planner, copywriter, scheduler],
messages=[],
max_round=12,
speaker_order=[user_proxy, planner, copywriter, scheduler] # Enforces the pipeline
)
manager = GroupChatManager(groupchat=groupchat, llm_config=llm_config)

# Initiate the task
user_proxy.initiate_chat(
manager,
message="Please plan a content calendar for 'Zero Trust Architecture Fundamentals' across one week. Aim for 5 posts."
)
```

In this flow, the `Admin` provides the initial theme. The `Planner` generates the concepts and passes them sequentially to the `Copywriter`, who fleshes each one out. Finally, the `Scheduler` receives the collection of finished posts and compiles the structured calendar. The `speaker_order` is critical; without it, the agents might attempt to perform each other's tasks, leading to confusion and poor results.

**Key Considerations & Pitfalls:**
* **Agent Isolation:** The system messages must be precise to prevent role drift. A vague `Copywriter` prompt might cause it to attempt scheduling.
* **Token Management:** In a `GroupChat`, the entire conversation history is passed to each agent by default. For longer workflows, consider implementing a `send_introductions` pattern or using a custom function to summarize previous steps.
* **Output Parsing:** The instruction for the `Scheduler` to prefix its output with `FINAL_CALENDAR:` allows for easy programmatic extraction of the result from the chat history, which is preferable to manually sifting through verbose responses.
* **Error Handling:** This is a linear pipeline. In a production scenario, you would need to add validation agents or code functions to check the output of each stage (e.g., verifying the CSV is valid) before proceeding.

This three-agent pattern provides a reusable template for any multi-stage content generation or planning task, where each stage requires specialized expertise and a defined input/output contract.



   
Quote
(@charlie2)
Trusted Member
Joined: 1 week ago
Posts: 61
 

Love the breakdown of agents by responsibility. It makes the workflow super clear. This is exactly the kind of starter project I needed to see. What would you recommend for managing the prompts or instructions for each agent? Do you keep them all in one script?



   
ReplyQuote