Bug in Reflection and Blogpost Writing Context

The context in the next code is only adding the review of the first agent:

res = critic.initiate_chat(
recipient=writer,
message=task,
max_turns=2,
summary_method=“last_msg”
)

When I ran the code I got the next result for the context in the last meta agent:


Critic (to Meta Reviewer):

Aggregrate feedback from all reviewers and give final suggestions on the writing.

Context:
{‘Reviewer’: ‘SEO Reviewer’, ‘Review’: ‘Suggesting to incorporate target keywords, optimize meta title and description, and add a clear call-to-action for improved search visibility and user engagement.’}
{‘Reviewer’: ‘SEO Reviewer’, ‘Review’: ‘Suggesting to incorporate target keywords, optimize meta title and description, and add a clear call-to-action for improved search visibility and user engagement.’}
{“reviewer”: “SEO Reviewer”, “review”: “Suggesting to incorporate target keywords, optimize meta title and description, and add a clear call-to-action for improved search visibility and user engagement.”}

The video shows that here it should be the three different outputs of the reviewers agents.

How can I fix this?

Thanks,

Oscar

1 Like

I’ve been taking the course and I noticed the same thing. I fixed it by modifying the reflection_message function to chain all of the chat messages together. This has the effect of including the initial prompt in the context for each reviewer, but it seems to work well.

def reflection_message(recipient, messages, sender, config):
    feedback_history = "\n\n".join([msg['content'] for msg in recipient.chat_messages_for_summary(sender)])
    return f'''Review the following content and previous feedback:
            \n\n {feedback_history}'''

I see the same bug

What I found but it is not deterministic is that you should modify this:

“{‘Reviewer’: “your role name’', ‘Review’: ''your review”}.”,}

review_chats = [
{
“recipient”: SEO_reviewer,
“message”: reflection_message,
“summary_method”: “reflection_with_llm”,
“summary_args”: {“summary_prompt” :
“Return review into as JSON object only:”
“{‘Reviewer’: “your role name’', ‘Review’: ''your review”}.”,},
“max_turns”: 1},
{
“recipient”: legal_reviewer, “message”: reflection_message,
“summary_method”: “reflection_with_llm”,
“summary_args”: {“summary_prompt” :
“Return review into as JSON object only:”
“{‘Reviewer’: “your role name’', ‘Review’: ''your review”}.”,},
“max_turns”: 1},
{“recipient”: ethics_reviewer, “message”: reflection_message,
“summary_method”: “reflection_with_llm”,
“summary_args”: {“summary_prompt” :
“Return review into as JSON object only:”
“{‘Reviewer’: “your role name’', ‘Review’: ''your review”}.”,},
“max_turns”: 1},
{“recipient”: meta_reviewer,
“message”: “Aggregrate feedback from all reviewers and give final suggestions on the writing.”,
“max_turns”: 1},
]

I used this strategy for solve another task with agents and almost all the times the feedback or context is with the json of each reviewer. What I learned is that this approach is very susceptible to the prompt.

Maybe there is another approach like using some cache or some variable to store the json output of each agent.