feat(routing): artifact-aware engine routing via output_requirement (TD-197)#41
Conversation
…TD-197) Artifact-producing subtasks (slide/file/code/data) were routed to Ollama by the regex SubtaskTypeClassifier (e.g. 'Create a PPTX slide file' -> simple_qa -> ollama), which cannot create files and loops. The LLM-derived output_requirement was computed by the bypass classifier but discarded at node-execution routing. - SubTask gains output_requirement; NodeExecutor.to_subtask propagates it. - AgentEngineRouter.select_for_output maps FILE->OpenHands, CODE->Codex, DATA->Gemini; TEXT/None delegate to the task-type router; budget<=0 keeps the LOCAL_FIRST Ollama guard. - LangGraph _execute_batch consults output_requirement before the regex path. - FractalTaskEngine classifies each terminal node's requirement per-node (LLM, gated on the goal being an artifact) instead of blanket goal inheritance, so a 'search' subnode stays on Ollama while the file node escalates. Wired via OutputRequirementClassifier in the container. - SDD artifacts under specs/artifact-aware-routing/. 3373 unit tests pass (+ new), ruff clean. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…k (TD-197) _build_task feeds the inner engine and is the routing-critical path, but it dropped output_requirement (only to_subtask, used for SSE display, carried it). So artifact nodes still reached the inner engine with output_requirement=None and fell through to the regex simple_qa->ollama path. Propagate it + add engine-level tests proving FILE subtasks route to OpenHands and TEXT does not escalate. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
Caution Review failedPull request was closed or merged during review 📝 WalkthroughWalkthroughThis PR implements artifact-aware engine routing (TD-197), enabling LLM engine selection based on output requirements (file/code/data artifacts) inferred during node classification. Changes flow from domain contracts through subtask propagation to routing in both task graph and fractal execution paths, with optional per-node classification for artifact-producing goals. ChangesArtifact-Aware Engine Routing
Sequence Diagram(s)sequenceDiagram
participant Request as Client Request
participant Planner as Node Planner
participant Executor as Node Executor
participant Router as Agent Engine Router
participant Classifier as OutputRequirementClassifier
participant Engine as FractalTaskEngine
Request->>Planner: Submit task
Planner->>Planner: Classify node outputs
Planner->>Executor: Emit PlanNode with output_requirement
Executor->>Executor: Convert to SubTask, copy output_requirement
Executor->>Router: Route via select_for_output(output_requirement)
alt output_requirement is artifact
Router->>Router: Check _OUTPUT_TO_ENGINE mapping
Router-->>Executor: Return artifact-capable engine
else output_requirement is TEXT or None
Router->>Router: Delegate to select(task_type)
Router-->>Executor: Return task-type engine
end
Executor->>Engine: Execute with routed engine
Engine->>Classifier: Classify for per-node artifact escalation
Classifier-->>Engine: output_requirement (file/code/data)
Engine->>Engine: Execute terminal node with classification
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Problem
Artifact-producing subtasks (slide / file / code / data) were routed to Ollama by the regex `SubtaskTypeClassifier` — e.g. "Create a PPTX slide file" classified as `simple_qa` → ollama, which cannot create files and degenerates into repetitive tool loops. The LLM-derived `output_requirement` was already computed by the bypass classifier but discarded at node-execution routing time.
Confirmed live: the slide goal decomposed correctly but every artifact node ran on Ollama and the task timed out with no file produced.
What changed
No new regex heuristics — routing keys off the LLM `OutputRequirement` enum (aligns with the no-rule-based-heuristics principle).
Testing
Notes
🤖 Generated with Claude Code
Summary by CodeRabbit
New Features
Documentation