feat: add prompt classification and rewriting pipeline#475
Closed
avoidwork wants to merge 30 commits into
Closed
Conversation
- Integrate promptPipeline into React agent call flow - Fall back to original message on pipeline errors - Add config schema support for promptRewrite settings - Add unit tests for prompt pipeline
Owner
Author
Audit Report: PR #475 vs Issue #4671. Original Issue Requirements
2. Spec RequirementsRequirement: Pipeline classifies user prompts into structured metadata
Requirement: Pipeline rewrites user prompts into optimized format
Requirement: Pipeline integrates into agent flow before message construction
Requirement: Pipeline is configurable and toggleable
Requirement: Pipeline modules are composable and testable
3. Audit Findings from Issue #467
4. Code Quality Checks
5. Gaps / Notes
6. Verdict✅ Issue #467 is fully delivered. All requirements from the original issue are implemented. All spec requirements are met with corresponding tests. The pipeline is:
The only deferred item (custom prompt templates via config) was intentionally excluded per the design doc's decision to keep templates in Fixes #467 |
- Create intent-specific rewrite templates in ./prompts/ (question, task, creative, analysis, other)
- Update prompts.js to load external templates based on classification intent
- Add fallback to default template for unknown intents
- Add placeholder replacement for {{userPrompt}}, {{intent}}, {{domain}}, {{complexity}}
- Add tests for external template loading and fallback behavior
- Update tasks.md to mark 5.3 as complete
Owner
Author
Update: External Prompt Templates (Task 5.3)Implemented external prompt templates loaded by intent classification. Changes
Template StructureEach template uses This allows templates to be edited independently without code changes. Files Changed
|
- Rename rewrite-*.md to REWRITE_*.md to match existing prompts/ convention - Update prompts.js to use uppercase template filenames
- Add AGENT_PROMPT_REWRITE_ENABLED to README.md env var table - Add promptRewrite.enabled to README.md Config Reference - Add Prompt Rewrite Pipeline Flow section to docs/FLOWS.md - Add promptPipeline files to docs/OVERVIEW.md Agent section
- Group sections into Subsystems and Tools categories - Nest Prompt Rewrite Pipeline under Agent - Nest Sub-Agent Log and Sub-Agent Message under Sub-Agent - Trim Logger (operational, not architectural) - Trim Sub-Agent from 11 features to 3 key architectural points - Trim Memory file table to high-level files - Convert Key Data Flows ASCII charts to mermaid - Add closing paragraph pointing to FLOWS.md
…oolean - Remove nested 'enabled' key from config.yaml - Update schema in src/config/schemas.js to accept boolean directly - Update index.js to pass config.agent?.promptRewrite instead of ?.enabled - Update all documentation references in README.md, docs/OVERVIEW.md, docs/FLOWS.md - Update openspec archive files to reflect new config structure - Rename env var from AGENT_PROMPT_REWRITE_ENABLED to AGENT_PROMPT_REWRITE
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.
Description
Adds a pre-processing pipeline that classifies user prompts by intent, domain, and complexity, then rewrites them into optimized format before reaching the React agent graph. Includes full implementation, config schema support, unit tests, and OpenSpec design artifacts.
Type of Change
Testing
tests/unit/promptPipeline.test.js(392 lines) covering all pipeline categories, classification logic, and rewriting behavior.Coverage
Checklist
npm run lintpasses