fix(delegate): accept JSON string batch tasks#21966
Closed
Bartok9 wants to merge 2 commits into
Closed
Conversation
Recover delegate_task batch inputs when open-weight models emit tasks as a JSON-encoded array string, and return clear errors for malformed task lists. Co-authored-by: Cursor <cursoragent@cursor.com>
…legate-string-tasks-merge-main
Contributor
Author
|
The test CI failure is pre-existing on |
This was referenced May 8, 2026
Contributor
Author
|
The test CI failure is pre-existing on |
Collaborator
Collaborator
|
Merged via #22436 — your commit was cherry-picked with original authorship preserved ( Both your PR and #21957 targeted the same code path; we picked yours as the salvage base because it had focused tests, returned structured errors for malformed/non-array JSON, and added per-element type validation. The companion commit ( |
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.
Problem
Closes #21933.
Open-weight models can emit
delegate_taskbatchtasksas a JSON-encoded array string instead of a native array. When that reaches the delegate boundary unchanged or as a bad single list item, batch delegation fails with a confusing generic error or an attribute error instead of running the requested subtasks.Root cause
delegate_taskonly treated native lists as batch mode and assumed every list item was a task object. It did not recover the commontasks='[{...}]'model-output shape, and it did not validate list element types before calling.get().Fix
Parse string-shaped
tasksas a JSON array at the delegate boundary, preserve native list behavior, and return clear structured tool errors for malformed JSON, non-array JSON, or non-object list entries.Testing
python3 -m py_compile tools/delegate_tool.py tests/tools/test_delegate.py: cleanpython3 -m pytest -o addopts='' tests/tools/test_delegate.py::TestDelegateTask::test_batch_mode_accepts_json_string_tasks tests/tools/test_delegate.py::TestDelegateTask::test_batch_mode_rejects_non_object_tasks tests/tools/test_delegate.py::TestDelegateTask::test_batch_mode_rejects_malformed_json_string_tasks -q: 3 passedgit diff --check: cleanMade with Cursor