Best Practices Integration into Existing CrewAI Workflow

Here’s a polished and well-structured version of your problem statement for posting in the CrewAI community:


:brain: Best Practices Integration into Existing CrewAI Workflow

Hi @maxmoura and CrewAI community,

I’m working on a CrewAI-based application where I’ve already created agents and tasks for specific features like:

  • Summarizing CRM lead details
  • Drafting emails based on lead information (e.g., details, activities, notes) pulled from a database view

Now, I’ve received a Best Practices document that includes guidance like:

  • Understanding Your Customer
  • Communication Best Practices
  • Discovery Questions
  • Activity Recommendations by Sales Stage

Although it’s a relatively small document, it contains critical instructions that should be consistently applied across all these features (summaries, email drafts, etc.).

I’m trying to figure out the best architectural approach to incorporate this Best Practices logic into my existing CrewAI setup. Here are some possible approaches I’ve considered:


:hammer_and_wrench: Options I’m Exploring

  1. Pass Best Practices directly into the tool along with lead details

    • Simple, but may clutter prompt inputs and mix responsibilities
  2. Create a separate tool BestPractice()

    • Encapsulates logic cleanly, but unclear how to best chain it with existing tools/tasks
  3. Create a dedicated agent and task for processing Best Practices, then use a multi-agent setup

    • Unsure about the optimal flow:

      • Should the Best Practice logic run before lead info is processed?
      • Or should it be used after, to refine/validate the output?
  4. Pre-process lead details through Best Practices first, then pass enriched input to summary/email agent

    • Might ensure compliance, but could add processing overhead

:red_question_mark: My Key Question

What’s the most CrewAI-idiomatic and scalable way to ensure these Best Practices are always applied to the output of my summary and email-drafting agents?

Would love your thoughts on how others have handled similar integration of global context/instructions across multiple tasks.

Thanks in advance!

—Shivang

Dear @Shivang_Goyal,

Currently I am also dealing with similar approaches. To my experience the most reliable method is to use tags for your must-have information. If you put your “critical instructions” between tags, then you can tell the agent to always include this information within your different output documents.

Best

1 Like

@Shivang_Goyal,

As I mentioned in this other thread, here are a few ideas on how to organize your instructions:

  • As @igi rightly pointed out, focus on organizing your prompts (Task.description). I also recommend using well-structured Markdown, especially with subheadings, bullet points, and so on. This helps maintain clarity and readability for both humans and LLMs.
  • Regarding your Best Practices document, consider creating a specific section for them where you break down the recommended practices relevant to each task. Not all best practices might apply to every task, so this curation helps maintain focus.
  • Avoid using a tool just to retrieve that file. Generally (and this applies to many situations), tool usage by the LLM should be restricted to scenarios where you can’t determine the necessary information beforehand. Each tool use by the LLM adds an extra step, which increases latency and potentially introduces another source of hallucinations (e.g., improper tool use). If you can provide the information directly in the prompt, that’s preferable.
  • If these Best Practices are crucial for the client, consider creating a dedicated step (either a node in a Flow or an Agent in your process) responsible for verifying that the best practices have been followed, i.e. one agent generates, and another one verifies. This improves the final output’s alignment with your client’s requirements.
  • Even if you adopt a verification step, it’s a good idea for the generating agent to already be aware of the best practices. In other words, make sure to provide the best practices to both the generating agents and (obviously) the ones that verify/enforce them.

I hope these general ideas help you deliver a great result.

1 Like