Skip to content

feat: add TaskCreateMany tool for batch task creation#18

Closed
danieldisu wants to merge 1 commit into
tintinweb:masterfrom
danieldisu:feat/task-create-many
Closed

feat: add TaskCreateMany tool for batch task creation#18
danieldisu wants to merge 1 commit into
tintinweb:masterfrom
danieldisu:feat/task-create-many

Conversation

@danieldisu

@danieldisu danieldisu commented May 1, 2026

Copy link
Copy Markdown

Disclosure

This patch was AI-generated (Claude) at my request, motivated by a noticeable inefficiency when an LLM needs to create several tasks upfront: it was forced to call TaskCreate repeatedly in sequential turns, wasting round-trips and token budget. TaskCreateMany eliminates that by accepting an array in a single call.

QA level: light. Unit tests pass, TypeScript compiles clean, and Biome reports no lint issues.

CleanShot 2026-05-01 at 15 49 52@2x CleanShot 2026-05-01 at 16 03 32@2x

Motivation

When an LLM plans a multi-step effort and knows all tasks upfront, calling TaskCreate N times means N sequential tool-use round-trips. This is slow and burns context. A batch primitive is the obvious fix — Claude Code itself ships TaskCreateMany for exactly this reason.

Changes

  • src/task-store.ts: Added createMany(items) method — iterates the input array inside a single withLock call, assigns sequential IDs, and returns all created Task objects.
  • src/index.ts: Registered TaskCreateMany as Tool 2 (renumbered subsequent tools 3–8). Tool description mirrors Claude Code's spec — includes when-to-use, when-not-to-use, field documentation, and tips. Added TaskCreateMany to TASK_TOOL_NAMES so it resets the reminder interval.
  • README.md: Updated tool count (7 → 8), added TaskCreateMany to the tool table with parameter docs and example output.
  • test/task-store.test.ts: 6 new unit tests covering sequential IDs, pending status, activeForm/metadata preservation, empty array, single item, and interleaving with create.
  • test/subagent-integration.test.ts: 5 new integration tests covering tool registration, multi-task summary output, field preservation, single-task input, and empty-array rejection.

What I actually verified

Check Result
tsc --noEmit clean
biome check src/ test/ clean
vitest run 160 passed (5 files)
Manual live session verified locally

Diffstat: 5 files changed, +290, -9.

@danieldisu
danieldisu marked this pull request as ready for review May 1, 2026 14:15
pe200012 added a commit to pe200012/pi-tasks that referenced this pull request May 16, 2026
@tintinweb

Copy link
Copy Markdown
Owner

starting a discussion here: #25 (comment)

@danieldisu danieldisu closed this Jun 11, 2026
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.

2 participants