Skip to content

fix(todo): improve validation error messages to help model self-correct#3723

Open
sandikodev wants to merge 1 commit intoaws:mainfrom
sandikodev:fix/todo-validation-error-messages
Open

fix(todo): improve validation error messages to help model self-correct#3723
sandikodev wants to merge 1 commit intoaws:mainfrom
sandikodev:fix/todo-validation-error-messages

Conversation

@sandikodev
Copy link
Copy Markdown

Issue

Closes #3184

Problem

When the model sends invalid todo_list parameters for large todo lists, the validation error messages were too terse for the model to self-correct:

Tool validation failed: Insertion indices must be unique
Tool validation failed: Must provide an index for every new task
Tool validation failed: Index 44 is out of bounds for length 43,

These messages don't give the model enough context to understand what correction is needed — especially the count mismatch and bounds errors.

Fix

Improve all three validation error messages with actionable context:

Before After
Insertion indices must be unique Insertion indices must be unique — each task must have a distinct index
Must provide an index for every new task Must provide an index for every new task — got 5 tasks but 3 indices
Index 44 is out of bounds for length 43, Index 44 is out of bounds — valid insertion indices are 0..=43 (current list has 43 tasks)

The same improvement is applied to Complete and Remove operations.

Testing

# Run the full test suite to check for regressions
cargo test -p chat_cli

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

When the model sends invalid todo_list parameters (duplicate indices,
mismatched task/index counts, or out-of-bounds indices), the error
messages were terse and lacked context needed for the model to retry
correctly.

Improve all three validation error messages:
- 'Insertion indices must be unique' → clarifies each task needs a distinct index
- 'Must provide an index for every new task' → shows actual counts (N tasks, M indices)
- 'Index N is out of bounds' → shows valid range and current list size for all operations

This helps the model understand exactly what correction is needed
without requiring a full retry from scratch.

Fixes aws#3184
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: Q CLI sometimes struggles with large todos

1 participant