mirror of
https://github.com/All-Hands-AI/OpenHands.git
synced 2026-01-09 06:48:02 -05:00
fix: validate task_list schema for task tracker (#10624)
This commit is contained in:
@@ -263,9 +263,36 @@ def response_to_actions(
|
||||
f'Missing required argument "task_list" for "plan" command in tool call {tool_call.function.name}'
|
||||
)
|
||||
|
||||
raw_task_list = arguments.get('task_list', [])
|
||||
if not isinstance(raw_task_list, list):
|
||||
raise FunctionCallValidationError(
|
||||
f'Invalid format for "task_list". Expected a list but got {type(raw_task_list)}.'
|
||||
)
|
||||
|
||||
# Normalize task_list to ensure it's always a list of dictionaries
|
||||
normalized_task_list = []
|
||||
for i, task in enumerate(raw_task_list):
|
||||
if isinstance(task, dict):
|
||||
# Task is already in correct format, ensure required fields exist
|
||||
normalized_task = {
|
||||
'id': task.get('id', f'task-{i + 1}'),
|
||||
'title': task.get('title', 'Untitled task'),
|
||||
'status': task.get('status', 'todo'),
|
||||
'notes': task.get('notes', ''),
|
||||
}
|
||||
else:
|
||||
# Unexpected format, raise validation error
|
||||
logger.warning(
|
||||
f'Unexpected task format in task_list: {type(task)} - {task}'
|
||||
)
|
||||
raise FunctionCallValidationError(
|
||||
f'Unexpected task format in task_list: {type(task)}. Each task shoud be a dictionary.'
|
||||
)
|
||||
normalized_task_list.append(normalized_task)
|
||||
|
||||
action = TaskTrackingAction(
|
||||
command=arguments['command'],
|
||||
task_list=arguments.get('task_list', []),
|
||||
task_list=normalized_task_list,
|
||||
)
|
||||
|
||||
# ================================================
|
||||
|
||||
Reference in New Issue
Block a user