feat(routing): tier-aware fallback, output format guard, task decomposition#77
Merged
Merged
Conversation
…sition Three opt-in/always-on improvements to routing resilience and output quality, driven by real T3 Code + Lynkr integration testing. 1. Tier-aware fallback (escalate-then-demote) — src/routing/tier-fallback.js On provider failure, climb to a MORE capable tier first (toward REASONING); only if every higher tier is unavailable fall downward to SIMPLE/local. Skips circuit-OPEN providers, dedups provider:model, never re-tries the failed model. Surfaced via X-Lynkr-Fallback / X-Lynkr-Served-Tier headers + warn logs (never silent). Always on. Integrated in invokeModel's catch block. 2. Output format guard — src/context/output-format-guard.js Injects a markdown formatting instruction for non-Claude backends so weaker models avoid ASCII/Unicode box-drawing diagrams. Keyed off the routing- resolved provider/model; skips Claude-family backends. Always on. 3. Task decomposition — src/agents/decomposition/ Opt-in (TASK_DECOMPOSITION_ENABLED). Cost-aware gate decides when to split a task into isolated-context subtasks (parallel where independent), then synthesizes; confidence-scored with monolithic fallback; shadow mode + net-savings telemetry. Exposed as the DecomposeTask tool. Tests: 47 new unit tests (gate/planner/dispatcher/synthesizer, format guard, tier-fallback chain). No regressions in existing suites. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.
Summary
Three improvements to routing resilience and output quality, built and validated against a live T3 Code → Claude Code → Lynkr integration.
1. Tier-aware fallback (escalate-then-demote) — always on
src/routing/tier-fallback.js+invokeModelcatch block.On provider failure, climb to a more capable tier first (toward
REASONING); only if every higher tier is unavailable, fall downward toSIMPLE/local.provider:model, never re-tries the failed modelX-Lynkr-Fallback,X-Lynkr-Served-Tier,X-Lynkr-Fallback-From-Tier,X-Lynkr-Fallback-Directionheaders + warn logsCOMPLEX (Moonshot) fails → REASONING (Azure) → MEDIUM/SIMPLE (Ollama)2. Output format guard — always on
src/context/output-format-guard.js.Injects a markdown formatting instruction for non-Claude backends so weaker models avoid ASCII/Unicode box-drawing diagrams. Keyed off the routing-resolved provider/model; skips Claude-family backends (already clean). Idempotent; handles string & array
system.3. Task decomposition — opt-in (
TASK_DECOMPOSITION_ENABLED)src/agents/decomposition/, exposed as theDecomposeTasktool.Cost-aware gate decides when splitting is worthwhile → planner emits a validated subtask DAG → dispatcher runs subtasks (parallel within dependency levels, isolated context) → synthesizer combines → confidence-scored with monolithic fallback. Shadow mode + net-savings telemetry. Built on the existing subagent stack.
Config
TASK_DECOMPOSITION_ENABLED(defaultfalse) — the only new env knob; all other decomposition settings hardcodedTesting
🤖 Generated with Claude Code