v0.4.0
First step of the multi-backend MAGI integration: the magi-core crate (already
declared but unused) is now wired in, giving the agent a three-perspective
consensus capability (Melchior / Balthasar / Caspar). Additive only — the
Provider trait, the agent loop, config discovery, and encrypted memory are
unchanged.
Added
consulttool — exposesmagi-core's 3-perspective consensus as a tool the main LLM can invoke autonomously when a question has genuine trade-offs. Routing emerges from the existing tool loop (no separate classifier); each call passes the inline approval gate, which doubles as cost control for the ≈ 3 model calls./consult <question>command — forces a MAGI consensus directly in the TUI, bypassing the router and approval, rendering the verbatim report (three perspectives + verdict). Runsanalyzein a joined task so a panic inmagi-coresurfaces as a recoverable error instead of killing the runner; blocks the session while it runs, like a normal turn.MagiCoreProviderAdapter(src/agent/magi_adapter.rs) — bridges magi-rs's resolvedProvidertomagi_core::provider::LlmProvider, so the consensus reuses the same backend + credentials (Anthropic or any OpenAI-compatible endpoint). No second LLM config layer.- StaticProvider guard —
consultis registered (and/consultworks) only when a real provider is configured; on the static/no-key path the tool is absent and/consultreports that a provider is required. - Degraded surfacing — a consult that completes with fewer than three agents is prefixed
[DEGRADED: …]so a low-quality consensus is never silent. - New tests for the adapter (assembled text, role-fold delimiter, error mapping), the tool (contract + consensus + invalid-args + empty-query + oversized-query + backend-error via
magi-core'sRoutingMockProvider), and the/consultparser + a full-report render-safety test. Total tests: 147 (was 136).
Changed
magi-coredependency bumped1.0→1.1(no features enabled;reqwest 0.12is not pulled — the adapter reuses magi-rs's existingreqwest 0.11stack).test-utilsenabled as a dev-dependency forRoutingMockProvider.
Security
- The verbatim consult report (LLM-generated) is run through
sanitize_textbefore rendering — strips ANSI escapes / control characters, matching the streaming-delta path. Consult input is length-capped (8192 bytes) on both the tool and forced/consultpaths, and empty queries are rejected before any model call.
Known limitations
- System-prompt fold.
magi-coredifferentiates its three personas via distinct system prompts, but magi-rs'sProviderhas no system-role channel yet, so the system text is folded into the user turn (behind an explicit delimiter). On weak / small local models this can weaken persona divergence and JSON adherence. Revisit when magi-rs gains a system-prompt channel. CompletionConfignot applied. The adapter does not forwardmax_tokens/temperatureto the backend (theProvidertrait exposes no per-call knobs). Deferred.- Deferred follow-ups (internal dev-docs): repetitive-call detection keyed on the consult
queryargument, and anInputTooLargeearly-rejection UX for oversized/consultinput.
Full Changelog: v0.3.1...v0.4.0