Infinite loop with context error,

Hello,
I’m working on a crew to analyse 3 documents, create a plan and create a report.

I have a constant loop where the Manager tries to delegate a task with a HUGE context, including a part of the documentation. It’s suppose to break down for the next loop but it never happens. It seems to send always the buffer. Of course I have memory=True.

Can you help me please ? I tried several things and I have no more ideas.

[…]
│ └── :wrench: Used Search the internet with Serper (30)
├── :clipboard: Task: 95f5a5bd-fa57-4f37-a9fb-42517698661c
│ Assigned to: Crew Manager
│ Status: :white_check_mark: Completed
│ ├── :robot: Agent: Crew Manager
│ │ Status: In Progress
│ │ ├── :wrench: Failed Delegate work to coworker (36)
│ │ └── :wrench: Using Ask question to coworker (3)
│ ├── :robot: Agent: Rédacteur de plan de réponse à appel d’offre
│ │ Status: :white_check_mark: Completed
│ │ ├── :wrench: Failed Delegate work to coworker (37)
│ │ └── :wrench: Using Ask question to coworker (4)
│ └── :robot: Agent: Crew Manager
│ Status: :white_check_mark: Completed
│ └── :wrench: Failed Delegate work to coworker (38)
└── :clipboard: Task: ae06de82-8e77-4078-a5ff-d23f37832553
Status: Executing Task…
└── :robot: Agent: Crew Manager
Status: In Progress
├── :wrench: Failed Delegate work to coworker (44)
└── :brain: Thinking…

Thought: The error indicates that the input for the “task” field was too long and contained invalid characters. I need to ensure that the task description is concise and properly formatted. I will also need to break down the task into smaller, manageable parts to fit within the character limits.

Action: Delegate work to coworker

Action Input: {“task”: {“description”: “Rédigez l’introduction générale captivante du document en markdown structuré. Incluez les sections suivantes: Introduction générale captivante, Chapitres parfaitement structurés, Sous-chapitres détaillés et équilibrés, Conclusion générale impactante, Transitions fluides entre les sections. Le document doit être complet et répondre aux exigences suivantes: Corps principal, Éléments de preuve, Supports visuels, Annexes et compléments. Le document doit: Répondre précisément aux exigences, démontrer une expertise claire, être convaincant et différenciant, faciliter la lecture et la compréhension, respecter les contraintes formelles.”}, “context”: {“description”: "### Rapport Détaillé et Structuré pour l’Analyse des Documents d’Appel d’Offres\n\n#### Introduction\nL’analyse des documents d’appel d’offres est essentielle pour identifier toutes les exigences métiers, techniques, de projet, et autres informations pertinentes. Chaque chapitre doit être examiné en détail pour s’assurer que toutes les exigences sont comprises et respectées. Ce rapport présente une analyse exhaustive de chaque chapitre, incluant des questions pour une meilleure compréhension et des résumés détaillés.\n\n#### 1. PARTIE 1 : SYSTEME D’ACQUISITION DYNAMIQUE\n\n##### 1.1 OBJET DU SYSTEME D’ACQUISITION DYNAMIQUE\n\n###### Exigences Métiers, Techniques, de Projet, et Autres Informations Pertinentes\n1. Contexte et Objectif:\n - Ce chapitre détaille le contexte et les objectifs du système […]

Thanks a lot

Hey Frédéric, welcome aboard!

tl;dr: To cut to the chase, you’re trying to delegate tasks that are just too complex, instead of breaking them up into smaller pieces. Go back, split your tasks into a bunch of sub-tasks, avoid building a monolithic system, and you’ll massively improve your chances of success. There you go — from an engineering (implementation) perspective for agentic systems, that’s my two cents.


Still with me? Alright, let’s buckle up for a long and possibly boring chat about agentic system architecture (planning).

Your Task.description is way too long and prescriptive. It’s not just asking for an introduction — it’s demanding multiple required sections within that intro («Introduction générale captivante», «Chapitres parfaitement structurés») and laying out a whole bunch of high-level requirements for the entire document («Corps principal», «Éléments de preuve», «Supports visuels»), all stuffed into what’s supposed to be a simple instruction to write the introduction!

The log shows the Crew Manager repeatedly failing with Failed Delegate work to coworker, and this pattern points to a recurring issue with the delegation process, most likely triggered by the huge payload (task description plus context) being sent every time.

So my simplest suggestion (given the info you provided) is: break it down. For example: Task 1 - Outline the Introduction Sections; Task 2 - Write Section 1.1; Task 3 - Write Section 1.2; and so on. The agent is already hinting at this in its own reasoning (I will also need to break down the task into smaller, manageable parts...)

I highly recommend watching Brandon Hancock’s CrewAI Flows Crash Course. He introduces a key CrewAI concept: Flows. In the video, Brandon walks through a flow that uses multiple Crews to write an entire book, splitting it up into chapters — which sounds exactly like the kind of thing you’re trying to do.

On a more theoretical note, whenever you set out to solve a problem using agentic systems, remember that the process you’re automating is often (or needs to be) a lot more deterministic than stochastic (probabilistic). Something like: Do this ➝ Then do that ➝ Next do this or that ➝ Finally, assemble everything and generate an output. For these cases, CrewAI’s Flow concept really helps keep each step both debuggable and scalable.

Picture this: every step in your complex process is handled by an agent that’s 90% reliable. Sounds awesome, right? Now, imagine you’ve got 5 such steps, each run by a 90% reliable agent. Your overall success rate just dropped to:

90% × 90% × 90% × 90% × 90% = 59% :scream:

That’s why approaches with autonomous agents (who run tools on their own and delegate tasks to other agents by themselves) can easily add more and more points to that simple multiplication above, leading to a lot of frustration when you try to scale things up.

So, if you want to boost your chances of success with agentic systems and actually enjoy getting good results, my humble advice is: always divide and conquer.

Best of luck on your journey!

1 Like

Thanks a lot for your answer. It’s clear that tasks descriptions were too complex.
I worked them with cursor’s chat to try to improve them but it was too much at once.
I tried with a smaller tasks and by removing unnecessary steps. I have no more loops.

I’m struggling with tasks/agents descriptions/breaking to have te correct level of output. Reports are either too complex (infinite loop) or too summarised.

I’ll check for flow. I was not sure if it could fit to my problem.