Skip to content

Multi-instruction parsing for batch chat requests#591

Merged
Chris0Jeky merged 5 commits intomainfrom
feature/574-multi-instruction-parsing
Mar 30, 2026
Merged

Multi-instruction parsing for batch chat requests#591
Chris0Jeky merged 5 commits intomainfrom
feature/574-multi-instruction-parsing

Conversation

@Chris0Jeky
Copy link
Copy Markdown
Owner

Summary

  • Adds ParseBatchInstructionAsync to IAutomationPlannerService that accepts multiple instructions and produces a single multi-operation proposal for atomic review/approve/reject
  • Supports batch card creation syntax: "create cards: meeting setup, IT onboarding, HR orientation" creates one proposal with multiple card-create operations
  • When the LLM extracts multiple instructions from a single chat message, they are now combined into one atomic proposal instead of separate proposals
  • Each operation in a batch gets its own unique idempotency key
  • Batch size is bounded at 30 operations per proposal
  • 32 new unit tests covering validation, parsing, batch limits, idempotency, and edge cases

Closes #574

Test plan

  • All 1,731 backend tests pass (dotnet test backend/Taskdeck.sln -c Release -m:1)
  • 32 new tests in AutomationPlannerBatchTests cover batch parsing logic
  • Existing ChatServiceTests updated for batch behavior
  • Verify batch card creation via API: POST /chat/sessions/{id}/messages with content like "create cards: task1, task2, task3"
  • Verify max batch size (31 items) returns validation error
  • Verify mixed operation types in a single batch produce one proposal

Introduces a new method that accepts multiple instructions and produces
a single multi-operation proposal for atomic review/approve/reject.
Closes #574.
- Add ParseBatchInstructionAsync: combines multiple instructions into one
  multi-operation proposal with sequential operation numbering
- Add TryParseBatchCardCreateAsync: parses "create cards: a, b, c" pattern
  into multiple card-create operations
- Add TryParseOperationsAsync: extracted helper for single-instruction
  operation parsing, reused by both single and batch code paths
- Integrate batch card pattern into ParseInstructionAsync as fallback
- Enforce MaxBatchSize (30) operations per proposal
- Each operation gets its own unique idempotency key
- Add batch card pattern to SupportedPatterns for parse hints
When the LLM extracts multiple instructions, use ParseBatchInstructionAsync
to create a single atomic proposal instead of separate proposals per
instruction. Single-instruction paths remain unchanged for backward
compatibility.
32 tests covering:
- Validation (empty list, empty userId, whitespace correlation ID)
- Batch card creation ("create cards: a, b, c" and variants)
- Multiple single-instruction batching
- Mixed operation types in a batch
- Partial success (some instructions parseable, some not)
- Max batch size enforcement (30 limit)
- Unique idempotency keys per operation
- Source metadata passthrough
- Summary generation
- Direct TryParseBatchCardCreateAsync helper tests
- Direct TryParseOperationsAsync helper tests
…tions

The multi-instruction test now mocks ParseBatchInstructionAsync and
verifies a single atomic proposal is created instead of separate
proposals per instruction.
@gemini-code-assist
Copy link
Copy Markdown

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@chatgpt-codex-connector
Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

@Chris0Jeky
Copy link
Copy Markdown
Owner Author

Adversarial Self-Review

Findings

1. Missing RegexOptions.Timeout on BatchCardCreateRegex (Low risk)
The compiled regex BatchCardCreateRegex does not specify a TimeSpan timeout, unlike LlmIntentClassifier which uses 100ms timeouts. The pattern is anchored at both ends making catastrophic backtracking unlikely. Not fixing because risk is negligible for anchored patterns.

2. Code duplication in TryParseOperationsAsync (Design trade-off)
TryParseOperationsAsync duplicates regex patterns from ParseInstructionAsync. Different return types and error semantics make sharing impractical without a larger refactor. Acceptable at current scale.

3. Batch card pattern silently swallows boardId-missing errors (Acceptable)
TryParseBatchCardCreateAsync returns null when boardId or columns are missing, causing fallthrough to parse hints. Consistent with TryParseOperationsAsync behavior.

4. Permission validation after proposal creation (Pre-existing pattern)
Permissions validated after proposal creation - same pattern as ParseInstructionAsync.

5. No test for comma-in-title edge case
Titles with commas get split by the delimiter. Expected behavior for comma-delimited format.

Verdict

No bugs or security issues found. 32 new tests, all 1731 backend tests pass. Backward-compatible.

@Chris0Jeky Chris0Jeky merged commit 8b52b65 into main Mar 30, 2026
18 checks passed
@github-project-automation github-project-automation bot moved this from Pending to Done in Taskdeck Execution Mar 30, 2026
@Chris0Jeky Chris0Jeky deleted the feature/574-multi-instruction-parsing branch March 30, 2026 22:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Multi-instruction parsing for batch chat requests

1 participant