AI engine
The AI is the part of Stretus most likely to be misunderstood in both directions. It is more capable than a form and much narrower than a general assistant. This section explains exactly what it does, how it decides, and, the part that matters most, what it refuses to do and why.
What it is
A strategy compiler with a conversational front end. You state a trading rule in ordinary language; a pipeline reads your words, extracts the specific values you stated, compiles them into a formal strategy object, validates that object against the execution engine's grammar, and shows you the result before anything runs.
It is not a chatbot with a strategy form behind it, and it is not a model asked to write trading code. The difference shows up in the failure modes: a chatbot guesses, and this pipeline refuses.
Why it exists
Because the gap between a trader's idea and a running strategy has never been the idea.
Most traders can state their edge in one sentence. Turning that sentence into something that executes has historically meant writing code, wiring a broker API, handling reconnections, and debugging at 3 a.m. when a position will not close. The AI closes the first half of that gap and the execution engine closes the second.
How it works, at a glance
| Stage | What it does |
|---|---|
| Your message | The input |
| Router and Extractor | Run concurrently. The router picks one tool from 18, gated by conversation phase. The extractor reads the whole message for stated values, independent of routing |
| Resolver | Reads intent and marks each value as stated, defaulted or derived |
| Compiler | Produces a formal strategy object, or typed gaps |
| Validator | Fail-closed, with up to three repair attempts |
| Strategy object | Shown to you for review |
The compiler has three possible outcomes:
| Outcome | What happens next |
|---|---|
| OK | Proceed to validation |
| Gaps | One bounded repair pass, then proceed or refuse |
| Refused | Stop, and say why |
After the strategy object is reviewed, the remaining steps are yours: backtest it, decide, and deploy.
The full workflow, stage by stage, with what can go wrong at each: Strategy generation process.
The five properties that define its behaviour
1. It is bounded
The resolve-compile loop runs at most twice. Never three times. One pass cannot use the compiler's feedback at all; three spends tokens rediscovering a wall the second pass already hit. A span that failed twice will fail a third time.
2. It is additive
The second pass receives only the spans the first pass could not read. Everything already resolved is frozen. Without that, a correctly-read stop-loss could come back different on retry. And a strategy builder that produces different output from the same input is not usable.
3. It is gated
Every value the model produces is parsed against the execution engine's grammar before it is inserted into a strategy. This is not a theoretical precaution: the engine rejects an unknown function but silently resolves an unknown identifier to NaN. A fabricated indicator name would make the entry condition false on every bar and produce a zero-trade backtest with no error anywhere. The gate is what stops that.
4. It is reason-driven
A compile failure is a typed value, not an absence. Four categories, each with a different correct response:
| Reason | Meaning | What happens |
|---|---|---|
UNKNOWN_PHRASE | No pattern matched; a model may still read it | Retried, narrowly |
MISSING_THRESHOLD | Real comparison, no number, "near the 20 EMA" | Asked, or defaulted |
AMBIGUOUS_SCOPE | "unless", "except", "rather than" | Never retried. You are asked |
NOT_REPRESENTABLE | No field can hold it | Never retried. Refused with a reason |
The last two never retry, and that is the point. AMBIGUOUS_SCOPE's honest resolution is a
question to you about what you meant, not a model picking between two readings, because the
failure mode of guessing is an inverted rule that looks plausible. NOT_REPRESENTABLE has no
answer to find.
Full taxonomy with example phrases: AI limitations.
5. It keeps provenance
Every value in the assembled strategy is marked with where it came from:
| Provenance | Meaning |
|---|---|
| Stated | You said it. Your words always win |
| Defaulted | The platform supplied a reasonable value you did not state |
| Derived | Inherited from earlier in the conversation, not from this message |
| Unsupported | You asked for it and the platform cannot express it |
This is why you can trust the read-back. A defaulted stop-loss is never presented as your stop-loss. See How the AI reads your words.
The 18 tools, and why the set shrinks
The router chooses exactly one tool per turn from a catalog of 18. Which tools are available depends on the phase of the conversation, a tool that cannot fire in the current phase is not offered at all.
| Category | Tools |
|---|---|
| Inputs | modify_strategy_inputs, ask_user_for_clarification, start_new_strategy |
| Signals | plan_strategy_signals, modify_signal_selection, edit_condition_term |
| Assembly | assemble_strategy |
| Backtest | run_backtest, get_backtest_result |
| Improve | improve_strategy, improve_strategy_loop |
| Discovery | fetch_market_data, search_custom_indicators |
| Control | pause_workflow, mark_strategy_rejected |
| Reply | respond_text, respond_with_safety_boundary |
| Risk | update_risk_execution_config (read by the extractor, not offered to the router) |
Ambient tools (clarification, market data, starting over, indicator search, input edits, and both reply tools) are reachable from every phase, because those requests are not tied to a stage of construction. Everything else is added only where it can legitimately fire.
An unrecognised phase returns the full catalog. That is a deliberate fail-safe: never drop a tool the model legitimately wants.
Detail: Strategy generation process.
What it will not do
There is a dedicated tool, respond_with_safety_boundary, for requests that ask the platform
to recommend a trade. There are also two regex guards on generated replies, one against
buy/sell phrasing and one against overpromise language.
This is a real, built control rather than a policy statement, and it has documented limits. Both are on What the AI will not do.
This section
| Page | What it answers |
|---|---|
| How the AI understands your request | Routing, extraction, and how a value gets marked as yours |
| Strategy generation process | The full pipeline, stage by stage |
| Validation system | What is checked before a strategy can exist |
| Repair system | What happens when validation fails, and the retry bounds |
| AI limitations | Every refusal reason, with phrases that trigger it |
| What the AI will not do | The advice boundary and the guards |
| Example strategies | Worked prompts and the strategies they produce |