Skip to content

Surface ruflo dual-mode role delegation + agentic-qe agent-type routing in ak's provider UX #36

Description

@pacphi

Summary

ak x provider pick already wires ruflo's dual-host env flags (ENABLE_CLAUDE_CODE/ENABLE_CODEX) and agentic-qe's primary/fallback LLM provider (AQE_LLM_PROVIDER + .agentic-qe/llm-config.json). What it doesn't surface is the layer above that: ruflo and agentic-qe both support role/agent-type-scoped model delegation (not just "which providers are turned on"), and none of that is discoverable from ak's UX today. This issue records the source-grounded findings (via RuvNet Brain / search_ruvnet) and proposes a phased UX change to close the gap — scoped strictly to what ruflo and agentic-qe actually support today, not new capability we'd have to build ourselves.

Findings (source-grounded)

1. Two distinct "Claude + Codex together" mechanisms exist — don't conflate them

  • ADR-034 "Optional MCP Backends" (ruflo/docs/adr/ADR-034-OPTIONAL-MCP-BACKENDS.md, Accepted) — env toggles (ENABLE_CLAUDE_CODE, ENABLE_CODEX, ENABLE_GEMINI_MCP) that let ruflo's agent loop run both host CLIs as MCP backends, tool-namespaced (claude__Read, codex__execute). This is the axis ak already wires. It has no role/delegation logic — it just turns both hosts on.
  • @claude-flow/codex (separate npm package, bin claude-flow-codex; source v3/@claude-flow/codex/src/dual-mode/{orchestrator,cli}.ts) — implements actual role-based delegation: a dual CLI subcommand running a pipeline of WorkerConfig{id, platform:'claude'|'codex', role, prompt, dependsOn} objects over shared memory. ruflo init --dual requires this package as a prerequisite — src/lib/providers.mjs's ensureCodexAdapter()/ensureDualAgents() already installs it correctly, but nothing downstream tells the user it exists or how to use it.

Confirmed built-in role templates in cli.ts:

Template Pipeline Claude workers Codex workers
feature architect → coder → tester → reviewer architect, reviewer coder, tester
security scanner → analyzer → fixer analyzer scanner, fixer
refactor analyzer → planner → refactorer → validator analyzer, planner refactorer, validator

Custom role splits are supported via repeatable --worker "<platform>:<role>:<prompt>" flags (chained sequentially via implicit dependsOn, or --parallel-workers), or a --config path.json exporting {workers, taskContext}.

Today's gap: ak x provider pick enables the hosts and installs the adapter, but never mentions claude-flow-codex dual run --template … or the custom --worker syntax. A user who enables both hosts has no way to discover role delegation exists.

2. Judgment/evaluation quality — two measured findings worth acting on

  • Cross-vendor judging is measurably less biased than same-vendor. v3/@claude-flow/cli/assets/model-router/openrouter-alts.json's judge_bias_check_2026_06_15 block: grading the same answers with openai/gpt-4.1 as judge instead of the default anthropic/claude-sonnet-4-6 scored everything 7–11pp harsher across the board but preserved the same relative ranking, and showed no Anthropic-family favoritism (gpt-4.1 was rated above Sonnet's own score). Actionable: same-vendor judges run ~8–10pp inflated but are ordinally trustworthy; use a different vendor when you need calibrated absolute scores.
  • A cheap LM judge can score worse than a plain vote. agenticow/examples/multi-persona-consensus.mjs found "a verifier-gated cheap-LM judge picks WORSE than a plain vote — a negative generation–verification gap" and instead uses a deterministic two-part selector (hard-constraint gate + rubric-distance score) across N persona branches, discarding losers for free via COW branching.
  • AQE's own qe-quality-gate agent (agentic-qe/.claude/agents/v3/qe-quality-gate.md) encodes the same lesson structurally via ADR-105 evidence tiers: gates block only on EXECUTED/STATIC evidence; INFERRED (model judgment) routes to adversarial verification (ADR-102) rather than being trusted solo; CONJECTURE never gates.

Today's gap: none of this is surfaced anywhere in ak. If a user wires an aqe fallback chain or a dual-mode judge worker, they get no guidance on vendor diversity for judging.

3. agentic-qe already has agent-type-scoped model routing — deeper than what ak exposes

  • HybridRouter (ADR-043, agentic-qe/src/shared/llm/router/hybrid-router.ts) — 4 routing modes (manual / rule-based / cost-optimized / performance-optimized), config precedence override → env (AQE_LLM_*, provider keys) → .agentic-qe/llm-config.json → DEFAULT_ROUTER_CONFIG.
  • Milestone 8 (agentic-qe/src/shared/llm/router/agent-router-config.ts, routing-rules.ts) — "Smart routing by agent type": a comprehensive agent-to-model mapping across all 59+ QE agent types, capability-based routing (reasoning/tools/cost), agent-category detection, and an override mechanism for specific tasks.
  • ak's applyAqeRouter() (src/lib/providers.mjs) currently writes only a flat, global fallbackChain + defaultProvider — it has no notion of per-agent-type overrides, even though AQE's router supports them internally.
  • Not yet confirmed: whether the per-agent-type override is exposed via a stable on-disk schema in .agentic-qe/llm-config.json today, or is programmatic-only (createModelRouter({...}) call sites). There's also a separately-confirmed, stable customization surface — .claude/agent-overrides/*.yaml (BMAD-002 overlay schema, agentic-qe/src/agents/overlay-schema.ts) which supports "Runtime configuration overrides" per agent and explicitly survives aqe init reinstalls — that may or may not be the right place to carry a provider override. This needs a source spike before any code is written (see Phase 3 below).

4. Current ak implementation snapshot (for reference)

src/lib/providers.mjs / src/commands/x/provider.mjs today:

  • Detects claude/codex CLIs, installs whichever is absent, writes ENABLE_CLAUDE_CODE/ENABLE_CODEX.
  • Installs @claude-flow/codex and runs ruflo init --dual --force when codex is opted in (prerequisite-only — never invokes the dual CLI itself).
  • Lets the user set AQE_LLM_PROVIDER (primary) and an ordered aqeFallback chain, written to .agentic-qe/llm-config.json via applyAqeRouter().
  • Has zero UX connecting "both hosts are enabled" to "here's how to actually delegate roles between them," and zero guidance on judge-vendor diversity.

Proposal: phased UX improvements

Scope is deliberately capped at surfacing and gently defaulting what ruflo/agentic-qe already support — no new routing capability invented inside ak.

Phase 1 — Guidance surfacing (no new state, low risk)

  • After a successful pick with both hosts enabled, print a one-line pointer to role delegation: claude-flow-codex dual run --template feature|security|refactor (or custom --worker specs) — Claude designs/reviews, Codex implements/tests by default.
  • When both hosts are enabled (in pick and in status), print a one-line judge-bias tip referencing the measured cross-grading result, recommending a different vendor as judge for calibrated scores.
  • Acceptance: ak x provider pick --host claude,codex and ak x provider status both print the two tips; existing tests unaffected; new assertions added for the printed guidance.

Phase 2 — Smarter interactive defaults (no new persisted fields)

  • In the interactive aqe fallback chain prompt, when codex is among the hosts being enabled and the user leaves the fallback prompt blank, pre-fill/suggest claude-code:<default>; openai:<default> instead of defaulting to empty — since Codex's models are reached via the openai provider type, this is a direct inference from the hosts already chosen in the same session.
  • Acceptance: interactive pick with --host implying codex shows the suggested chain as the prompt default (still overridable); non-interactive --aqe-fallback behavior unchanged.

Phase 3 — Spike: per-agent-type provider overrides (build only if confirmed)

  • Before writing code: confirm whether AQE's agent-router-config.ts / routing-rules.ts override mechanism has a stable, documented on-disk config surface (vs. programmatic-only), and whether .claude/agent-overrides/*.yaml (BMAD-002) is the intended carrier for a provider/model override field.
  • If confirmed: extend ak x provider pick with an optional "route specific agent types to a specific provider" step (e.g. qe-security-scanner → openai, qe-test-architect → claude-code), written to whichever surface AQE actually reads.
  • If not confirmed as stable/documented: close this phase as "not exposed yet upstream" rather than reverse-engineering an undocumented internal shape.

Phase 4 — Deferred, opt-in only (explicit sign-off required)

  • A persisted kit.json role-split preference (e.g. providers.dualRoleSplit) that ak uses to scaffold package.json convenience scripts (dual:feature, dual:security, dual:refactor) pointing at the right claude-flow-codex dual run invocation. This is a real product opinion (scaffolding files into the user's package.json), not just wiring — held back pending explicit go-ahead rather than bundled with the rest.

Non-goals

  • No changes to ruflo's or agentic-qe's own routing logic — this is ak UX only.
  • No new LLM-judge implementation inside ak — Phase 1's guidance only points at existing measured findings, it doesn't build a judge.
  • Phase 4 is explicitly excluded from this issue's initial scope.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions