

def _reflection_with_llm_as_summary_dict(sender, recipient, summary_args):  
    summary_dict = {}
    for key, prompt in summary_args.items():
        if not isinstance(prompt, str):
            continue
        msg_list = recipient.chat_messages_for_summary(sender)
        agent = sender if recipient is None else recipient
        role = summary_args.get("summary_role", None)
        if role and not isinstance(role, str):
            raise ValueError("The summary_role in summary_arg must be a string.")

        summary = sender._reflection_with_llm(
            prompt, msg_list, llm_agent=agent, cache=summary_args.get("cache"), role=role
        )
        summary_dict[key] = summary
    return summary_dict
