Skip to content
Crystal CodeDocs
ENEnglish

Pursue runtime

/pursue works toward an objective until a checker model finds it met. The runtime lives in CrystalCode.Engine/Sessions/Pursue.

PursueRun runs inside the one turn that /pursue start or resume opens. CodingSession.ExecuteTurnAsync hands it an IPursueHost from Sessions/Pursue/Interfaces.

Each segment is an ordinary StreamingTurn or MultimodalStreamingTurn. The run merges segment counts, usage, and the last transcript into one TurnResult. The turn uses a SharedTurnBudget built from pursueLimits instead of executionBudget. The budget is shared by every segment, the checker, and child Agents. Each segment gets only the remaining duration.

The checker reads a numbered rendering of the transcript. The rendering drops the oldest entries to fit the checker’s own context, and the checker cites entry numbers. Its JSON answer is parsed strictly by PursueVerdictParser, with no repair request. Transport failures use the retry policy. Checker usage goes to the ledger through RecordChildUsage.

A wait verdict races completion of the listed session tasks against queued input. A task result is delivered once per run, through a budgeted continuation to the working model. The host adds only task ids, statuses, and available exit codes from the registry to that continuation.

The checker reserves response space and budgets the bound prompt, including repeated conversation placeholders and omission notices. Its run-local compaction cache keeps the summary and tail while the original items are unchanged. It appends new items, and it folds older items into the cached summary when needed. Changed or replaced prefixes invalidate the cache. The working transcript and the captured evidence stay independent of that cache.

New stop reasons are pursue_blocked and pursue_limit_reached. Continuation messages are saved as ordinary user messages.

PursueState holds the state. PursueChanged and PursueChecked events, SessionSnapshot.Pursue, and SessionDocument.Pursue carry it.

PursueState.History holds immutable PursueCheckRecord values. Each record has the objective, run, and check ids, the UTC time, the verdict or failure, the reason, the next step, the wait task ids, the usage, and PursueEvidence (number, kind, and the exact rendered text). Rendering captures evidence before the temporary checker context disappears. Evidence numbers are local to that rendering and are never archive indexes.

Each completed attempt updates state and checkpoints before its PursueChecked notification. A failed attempt counts as a check and uses the verdict failed. Retries remain one attempt. Appends share immutable history across state snapshots.

PursueDocument saves identities, history, run counters, and the next step. An older document without counters recovers the check count and next step from matching history where it is available. A new run resets the counters and keeps the objective’s history on resume. Start, clear, and fork replace or drop it.

Front ends receive history through PursueChanged. HTTP and Bridge writers emit only checkCount and latestCheck with the state. GetPursue, ListPursueChecks, and GetPursueCheck are engine queries through the runner. Pages use a non-negative offset (after, default 0) and a limit from 1 through 100 (default 50). They return objectiveId, checks, nextOffset, and hasMore. Clients discard pages for a replaced objective. Server and Bridge own only the explicit wire mapping and parameter validation.

PursueReport builds a DocumentWritten key/value report for status and setting acknowledgements. It reuses the terminal document renderer and the protocol report mappings. GetPursueConfiguration returns the checker choices and limits independently of any objective.

SessionOptionCatalog provides the pursue_* and pursue_compaction_ model and tuning options. BridgeHostSettings permits them in custom lists. Model edits publish SessionOptionsChanged, so clients refresh dependent choices.

Integer limits use PursueLimitCommand.TryCreate to validate a named value and produce the shared slash command. Front ends submit it through the runner, which keeps busy refusals and persistence.

For the wire contract, see Server protocol and Bridge protocol. For the configuration keys, see Configuration.