fix(tools): harden UpdateTodoList for local LLM task JSON quirks#548
Closed
JessicaMulein wants to merge 1 commit into
Closed
fix(tools): harden UpdateTodoList for local LLM task JSON quirks#548JessicaMulein wants to merge 1 commit into
JessicaMulein wants to merge 1 commit into
Conversation
normalize_json_array for tasks in execute and format_output; coerce brace-prefixed strings without breaking on invalid JSON; add test_update_todo_list coverage. Co-authored-by: Cursor <cursoragent@cursor.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Hardens UpdateTodoList so local models can pass
tasksas a JSON string, char-split arrays, or brace-prefixed strings without breakingformat_outputor writing garbage one-character “tasks” totodo.txt.Problem
On Ollama and similar local models we routinely see:
taskspassed as a JSON string instead of a parsed array{but are not valid JSONmainalready hasnormalize_json_array()incecli.tools.utils.helpers(used by Grep and others), but UpdateTodoList still used naivejson.loads+ a loop that treated each character as a task informat_output.Solution
normalize_task_items()/format_task_lines()— shared coercion forexecuteandformat_outputcoerce_task_item()— dict passthrough; invalid{…}strings fall back to plain task textformat_output—json.loadsguard; surfaceToolErrorfrom normalization instead of silent corruptionLIST_PARAMS = ["tasks"]preserved for base tool list handlingTests
New file:
tests/tools/test_update_todo_list.py(7 cases)test_normalize_task_items_does_not_split_characterstest_format_task_lines_accepts_json_stringtest_format_output_accepts_tasks_as_json_stringformat_outputtest_format_output_reports_invalid_tasks_jsontaskstest_coerce_task_item_plain_string_starting_with_brace{prefix fallbackScope
In scope:
cecli/tools/update_todo_list.py,tests/tools/test_update_todo_list.py, minor import-order touch intests/tools/test_get_lines.py.Out of scope: General glued-tool JSON (
parse_tool_arguments), Grep, session encryption — separate PRs if still needed onmain.Checklist
normalize_json_array(no duplicate helper stack)executeandformat_outputshare the same normalization path