Skip to main content

AI engine

Who it’s for
Everyone who builds a strategy. And anyone who wants to know why the AI refused something
Assumes
Nothing
Applies to
Every strategy created through chat

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

StageWhat it does
Your messageThe input
Router and ExtractorRun concurrently. The router picks one tool from 18, gated by conversation phase. The extractor reads the whole message for stated values, independent of routing
ResolverReads intent and marks each value as stated, defaulted or derived
CompilerProduces a formal strategy object, or typed gaps
ValidatorFail-closed, with up to three repair attempts
Strategy objectShown to you for review

The compiler has three possible outcomes:

OutcomeWhat happens next
OKProceed to validation
GapsOne bounded repair pass, then proceed or refuse
RefusedStop, 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:

ReasonMeaningWhat happens
UNKNOWN_PHRASENo pattern matched; a model may still read itRetried, narrowly
MISSING_THRESHOLDReal comparison, no number, "near the 20 EMA"Asked, or defaulted
AMBIGUOUS_SCOPE"unless", "except", "rather than"Never retried. You are asked
NOT_REPRESENTABLENo field can hold itNever 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:

ProvenanceMeaning
StatedYou said it. Your words always win
DefaultedThe platform supplied a reasonable value you did not state
DerivedInherited from earlier in the conversation, not from this message
UnsupportedYou 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.

CategoryTools
Inputsmodify_strategy_inputs, ask_user_for_clarification, start_new_strategy
Signalsplan_strategy_signals, modify_signal_selection, edit_condition_term
Assemblyassemble_strategy
Backtestrun_backtest, get_backtest_result
Improveimprove_strategy, improve_strategy_loop
Discoveryfetch_market_data, search_custom_indicators
Controlpause_workflow, mark_strategy_rejected
Replyrespond_text, respond_with_safety_boundary
Riskupdate_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

PageWhat it answers
How the AI understands your requestRouting, extraction, and how a value gets marked as yours
Strategy generation processThe full pipeline, stage by stage
Validation systemWhat is checked before a strategy can exist
Repair systemWhat happens when validation fails, and the retry bounds
AI limitationsEvery refusal reason, with phrases that trigger it
What the AI will not doThe advice boundary and the guards
Example strategiesWorked prompts and the strategies they produce