Skip to main content
ChatCLI ships seven LLM-agent patterns that work together as a quality pipeline wrapping the existing ReAct dispatcher. Each pattern has a distinct purpose, can be toggled per session or via /config, and composes with the others without regressing steady-state performance.
Design premise: opt-in by default. With CHATCLI_QUALITY_* unset, the pipeline runs with zero post-hooks — Pipeline.Run degenerates to a direct agent.Execute call. You only pay for what you enable.

The seven patterns

#1 — ReAct

Reason → Act → Observe. The base loop every worker runs. Already present; now emits structured events and auto-attaches effort hints.

#2 — Plan-and-Solve / ReWOO

PlannerAgent emits structured JSON; PlanRunner executes steps in topological order with #E1.head=200 placeholders.

#3 — Reflexion

Detects error, hallucination or low quality; distills a Lesson via LLM and persists in memory.Fact for future RAG retrieval.

#4 — RAG + HyDE

Hypothesis-based keyword expansion (3a) + cosine vector search (3b — Voyage/OpenAI, pure-Go backend).

#5 — Self-Refine

RefinerAgent critiques the draft and rewrites. Multi-pass with convergence via EpsilonChars.

#6 — Chain-of-Verification

VerifierAgent generates independent verification questions, answers each, and rewrites on discrepancy.

#7 — Reasoning Backbone

Cross-provider abstraction: thinking_budget on Anthropic, reasoning_effort on OpenAI. Auto-attach for critical agents.

Configuration

CHATCLI_QUALITY_* env vars, /config quality, and the five slash commands: /thinking, /plan, /refine, /verify, /reflect.

How the patterns connect

                 ┌──────────────────────────────────────┐
                 │   /agent or /coder <task>            │
                 └──────────────────┬───────────────────┘

  (#4 RAG+HyDE) ────────────────────▼───────────────
  memory.Retriever expands hints with an LLM-generated
  hypothesis (HyDE-3a) and optionally searches the
  vector store (HyDE-3b) before assembling the system
  prompt.

  (#2 Plan-and-Solve) ──────────────▼───────────────
  When triggered (auto-score or /plan), the planner
  emits a JSON plan, PlanRunner executes each step
  resolving #E1 placeholders, and a deterministic
  report is injected into history.

                    ┌───────────────▼───────────────┐
                    │   ReAct loop (workers)        │
                    │   (#1, always on)             │
                    └───────────────┬───────────────┘

                    ┌───────────────▼───────────────┐
                    │   QualityPipeline (per call)  │
                    │   - Pre:  applyAutoReasoning  │ (#7)
                    │   - Execute worker            │
                    │   - Post: RefineHook          │ (#5)
                    │   - Post: VerifyHook          │ (#6)
                    │   - Post: ReflexionHook       │ (#3)
                    └───────────────┬───────────────┘

  Lessons from Reflexion are persisted to memory.Fact
  and surface again via #4 on similar future tasks —
  closing the loop without retraining.
Architectural principle: every new pattern hooks into the dispatcher or the context builder — the inner ReAct loop (worker_react.go) does not change. Patterns don’t replace each other, they compose.

Trigger matrix

PatternSlashEnv varDefaultAuto trigger
#1 ReActalways onalways
#2 Plan-First/plan [task]CHATCLI_QUALITY_PLAN_FIRST_MODEautocomplexity ≥ 6
#3 Reflexion/reflect <lesson>CHATCLI_QUALITY_REFLEXION_ENABLEDonerror, CoVe flagged, refine low
#4 HyDE— (transparent)CHATCLI_QUALITY_HYDE_ENABLEDoffevery retrieval
#5 Refine/refine on|offCHATCLI_QUALITY_REFINE_ENABLEDoffpost-worker
#6 CoVe/verify on|offCHATCLI_QUALITY_VERIFY_ENABLEDoffpost-worker
#7 Reasoning/thinking on|offCHATCLI_QUALITY_REASONING_MODEautofor AutoAgents

Override priority

For a given turn, the effort hint resolves in this order (later wins):
1

Skill frontmatter

effort: high in the activated skill’s frontmatter.
2

Agent default

E.g. PlannerAgent has embedded effort="high".
3

CHATCLI_QUALITY_REASONING_*

Auto-enable for agents in AutoAgents.
4

/thinking session override

Wins over everything above for the next turn.
For Refine / Verify / Reflexion hook enablement:
1

/config quality (env)

CHATCLI_QUALITY_REFINE_ENABLED, etc.
2

/refine and /verify session toggles

*bool override living on cli.qualityOverrides; overrides env for the session.
For Plan-First:
1

/plan one-shot flag

cli.pendingPlanFirst = true consumed on next dispatch.
2

CHATCLI_QUALITY_PLAN_FIRST_MODE + complexity

always ignores score; auto fires when ComplexityScore(task) >= threshold.

Cost and latency

Defaults are calibrated for steady-state identical to pre-pipeline chatcli. Expensive patterns (Refine, Verify, HyDE) start off; you opt in when the context justifies.
PatternExtra LLM calls per turnNotes
ReAct0 (already part of the loop)
Plan-First (auto)+1 (planner) when triggeredSteps reuse the dispatcher
Reflexion+1 (lesson gen), backgroundNever blocks the turn
HyDE 3a+1 (hypothesis), cheap200 token budget
HyDE 3b+1 (query embed) + lazy backfillembedding API ~$0.00002/1k tokens
Self-Refine+N (one per pass, default 1)Convergence cuts it short
CoVe+1 (verifier) per call siteInternally N=3 questions
Reasoning auto0 extra calls; +tokens on hosted thinkingAnthropic budget = 8k default

Observability

Every active pattern shows up in /config quality:
✨ AGENT QUALITY PIPELINE ────────────────────────
  CHATCLI_QUALITY_ENABLED         : enabled
  Hooks registered                : pre=0, post=3

  ── Self-Refine (#5)
  CHATCLI_QUALITY_REFINE_ENABLED  : enabled
  CHATCLI_QUALITY_REFINE_MAX_PASSES: 1
  ...

  ── RAG + HyDE (#4)
  CHATCLI_QUALITY_HYDE_ENABLED    : enabled
  CHATCLI_QUALITY_HYDE_USE_VECTORS: enabled
  CHATCLI_EMBED_PROVIDER          : voyage
  Vector provider                : voyage:voyage-3
  Vector entries                 : 127

Next steps

Tutorial: Plan-and-Solve

Start with the pattern with highest leverage on multi-step tasks.

Configure HyDE with vectors

Enable embeddings (Voyage or OpenAI) for semantic retrieval.

Slash reference

/thinking, /plan, /refine, /verify, /reflect.

Full env var list

All CHATCLI_QUALITY_* and CHATCLI_EMBED_*.