feat: add batch task creation to TaskCreate tool#24
Draft
v2nic wants to merge 3 commits into
Draft
Conversation
Extend TaskCreate to accept an optional array parameter for creating multiple tasks in a single atomic call. The existing scalar / parameters remain fully backward-compatible. Key changes: - Add for atomic batch creation within a single lock - Add array parameter to TaskCreate tool (mutually exclusive with scalar params) - Add validation: reject mixing with / - Add validation: require + when not using - 6 new unit tests for createMany (IDs, persistence, metadata, empty array) - 10 new integration tests for TaskCreate batch mode - Updated README with batch usage docs and parameter tables This approach modifies the existing tool rather than adding a new one, avoiding context bloat from an additional tool definition while keeping the API surface minimal.
Author
|
👋 CI shows |
The parameter descriptions and prompt guidelines already convey the distinction. The extra section was redundant and added context bloat for the LLM.
Rename the TaskCreate batch array parameter from `tasks` to `batch` to make it more distinctive and searchable. Update all references in source, tests, and README accordingly.
Owner
|
starting a discussion here: #25 (comment) |
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
Extend
TaskCreateto support batch creation via an optionalbatcharray parameter. The existingsubject/descriptionscalar parameters remain fully backward-compatible. Creates multiple tasks in a single atomic tool call — no new tool definition added to the LLM's context window.Motivation
When an LLM needs to create several tasks upfront, calling
TaskCreateN times means N sequential tool-use round-trips, wasting context and time. A batch primitive solves this — Claude Code ships batch creation for exactly this reason.Rather than adding a new
TaskCreateManytool (which would bloat the context with an 8th tool definition), this PR adds abatcharray parameter to the existingTaskCreatetool. The LLM only needs one tool for creating tasks, regardless of count.See PR #18 (separate
TaskCreateManytool, open) and PR #16 (batch mutations, closed without merge) for prior approaches. No maintainer comments on either.Changes
src/task-store.ts— AddcreateMany(items)method: creates multiple tasks inside a singlewithLockcall, assigning sequential IDssrc/index.ts— Addbatcharray parameter toTaskCreate(mutually exclusive withsubject/description). Makesubjectanddescriptionoptional. Add prompt guideline for batch preference. Add validation for mixed-mode and missing-field errors.README.md— UpdatedTaskCreatesection with expanded parameter tables for single and batch modes, example JSON, and output formattest/task-store.test.ts— 6 new tests forcreateMany(sequential IDs, pending status, metadata, ID counter continuation, empty array, file persistence)test/subagent-integration.test.ts— 10 new tests forTaskCreatebatch mode (batch creation, TaskList integration, agentType, backward compat, mixed-mode rejection, missing-field rejection, singular wording, atomic appearance)Design decisions
Modify existing tool vs. add new tool — Modifying
TaskCreateavoids adding an 8th tool definition to the LLM's context window. The tool description already says "create a structured task list" which naturally encompasses batch creation.batchinstead oftasks— The parameter is namedbatchrather thantasksfor discoverability and searchability.tasksis too generic and easy to confuse with the concept of tasks;batchclearly signals the batch-creation feature.Mutual exclusivity — Using both
batchandsubject/descriptiontogether returns an error. This keeps the schema unambiguous.Atomic creation — Batch tasks are created inside a single
withLockcall, ensuring consistency in file-backed mode (no partial writes when multiple sessions create tasks concurrently).No dependency wiring in create — Dependencies should be wired up via
TaskUpdateafter creation. KeepingTaskCreatefocused on creation only keeps the tool schema simple.