Conversation
|
👋 CI shows |
|
starting a discussion here: #25 (comment) |
2d707aa to
f9d28aa
Compare
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.
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.
f9d28aa to
64d6d8e
Compare
|
Rebased this branch onto tintinweb master (v0.8.0, 86a559c) — merge conflicts resolved and the branch now fast-forwards cleanly. Verified locally: typecheck clean, lint clean, 362 tests passing, build clean. CI shows |
|
Closing this in favor of a simpler approach: instead of a |
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.