Skip to main content

enterprise_ai.runtime.continuation

Source: sdks/python/src/enterprise_ai/runtime/continuation.py. Back to the Python SDK reference index.

note

This page is generated by tools/docs/gen_sdk_reference.py from the SDK sources and the OpenAPI text folders. Do not edit it by hand: change the source and regenerate.

Model TurnContext​

What the rules look at. Filled by :class:~enterprise_ai.runtime.runner.AgentRunner.

Fields:

NameTypeRequiredDescription
final_textstrnoText of the last answer of the model.
finish_reasonstr | Nonenofinish_reason of the last answer, such as stop or length.
user_textstrnoText of the last user message.
tools_availableboolnoThe model was offered at least one tool.
tool_calls_totalintnoTool calls made in the turn so far.
tool_calls_since_userintnoTool calls made since the last user message.
mutatedboolnoA tool that is neither a check nor read only ran while a verification tool is available.
verified_after_mutationboolnoA verification tool succeeded after the last change (default True).
verify_failedboolnoThe last verification tool call failed.
no_progress_roundsintnoNumber of consecutive tool rounds repeating the same calls.
read_only_roundsintnoNumber of consecutive tool rounds that only called read only tools.
budget_lowboolnoTrue when at most 2 steps remain in the step budget.
require_deliveryboolnoThe turn must use at least one tool before answering (delivery rule).
audit_modeboolnoAudit turn: the exploration rule waits 8 read only rounds instead of 4.
nudgesdict[str, int]noNumber of times each rule fired in the turn, by rule code.

Model ContinuationRule​

One continuation rule: code, stage, cap max_nudges and its prompt.

Fields:

NameTypeRequiredDescription
codestryesCode of the control, 1 to 64 characters: a catalogue code such as EAI-GOV-01, or a custom one. Unique in the tenant.
max_nudgesintyesMaximum number of times the rule may fire in one turn.
predicateCallable[[TurnContext], bool]yesFunction (TurnContext) -> bool that tells whether the turn must go on.
promptstryesMessage appended as a user message when the rule fires.
stagestrnoWhen the rule is evaluated: final (answer without tool calls, default) or round (after each tool round).

ContinuationRule.applies​

applies(ctx: TurnContext) -> bool

True when the predicate holds and the cap is not reached.

NameTypeDefaultRequiredDescription
ctxTurnContextyesContext of the call: cancellation and deadline.

Returns: bool. True when the rule fired fewer than max_nudges times in the turn and its predicate holds on the context.

Functions​

is_go_ahead​

is_go_ahead(text: str | None) -> bool

True for a short approval such as ok, go ahead, vas-y or continue.

NameTypeDefaultRequiredDescription
textstr | NoneyesUser message; None or empty gives False.

Returns: bool. True when the whole text, 40 characters at most, is an English or French approval.

lists_remaining_work​

lists_remaining_work(text: str | None) -> bool

True when an answer lists work still to do (English and French phrases).

NameTypeDefaultRequiredDescription
textstr | NoneyesAnswer of the model; None or empty gives False.

Returns: bool. True when the text contains a phrase such as next steps, remaining work, il reste or reste à faire.

announces_action​

announces_action(text: str | None) -> bool

True when an answer announces an action (I will, je vais).

NameTypeDefaultRequiredDescription
textstr | NoneyesAnswer of the model; None or empty gives False.

Returns: bool. True when the text contains an English or French announcement such as I will, let me or je vais.

default_rules​

default_rules() -> list[ContinuationRule]

The Navin rules in evaluation order.

This element takes no parameter.

Returns: list[ContinuationRule]. A ContinuationRule: One continuation rule: code, stage, cap max_nudges and its prompt.

first_applicable​

first_applicable(rules: list[ContinuationRule], ctx: TurnContext, stage: str) -> ContinuationRule | None

First rule of stage that applies, or None.

NameTypeDefaultRequiredDescription
ruleslist[ContinuationRule]yesRules in evaluation order.
ctxTurnContextyesContext of the call: cancellation and deadline.
stagestryesStage to evaluate: final or round.

Returns: ContinuationRule \| None. A ContinuationRule: One continuation rule: code, stage, cap max_nudges and its prompt.