Skip to main content
ChatCLI ships seven LLM-agent patterns that work together as a harness/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

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.

Pipeline Architecture (engine)

The QualityPipeline itself is a thread-safe machine with enterprise guarantees. Hooks are pluggable, but the scheduler below handles concurrency, failures, and shutdown:
1

State machine (Active β†’ Draining β†’ Closed)

Transitions via atomic CAS. DrainAndClose(timeout) waits for in-flight to finish before closing β€” safe for graceful SIGTERM.
2

Copy-on-Write snapshots

Each AddPre/AddPost/SwapConfig builds a new snapshot and CAS-swaps via atomic.Pointer. In-flight runs always see a consistent view; zero locks on the hot path.
3

Per-hook isolation

Every hook runs inside a wrapper that recovers panics, enforces a timeout (default 30s), and records failures in a per-hook circuit breaker (default 5 failures β†’ open 30s).
4

Priority-based ordering

Hooks implementing Prioritized are ordered (lower first). Ties preserve registration order. Backward compat: hooks without Priority() default to 100.
5

Short-circuit sentinels

A PreHook can return ErrSkipExecution (cache hit β†’ skip agent.Execute) or ErrSkipRemainingHooks (stop the phase). The pipeline synthesizes a result so PostHooks still run.
6

Hot reload

SwapConfig(cfg) atomically swaps config. In-flight runs keep the old config (correct β€” one turn under one config); new runs pick up the new one.

Pipeline metrics

5 collections under chatcli_quality_pipeline_*: Use generation to correlate dashboards with config changes:

Trigger matrix


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.

Observability

Every active pattern shows up in /config quality:
CHATCLI_EMBED_PROVIDER accepts voyage, openai, bedrock, or null. For Bedrock, ChatCLI reuses the same AWS chain as the chat (IAM, profile, SSO) β€” no extra API key. See RAG + HyDE for per-provider details.

Next steps

Tutorial: Plan-and-Solve

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

Configure HyDE with vectors

Enable embeddings (Voyage, OpenAI, or Bedrock Titan/Cohere) for semantic retrieval.

Slash reference

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

Full env var list

All CHATCLI_QUALITY_* and CHATCLI_EMBED_*.