-
Notifications
You must be signed in to change notification settings - Fork 4
Fix task graph collapse and preserve pipeline task prompts #317
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
edf8b2c
793b90f
4476804
62b3b49
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -28,6 +28,18 @@ import type { Task, TaskGraph, RequestCategory } from "../../schemas/pipeline.js | |
| * → ParallelClassifier.classify() | ||
| */ | ||
| export class TaskGraphProcessor { | ||
| private static readonly DELIVERABLE_TYPES = new Set<RequestCategory>([ | ||
| "create", | ||
| "document", | ||
| "plan", | ||
| ]); | ||
|
|
||
| private static readonly DELIVERABLE_PATTERN = | ||
| /\b(presentation|slides?|deck|outline|structure|report|proposal|script|summary|brief|document|docs|guide|plan|roadmap|table|matrix|comparison|q&a|questions?|talk\s+track|message|copy|email|memo|one[-\s]?pager)\b/i; | ||
|
|
||
| private static readonly INDEPENDENT_ACTION_START_PATTERN = | ||
| /^(?:find|locate|trace|track|follow|show|tell|read|search|explore|browse|inspect|analyze|investigate|explain|diagnose|review|compare|assess|evaluate|create|build|generate|scaffold|implement|add|make|draft|set up|spin up|bootstrap|modify|update|change|fix|patch|edit|refactor|rename|rewrite|remove|replace|improve|optimi[sz]e|tune|correct|enable|disable|toggle|test|validate|verify|assert|confirm|ensure|check|lint|typecheck|run|execute|deploy|start|launch|restart|stop|install|migrate|seed|serve|document|summari[sz]e|describe|write|prepare|plan|design|organize|outline|strategize|propose|break down)\b/i; | ||
|
Comment on lines
+40
to
+41
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Because the collapse check treats fallback Useful? React with 👍 / 👎. |
||
|
|
||
| // 'make' 등 단일 키워드가 create/modify 패턴에 먼저 걸리는 숙어들을 TYPE_PATTERNS보다 먼저 처리. | ||
| // 패턴 순서가 바뀌어도 이 테이블의 판정은 항상 우선한다. | ||
| private static readonly IDIOM_PATTERNS: ReadonlyArray<{ | ||
|
|
@@ -255,6 +267,14 @@ export class TaskGraphProcessor { | |
| // ① 먼저 모든 문장의 type을 한 번에 분류 — resolveDependsOn에서 이전 type을 참조하기 때문 | ||
| const types: RequestCategory[] = sentences.map((s) => this.classifyType(s)); | ||
|
|
||
| if (this.shouldCollapseSingleDeliverable(sentences, types)) { | ||
| const finalType = types[types.length - 1]!; | ||
| const mergedSentence = sentences.join(" "); | ||
| return TaskGraphSchema.parse({ | ||
| tasks: [this.buildTask(mergedSentence, 0, finalType, [])], | ||
| }); | ||
| } | ||
|
|
||
| // ② 각 문장을 Task로 변환하면서 depends_on 결정 | ||
| const tasks: Task[] = sentences.map((sentence, index) => { | ||
| const type = types[index]!; | ||
|
|
@@ -287,6 +307,32 @@ export class TaskGraphProcessor { | |
| return this.FLOWS_TO[prev]?.includes(curr) ? [`t${index}`] : []; | ||
| } | ||
|
|
||
| private static shouldCollapseSingleDeliverable( | ||
| sentences: string[], | ||
| types: RequestCategory[], | ||
| ): boolean { | ||
| if (sentences.length < 2) return false; | ||
|
|
||
| const finalSentence = sentences[sentences.length - 1]!; | ||
| const finalType = types[types.length - 1]!; | ||
| if (!this.DELIVERABLE_TYPES.has(finalType)) return false; | ||
| if (!this.DELIVERABLE_PATTERN.test(finalSentence)) return false; | ||
|
|
||
| const prefixSentences = sentences.slice(0, -1); | ||
| const prefixTypes = types.slice(0, -1); | ||
| return prefixSentences.every((sentence, index) => | ||
| this.isContextQualifier(sentence, prefixTypes[index]!), | ||
| ); | ||
| } | ||
|
|
||
| private static isContextQualifier( | ||
| sentence: string, | ||
| type: RequestCategory, | ||
| ): boolean { | ||
| if (type !== "execute") return false; | ||
| return !this.INDEPENDENT_ACTION_START_PATTERN.test(sentence.trim()); | ||
| } | ||
|
|
||
| /** | ||
| * 하나의 문장으로부터 Task 객체를 생성합니다. | ||
| * | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When a multi-step run has an earlier completed task and a later task fails,
allOkis false so the finalrawOutputuses this helper, but the helper returns the last completed output before considering failed records. For example, a successful create followed by a failed validate now reports the create output whileok: false, hiding the actual adapter error that the previous joined-record behavior exposed.Useful? React with 👍 / 👎.