The idea: different jobs, different models
A main model can handle an entire task. An optional low-cost (LC) model handles work under the chosen execution strategy. A validation model checks a deep-research result; a decision model answers bounded structured questions. A vision model handles images. These roles are independent, and extra model calls can increase cost.
Try it: after configuring OAF_MODEL, configure an LC model available to you and run a small task:
export OAF_LC_MODEL="(type: ollama, model: 'llama3', url: 'http://localhost:11434')"
mini-a modelstrategy=default goal="Compare CSV and JSON for a small data export."
default uses the normal escalation strategy. Use /stats in an interactive session to inspect which model was called. Savings depend on provider prices, retries, and task quality; there is no fixed percentage guarantee.
Use advisor when a cheaper executor benefits from occasional main-model advice, delegate for LC execution, and supervised execution when main must prepare an explicit acceptance contract. Both required model roles must be configured for supervised execution. See the model options.
Dual-Model Cost Optimization
Alongside default, advisor and delegate, modelstrategy=auto selects a strategy per goal. Supervised execution uses main-model preparation and LC execution of a concrete contract, completing only after current evidence passes mandatory checks/review. Both roles are required. Saving accepted contracts and discovering them for reuse are independent opt-ins; defaults remain unchanged.
One of mini-a’s most powerful features is its dual-model architecture. You can assign a cheaper, faster model to handle simple tasks (routing, summarization, classification) while reserving a more capable model for complex reasoning.
export OAF_MODEL="(type: openai, model: gpt-5.2, key: '...')" # Main model — complex reasoning
export OAF_LC_MODEL="(type: openai, model: gpt-5-mini, key: '...')" # Light model — simple tasks
The framework automatically decides which model to use for each subtask, optimizing cost without sacrificing quality where it matters.
You can also add a dedicated validation model for deep-research scoring when you want execution and validation separated:
export OAF_VAL_MODEL="(type: openai, model: gpt-5-mini, key: '...')"
# Or override only this run
mini-a deepresearch=true modelval="(type: openai, model: gpt-5-mini, key: '...')" \
goal='Research the latest release notes and summarize breaking changes'
Recent updates added dynamic escalation controls and per-run cost tracking so you can tune and measure this behavior:
lccontextlimitescalates to the main model when low-cost context gets too large.- After successful steps, Mini-a can return to the low-cost model automatically; inspect
/statsto understand actual routing. getCostStats()returns a per-session usage breakdown for low-cost and main model tiers.OAF_MINI_A_NOJSONPROMPT/OAF_MINI_A_LCNOJSONPROMPTlet you force text-prompt mode per model tier (Gemini main models auto-enable when unset).
Estimated Savings
Compare a representative task under one-model and two-model configurations. Record answer quality, retries, latency, and provider-billed input/output usage. /stats separates model-tier usage when available. Missing pricing or usage data must remain unknown; it is not a zero-cost result.
Dual-Model Setup
mini-a can pair a main model (OAF_MODEL) with a low-cost model (OAF_LC_MODEL). Which one executes a step depends on modelstrategy, escalation, and configured budgets. The LC role is not limited to formatting or planning.
Full configuration:
export OAF_MODEL="(type: openai, model: gpt-5.2, key: '...')"
export OAF_LC_MODEL="(type: openai, model: gpt-5-mini, key: '...')"
When each model is used
| Strategy | Execution behavior |
|---|---|
default |
Uses the normal LC-to-main escalation policy when LC is configured |
advisor |
LC executes with bounded main-model consultations |
delegate |
LC executes the task |
supervised |
Main prepares a contract; LC executes against it |
auto |
Selects a strategy for the run |
Benefits
- Control model spend by assigning work to a model appropriate for the task and measuring the result.
- Tune latency by choosing providers and models that respond quickly for your workload.
-
Mix providers freely. You can use different providers for each model. For example, use Anthropic for reasoning and OpenAI for lightweight tasks:
export OAF_MODEL="(type: anthropic, model: claude-sonnet-4-20250514, key: '...')" export OAF_LC_MODEL="(type: openai, model: gpt-5-mini, key: '...')"
When the light model is not set, mini-a uses the main model for everything. Setting the light model is optional but recommended for cost-sensitive workloads.
Model Strategy Modes
modelstrategy controls how Mini-A allocates work between the main model and the LC (low-cost) model when both OAF_MODEL and OAF_LC_MODEL are configured. default, advisor and delegate share the single-model execution path when LC is absent. supervised requires both roles; auto selects a concrete strategy per run.
| Mode | When to use |
|---|---|
default |
General-purpose work. Mini-A starts on the main model for the first step of complex goals, then switches to LC. Automatically escalates back to main when errors or stalled reasoning are detected. Best baseline — start here unless you have a specific reason to deviate. |
advisor |
Long or risky tasks where LC cost savings matter but you still want main-model judgment on hard calls. LC executes every step; the main model is consulted (not executed) only on risk signals, ambiguity, or hard-decision checkpoints. Use when you want to cap spend but cannot afford a wrong decision mid-task. |
delegate |
Batch / throughput scenarios where speed and cost matter more than best-first-step quality. LC executes all steps including step 0 (skips the default behavior of using main for the first step on complex goals). Escalation to main is still active when error/stall thresholds are hit. Use for repetitive, well-understood tasks. |
supervised |
Main prepares a concrete contract; LC executes it under host-controlled acceptance checks. See Supervised Execution |
auto |
Resolve a strategy once per run from resume state, contract options, model availability, complexity and verification requirements |
Quick decision guide:
- Single goal, unknown complexity →
default - High-stakes or irreversible actions, dual-model setup →
advisor(addharddecision=requirefor critical deployments) - Bulk/batch processing, cost is the primary concern →
delegate - Let Mini-A choose a strategy →
auto - Require contract-based acceptance with both roles configured →
supervised - Only one model configured →
default; explicit supervised execution fails without LC
When advisor mode is active and the agent encounters a difficult step, it sends a structured query to the main model and receives back a JSON assessment with recommended_next_step, risk_flags, escalate_to_main, and confidence fields. The LC model then proceeds with that guidance. If escalate_to_main is true, the main model takes over for that step only.
| Parameter | Default | Description |
|---|---|---|
modelstrategy |
default |
default, advisor, delegate, supervised, or auto |
advisormaxuses |
2 |
Maximum advisor consultations per run |
advisorcooldownsteps |
2 |
Minimum steps between consecutive consultations |
# default — adaptive escalation, good general-purpose starting point
mini-a goal="summarize this repository" useshell=true
# advisor — LC executes every step, main model consulted on hard decisions
mini-a goal="refactor the auth module" \
modelstrategy=advisor useshell=true
# advisor — block execution until main model approves risky actions
mini-a goal="deploy to production" \
modelstrategy=advisor harddecision=require useshell=true
# delegate — LC handles all steps (including step 0), use for batch / throughput
mini-a goal="process log files and extract errors" \
modelstrategy=delegate useshell=true
# delegate — combine with lcbudget to cap total LC spend
mini-a goal="generate summaries for 50 documents" \
modelstrategy=delegate lcbudget=100000
Automatic strategy selection
modelstrategy=auto resolves before prompt construction. The first matching rule wins: resumed runs retain their recorded strategy; contract options select supervised; no LC or modellock=main|lc selects default; complex goals with verification words (test/validate/verify/ensure) or outfile select supervised when compatible; other complex goals select advisor; medium low-risk goals with positive lcbudget select delegate; remaining goals select default. Medium complexity can be refined by a configured decision model. Contract intent still requires a valid supervised configuration. Under orchestrationcontext (default auto), console and web sessions count as interactive and never auto-select supervised; batch runs need a complex execution goal, a deliverable and a verification signal. An explicit supervised strategy, a contract or a resumed supervised run still wins.
orchestration=auto uses this resolver when modelstrategy is not explicit. Child tasks of an auto run resolve for their own goals. The choice is logged as Model strategy auto -> X and traced as model_strategy_decision; explicit strategies remain authoritative. The default remains default.
Decision-assisted selection and verdict gates
Set modeldec or OAF_DECIDE_MODEL to configure a stateless decision model. It requires OpenAF getCapabilities() and decideWithStats() support. With an existing mcpdynamic=true or capabilityselection=true mode, it ranks candidate relevance; it also refines ambiguous goal complexity. Configuration alone does not enable dynamic selection. /model dec, /set modeldec and Advanced Models configure the session slot; /models reports its effective source. usedecide=false disables calls, and llmcomplexity=false opts out of complexity refinement.
Selection preserves policy filters and capability limits. Empty/invalid selections, provider failures, catalogs above 64 candidates or requests above 48 KiB use the existing selector; no catalog is silently truncated. Decision calls have no conversational history or tools and do not grant permissions. Native probabilities are provider information, not correctness guarantees.
Explicit usedecide=true enables bounded verdict gates: executable-plan critique and fully successful research validation can skip generative review; LC-progress decisions can defer escalation; low-value advisor consultations can be skipped, excluding risk/error-recovery signals. Complexity can select planning style, child handoffs can rank tools after explicit matches, relevant memories can be reranked, and reflected memories can be filtered for durability. Failed, ambiguous or unavailable decisions retain the original path. Research with valtools=true keeps its validator path.
Validated identical gate answers are cached only within the run. Uncached gates obey rpm/tpm, 32-question and 48 KiB budgets. Configuration/runtime-support failure disables further gates for that run. Decision failures do not retry or switch decision providers; the original path can still make its usual LC/main calls. Automatic skill consultation has its own selector fallback.
With explicit useutils=true usedecide=true, the bounded decide utility accepts state and questions (choice, boolean or ordinal score). It respects utilsallow/utilsdeny, permits at most 32 consultation attempts per run and 32 questions/48 KiB per request, returns {response, stats}, and accepts no provider/model overrides or file/image paths. Provider failures return sanitized errors without retries, fallback calls or tool-result caching.
getMetrics().decisions reports calls, failures, fallbacks/reasons, duration and reported token usage; usage_reports distinguishes absent usage from reported zero. llm_calls.total includes main, LC, validation, advisor and decision calls. Use debugdecch for decision traffic, keeping full debug output private. See standalone decision MCP.
Direct decisions with /decide
/decide sends a question straight to the configured decision model. It works in the console and in the Advanced web Decisions screen, before any goal has run and without useutils=true. The main and LC models are never called.
| Form | What happens |
|---|---|
/decide |
Guided composer: shared scope, evidence and named questions, then a review step before submission |
/decide interactive |
Asks for each input one at a time, including choice keys and ordered score levels; the web uses input dialogs |
/decide <JSON/SLON> |
Submits a complete {state, questions} request |
/decide help |
Shows syntax and an example without calling a provider |
/decide {"state":{"scope":"Assess only the supplied incident facts.","evidence":"One customer was charged twice; other payments work."},"questions":{"urgent":{"type":"boolean","instructions":"Does this require immediate attention?"},"team":{"type":"choice","instructions":"Choose the responsible team.","criteria":{"billing":"Payments and refunds","technical":"Software failures"}}}}
Questions are boolean, choice or ordinal score (levels start at zero). A request can hold at most 32 questions and 48 KiB, and must carry its own evidence: files, images, provider options and model overrides are rejected. Type /cancel at a prompt to abort, or """ to begin and end multiline input. The session modeldec overrides OAF_DECIDE_MODEL, and an explicit usedecide=false blocks the command. Each call uses a fresh client with no retries, honors session rpm/tpm, attaches debugdecch and appears once in /stats. /last and the agent conversation are unchanged.
Low-Cost Tool Calling (usetoolslc)
usetoolslc=true registers MCP tools natively on the low-cost model only, while the main model continues to use prompt/action-based tool guidance. Use this when you want the cheaper model to call tools directly during low-complexity steps without enabling native tool calling on the main model as well.
mini-a goal="scan docs and escalate if needed" \
modellc="(type: openai, model: gpt-5-mini, key: '...')" \
mcp="(cmd: 'ojob mcps/mcp-files.yaml')" \
usetoolslc=true
This is distinct from usetools=true, which enables tool calling on whichever model is currently active (main or LC). With usetoolslc, only the LC model gets the native tool interface.
Low-Cost JSON Recovery (lcjsonretries, lcreplytool)
Mini-A picks its next action from a reply envelope such as {"thought":"done","action":"final","answer":"..."}. Smaller models sometimes return text that does not parse. Two settings control recovery before Mini-A escalates to the main model:
lcjsonretries(default1) gives the low-cost model that many extra same-step attempts on an unparseable text reply. Retries do not consume amaxstepsstep, but they do cost tokens and provider calls and count towardlcbudget. Set0for immediate fallback. Text, already-parsed objects, and arrays are all accepted, and retries keep provider JSON-mode restrictions (including Ollama native tools).lcreplytool=true(opt-in) uses the same retry slot differently: instead of a corrective text prompt, Mini-A asks the low-cost model for onesubmit_replytool call. The isolated recovery instance has only that local MCP tool, and its handler captures a validated single-action payload. It never executes shell commands or other tools, and Mini-A processes the captured reply through its normal dispatcher. It is supported on OpenAI-compatible (type=openai) and Ollama adapters; others keep the text retry. Neitherusetoolsnorusejsontoolneeds to be enabled.
mini-a goal="..." modellc="(type: ollama, model: 'llama3.2')" lcreplytool=true lcjsonretries=1
Check getMetrics().llm_calls for lc_json_retries, lc_reply_tool_attempts, lc_reply_tool_successes, and fallback_to_main_llm. A successful capture does not mean the requested action succeeded, and a syntactically valid object with a wrong action name or missing tool argument follows the normal action-validation path rather than counting as a JSON failure. modellock=lc selects the low-cost tier for normal steps, but recovery can still call the main model, so it is not a strict spending or provider-isolation boundary.
To investigate a stubborn failure, rerun with debug=true and inspect STEP_PROMPT, LLM_RESPONSE, and NORMALIZED_MSG (fallback calls use FALLBACK_RESPONSE), then compare promptprofile=minimal, balanced, and verbose explicitly, since debug mode changes the default profile. Debug output can include your goal and tool data, so review it before sharing. Extra retries add cost without fixing a model that consistently returns the wrong schema.
System Prompt Profiles (promptprofile)
Control how verbose the system prompt is. A shorter prompt reduces token cost on every LLM call:
| Value | Description |
|---|---|
minimal |
Shortest possible — drops examples and detailed guidance. Default in chatbot mode. |
balanced |
Balanced detail and token usage. Default for most sessions. |
verbose |
Full detail. Auto-enabled when debug=true outside chatbot mode. |
# Reduce per-call token overhead
mini-a promptprofile=minimal goal="..."
Set systempromptbudget=<n> to cap the estimated system prompt tokens. When exceeded, Mini-A drops lower-priority sections to stay under the limit:
mini-a systempromptbudget=4000 goal="..."