FoundationAgents/MetaGPT · error · ValueError
task_id is not found in the insight_pool
Error message
task_id is not found in the insight_pool
What it means
Raised by InstructionGenerator.load_insight_pool when any entry in the loaded insight pool JSON lacks a 'task_id' key. Every insight must carry a task_id because the pool is filtered by task (int(item['task_id']) == int(task_id)) and later grouped per task.
Source
Thrown at metagpt/ext/sela/insights/instruction_generator.py:109
rsp_list.append(rsp)
for item in rsp_list:
item_dict = json.loads(item)
data = {
"Insights": item_dict,
}
new_data.append(data)
return new_data
@staticmethod
def load_insight_pool(file_path, use_fixed_insights, task_id=None):
data = InstructionGenerator.load_json_data(file_path)
if use_fixed_insights:
current_directory = os.path.dirname(__file__)
fixed_insights = InstructionGenerator.load_json_data(f"{current_directory}/fixed_insights.json")
data.extend(fixed_insights)
for item in data:
if "task_id" not in item:
raise ValueError("task_id is not found in the insight_pool")
if task_id:
data = [item for item in data if int(item["task_id"]) == int(task_id)]
return data
async def generate_new_instructions(self, task_id, original_instruction, max_num, ext_info=None):
data = self.insight_pool
new_instructions = []
if len(data) == 0:
mcts_logger.log("MCTS", f"No insights available for task {task_id}")
# return [original_instruction] # Return the original instruction if no insights are available
for i in range(max_num):
if len(data) == 0:
insights = "No insights available"
else:
item = data[i]
insights = item["Analysis"]
new_instruction = await InstructionGenerator.generate_new_instruction(View on GitHub (pinned to 11cdf466d0)
Solutions
- Add an integer 'task_id' field to every entry in the insight pool JSON
- Validate the JSON offline: assert all('task_id' in item for item in data)
- Keep the schema of your added insights identical to existing entries
Example fix
# before
{"Analysis": "..."}
# after
{"task_id": 0, "Analysis": "..."} Defensive patterns
Strategy: validation
Validate before calling
data = json.load(open(pool_path))
missing = [i for i, item in enumerate(data) if "task_id" not in item]
assert not missing, f"entries missing task_id: {missing}" Type guard
def insight_pool_valid(data: list[dict]) -> bool:
return all(isinstance(item, dict) and "task_id" in item for item in data) Prevention
- Validate pool JSON against existing entries' schema before adding insights
- Always include integer task_id in hand-written insights
When it happens
Trigger: Loading an analysis_pool/insight_pool JSON where at least one item was added without a task_id field — typically hand-written or externally generated insights.
Common situations: Editing the pool JSON to add domain knowledge and omitting task_id; merging insights from another pool format; use_fixed_insights pulling a malformed fixed_insights.json.
Related errors
- Dataset {dataset_name} not found in config file. Available d
- Dataset {task_name} not found in config file. Available data
- Number of classes {num_classes} not supported
- Target column not provided
- Invalid exp_mode: {args.exp_mode}
AI-assisted analysis of FoundationAgents/MetaGPT@11cdf466d0 (2026-08-14).
Data as JSON: /api/errors/5dfccb058b64c7fa.
Report an issue: GitHub.