soev for developers
soev-agentsReference

soev_agents.toolkit

Ready parts to build agents: the ReAct agent, its inputs, prompts and tools, and its context management.

Each part is one choice among others, and you can write your own part in its place. ReActAgent puts the parts together into one . A of your own uses the same parts, such as MessageBuilder in an LlmStep.

ReAct agent

A ready that calls until the model writes its final output.

ReActAgent

classReActAgent[R, T: BaseModel](config, *, input=Text, element_types=(), event_types=())

A ready that runs the ReAct loop: the model calls until its output calls none.

Each model output with runs the , and the model is called again with their results. The ends with the first model output that calls no . Register the in an AgentCatalog under a name.

The settings come from config: one ReActConfig for every , or a function that builds the config of each . The function gets the of the , the parsed turn and the model that the 's input names. So it can give each model its own settings, or refuse a with InputDeniedError. The whole runs on that model. The is never asked which model it is.

Nothing is recorded beyond the conversation. The system prompt and the instructions of required follow from the config and each recorded input, so each later model call writes them again.

Example

from openai import AsyncOpenAI

from soev_agents.adapters import InMemoryTraceStore, OpenAIChatModel
from soev_agents.runtime import AgentCatalog
from soev_agents.toolkit import BRACKETS, ReActAgent, ReActConfig

# PROMPT is your system prompt text, and search is a tool that the `tool` decorator made.
model = OpenAIChatModel(AsyncOpenAI(), model="gpt-4.1-mini")
assistant = ReActAgent(ReActConfig(model=model, prompt=PROMPT, tools=[search], citations=BRACKETS))
agents = AgentCatalog(InMemoryTraceStore(), {"assistant": assistant}, version="1")

Make the .

paramconfigReActConfig[Any] | Callable[[Any, Any, str], ReActConfig[Any]]

The config of every , or a function of the , the parsed turn and the model name that returns the config of that turn.

paraminputtype[Any]
= Text

The pydantic class that each fresh input's parses into. Text, the default, takes a plain string.

paramelement_typesSequence[type[Element]]
= ()

The classes that the 's record beyond the core ones, such as the documents and passages that its show.

paramevent_typesSequence[type[Event]]
= ()

The classes that the 's record beyond the core ones.

Raises:

  • ValueError: config is a ReActConfig that keeps the default render_input or tool_states, and input has no text or tools field for that default to read.
methodbuild(resources, turn, model) -> Graph

Build the for turn, on the model that its input records.

paramresourcesR

The of the . Only a config function reads them.

paramturnT

The of the input that opened the , parsed into input.

parammodelstr | None

The model that the 's opening input names.

Returns

Graph

The of the : a model and a , with the of passes.

Raises:

  • InputDeniedError: The input records no model, the config function refuses the , or the names a that the never declared, asks another state for a locked one, or requires one that tools leaves out.
  • ValueError: The config that a function built keeps a default that reads a field input does not have, or its tools holds a twice or a that is not declared.
  • PromptFileError: The gives texts to a that is not in tools, or to an argument that the model does not write.

ReActConfig

dataclassReActConfig[T: BaseModel](*, model, prompt, limits=…, context=MessageBuilder(), citations=None, render_input=elements_then_text, declared=None, tools=(), tool_states=…, passes=10, tool_rounds_after_cap=1, resets_on_answer=False, repeats=False)

Every setting of a ReActAgent for one , except its .

Only model and prompt are required. A ReActAgent takes one config for every , or a function that builds the config of each .

The settings work together. declared lists the that the has, and tools are the that your code supplies for this . tool_states gives the state that the asks of each . A declared is offered when it is supplied and its state is not "off", in the order of declared. A that requires a gets the 's instruction after its message, in the words of the 's declaration.

passes caps the model calls of one that call . Past the cap, the do not run, and the default gives each of them a directive to finish as its result. The model keeps its for tool_rounds_after_cap more calls. Then it is called without , so it can only write its final output.

The that context adds, such as the , are not declared. The offers them, and the runs them each time that the model calls them.

parammodelChatModel

The that calls the model.

parampromptstr | PromptFile | Callable[[T, str | None], str]

The system prompt: a text, a PromptFile, or a function that writes the text. A gives the texts for the 's model. Its system template can read only citation, an example of citations, and its texts replace the texts of the supplied . A function gets the parsed turn and the example , such as [1] for BRACKETS. The example is None when citations is None. A must have a system template, or each fails at its first model call.

paramlimitsModelLimits
= …

What the model accepts. The default window of 32,000 tokens fits most , so a context that the model cannot take fails before it is sent.

paramcontextContextStrategy
= MessageBuilder()

The that builds what each model call receives. The default is a MessageBuilder with the default ContextPolicy, which old results to fit limits and keeps room for the model's output. It does not compact: give the policy a Compact for that. A call whose prompt leaves less room fails the .

paramcitationsCitationStrategy | None
= None

How the model is told to cite and how its are read back, such as BRACKETS. None means that the model does not cite.

paramrender_inputCallable[[T, ShowElements, Input], UserMessage | None]
= elements_then_text

How the model reads an input of the . It gets the parsed turn, the function that shows under their numbers, and the recorded Input, for what the does not hold, such as when the input was . It returns None to keep the input from the model. The default shows the 's , then its text. An earlier input that the no longer parses is shown as recorded: its , then its .

paramdeclaredSequence[ToolDeclaration] | None
= None

The that the has, or None to declare each of tools with the state "auto".

paramtoolsSequence[Tool[Any]]
= ()

The that your code supplies for this . Each of them must be declared.

paramtool_statesCallable[[T], Mapping[str, ToolState]]
= …

A function of the parsed turn that returns the state that the asks of each , by name. The default reads the 's tools field, as ChatTurnInput holds it. A that it does not name has the default of its declaration.

parampassesint
= 10

The number of model calls that call that one allows.

paramtool_rounds_after_capint
= 1

The number of model calls past passes that still get the . At least 0.

paramresets_on_answerbool
= False

If true, each response to a Request starts the count of passes again. If false, the count covers the whole .

paramrepeatsbool
= False

Whether a that is identical to an earlier successful call of the runs again, for each that does not set its own repeats.

Raises:

  • ValueError: tool_rounds_after_cap is negative, two declarations share a name, or a declared or supplied has the name of a that context adds.
  • PromptFileError: The system template of the , or a block that a model layer replaces, reads a variable other than citation.
attributedeclarationsSequence[ToolDeclaration]

The declarations of the 's .

These are declared, or a declaration of each of tools when declared is None.

Inputs

The of an says what a holds. These names show a to the model.

Text

classText

A plain-text input: the is the message.

It asks nothing of any and brings no context. It is the default of a ReActAgent.

attributetextstr

The message, which is the whole .

attributetoolsMapping[str, ToolState]

The that the input asks for: none.

attributecontextstr | None

The context for the system prompt: always None.

ChatTurnInput

modelChatTurnInput

A chat turn: the message, the state that it asks of each , and context for the 's system prompt.

Unknown fields are refused, so a misspelt field fails instead of being dropped.

attributetextstr

The message.

attributetoolsdict[str, ToolState]
= {}

The state that the asks of each , by the 's name. A that it does not name has the default of its ToolDeclaration.

attributecontextstr | None
= None

Text for the 's system prompt, which prompt_template writes in place of {context}, or None.

rendered_by

functionrendered_by(input_type, render=elements_then_text) -> RenderInput

Return a RenderInput that parses each input's into input_type and renders it with render.

Give it as the render_input of a MessageBuilder in a of your own. The is parsed strictly. A that input_type no longer parses is shown as recorded: its , then the , as text when it is a string and as JSON otherwise. So a change to input_type leaves older readable.

paraminput_typetype[BaseModel]
paramrenderRenderTurn
= elements_then_text

How the model reads the parsed turn. The default shows its , then its text.

Returns

RenderInput

The function for render_input.

elements_then_text

functionelements_then_text(turn, show, input=None) -> UserMessage

Return the that turn's fields hold, as show renders them, then its text after a blank line.

This is the default RenderTurn. A that holds no is its text alone.

paramturnAny

The parsed turn. It must have a text.

paramshowShowElements

The function that shows under their numbers.

paraminputInput | None
= None

The recorded input. It is not read.

Returns

UserMessage

The user message.

Raises:

  • AttributeError: turn has no text. Its needs a RenderTurn of its own.

RenderTurn

type aliasRenderTurn = Callable[[Any, ShowElements, Input], UserMessage | None]

How the model reads a parsed input: a function of the parsed turn, ShowElements and the recorded Input.

It returns the user message, or None to keep the input from the model on purpose. The recorded Input gives what the does not hold, such as when it was (ts).

RenderInput

type aliasRenderInput = Callable[[Input, ShowElements], UserMessage | None]

A function that renders an Input as the user message that the model reads.

It gets the input, and the function that shows the of the input. It returns None to keep the input from the model on purpose. rendered_by makes one.

Prompts

The system prompt is a text, a function of the , or a with a layer of overrides per group of models.

Prompt

type aliasPrompt = Callable[[Any, str | None], str]

A function that writes the system prompt of a .

It gets the parsed input of the , and an example of the of the model about to be called, or None when the model does not cite. prompt_template makes one.

prompt_template

functionprompt_template(template) -> Prompt

Return a prompt that writes template with the example and the 's context in it.

{citation} becomes the example of the model's . {context} becomes the 's context, as ChatTurnInput holds it, without the spaces around it. Each is empty when there is none. Both are filled in one pass, so text that the brings is never read as a placeholder. Other braces stay as they are, and the spaces around the result are removed.

paramtemplatestr

The system prompt, with {citation} and {context} where they go. A needs a context field only when the template holds {context}.

Returns

Prompt

A Prompt, for the prompt of a ReActConfig.

PromptFile

modelPromptFile

One 's : every text that its models read, with a layer of overrides per group of models.

Load the file with load and give it as the prompt of a ReActConfig, which uses the texts of the 's model. python -m soev_agents.toolkit.prompts FILE --model ENDPOINT prints what one model reads.

The system prompt is a Jinja template. A model layer replaces its {% block %}s, or extends them with {{ super() }}. A placeholder in a plain text is filled by the code that reads the text. A model layer replaces only keys that the base defines. names and argument names are checked when the texts are applied (Prompts.described), because only the knows its .

Raises:

  • pydantic.ValidationError: The file has another shape, a layer replaces a block or text that the base does not define, or two layers name one endpoint.
  • jinja2.TemplateSyntaxError: The system template is not valid Jinja.
attributesystemstr | None
= None

The system prompt as a Jinja template, or None when the file has none. The template is plain text, not HTML, so nothing is escaped. A variable that the render does not get fails the render.

attributetextsdict[str, str]
= {}

Plain texts, by key.

attributetoolsdict[str, ToolTexts]
= {}

Texts that replace a 's own description and argument descriptions, by name.

attributemodelstuple[ModelLayer, ...]
= ()

The model layers.

attributeblocksfrozenset[str]

The names of the system template's blocks.

attributeendpointsfrozenset[str]

Every endpoint a model layer names.

methodload(path) -> Self

Load the at path, a YAML document.

parampathPath

The path of the file, in UTF-8.

Returns

Self

The .

Raises:

  • pydantic.ValidationError: See the class.
  • jinja2.TemplateSyntaxError: The system template is not valid Jinja.
  • yaml.YAMLError: The file is not valid YAML.
methodcheck_variables(known) -> None

Refuse a system template or block override that reads a variable outside known.

So a renamed field fails when the is built, not mid-chat.

paramknownIterable[str]

The variables that the supplies. Jinja's super and self are always allowed.

Raises:

  • PromptFileError: A template reads an unknown variable.
methodfor_model(model) -> Prompts

Return the texts that model reads: the base, with the layer that names model over it.

A model that no layer names, or None, gets the base alone.

parammodelstr | None

The endpoint id of the model, or None for the base.

Returns

Prompts

The resolved texts.

Prompts

dataclassPrompts(template, blocks, texts, tools)

The texts of one for one model, which PromptFile.for_model resolves from the .

paramtemplatestr | None

The base system template, or None when the file has none.

paramblocksMapping[str, str]

The blocks of the template that the model's layer replaces, by block name. Empty for the base.

paramtextsMapping[str, str]

The plain texts, by key: the base's, with the layer's over them.

paramtoolsMapping[str, ToolTexts]

The texts, by name: the base's, with the layer's merged over them.

attributedigeststr

The name of this set of texts: the first 16 hex characters of a SHA-256 hash of the texts.

The same file and model give the same digest, and any change to a text that the model reads from the file gives another. A 's own default texts are code and not part of it.

attributesourcestr

The template that system renders.

It is the base template, or a template that extends the base with the block overrides.

methodsystem(**variables) -> str

Return the system prompt: the template rendered with variables.

paramvariablesAny

The value of each variable of the template, by name. A ReActAgent gives only citation.

Returns

str

The system prompt, with the blocks of the model's layer in it.

Raises:

  • PromptFileError: The has no system template.
  • jinja2.UndefinedError: The template reads a variable that is not given.
methodtext(key) -> str

Return the text under key.

paramkeystr

The key of the text in the .

Returns

str

The text, as the file writes it. The code that reads it fills its placeholders.

Raises:

  • PromptFileError: The defines no such text.
methoddescribed[T: Tool[Any]](tools) -> list[T]

Return tools, each with the texts that the gives it in place of its own.

paramtoolsSequence[T]

The of the .

Returns

list[T]

A new list in the same order. A that the file gives texts is a copy, and the other are the same objects.

Raises:

  • PromptFileError: The file gives texts to a not in tools, or to an argument that the model does not write, or to a that is not a dataclass.

ModelLayer

modelModelLayer

The overrides of a for a group of models, which endpoints names.

A layer replaces only blocks and texts that the base of the file defines. Unknown fields are refused.

attributeendpointstuple[str, ...]

The endpoint ids of the models that the layer applies to. At least one. Two layers of a file cannot name the same endpoint.

attributeblocksdict[str, str]
= {}

The blocks of the system template that the layer replaces, by block name. A block can extend the base block with {{ super() }}.

attributetextsdict[str, str]
= {}

The texts that the layer replaces, by key.

attributetoolsdict[str, ToolTexts]
= {}

The texts of the layer, by name. A description replaces the base's, and the argument texts are added over the base's.

ToolTexts

modelToolTexts

What the model reads of one in a : its description and its arguments' descriptions.

Each text replaces the 's own default. Unknown fields are refused.

attributedescriptionstr | None
= None

The 's description, or None to keep the 's own.

attributeargumentsdict[str, str]
= {}

The description of each argument, by argument name.

PromptFileError

errorPromptFileError

A that does not fit its , or a model layer that does not fit the file's base.

PromptFile raises it, inside a pydantic.ValidationError, for a model layer that replaces a block or a text that the base does not define, or that names an endpoint of another layer. PromptFile.check_variables raises it for a template that reads a variable that the does not supply, and ReActConfig calls that check. Prompts.described raises it for texts of a or an argument that the does not have, Prompts.text for a text that the file does not define, and Prompts.system for a file without a system template.

Citations

A tells the model how to cite, and reads its back.

BRACKETS

constantBRACKETS: Final = …

The that writes such as [4], and [4][5] for two sources.

It reads [4], [4, 5], [4;5], 【4】 and 【4†source】, so a model that writes another of these is still read.

FULLWIDTH

constantFULLWIDTH: Final = …

The that writes such as 【4】, and 【4】【5】 for two sources.

It reads the same as BRACKETS.

Tools

A declaration says how an offers a . A says what one asks of the .

ToolDeclaration

dataclassToolDeclaration(*, name, default='auto', locked=False, required_tool_instruction=…)

A that an has, by name, and the 's rule for offering it.

A declaration is not the : two can offer the same by different rules. On each , the code supplies a for each declared name or leaves it out.

paramnamestr

The name that the model calls the by.

paramdefaultToolState
= 'auto'

The 's state on a that names no state for it.

paramlockedbool
= False

If true, a cannot ask a state other than default. A that does is refused with InputDeniedError.

paramrequired_tool_instructionstr
= …

What the model is told on a that requires the . {tool} becomes the 's name. A ReActAgent adds it after the 's message. The default is "Use the {tool} tool for this message.".

Raises:

  • ValueError: required_tool_instruction uses a placeholder other than {tool}.
methodstate(requested) -> ToolState

Return this 's state on a that asks requested.

paramrequestedMapping[str, ToolState]

The states that the asks, by name.

Returns

ToolState

default when the declaration is locked or requested does not name the . Otherwise the state that requested names.

ToolState

type aliasToolState = Literal['off', 'auto', 'required']

What a asks of one : "off", "auto" or "required".

"off": not offered. "auto": offered for the model to use as it sees fit. "required": offered with an instruction to use it. The instruction is a request, not a guarantee: the model can still not call the .

Subagents

A runs one for each call of a .

ToolDelegation

dataclassToolDelegation[I: BaseModel](name, description, input, build, result=…, result_schema=None)

A that the parent's model calls as a : one for each call.

Each runs on build(its input, its model), the model that the names. Put the in a of the parent's , and offer its spec to the parent's model.

The model is shown input's fields as the 's arguments. An field is shown as the id of an of its class, which the turns into the parent's with the parent's . An input that is not an object, such as a RootModel[str], is shown under one input argument. A call whose arguments do not fit gets an error as its result and starts no .

paramnamestr

The name that the parent's model calls the by.

paramdescriptionstr

What the parent's model reads about the .

paraminputtype[I]

The of the . The 's arguments come from its fields.

parambuildCallable[[I, str | None], Graph]

The function that builds a 's from the parsed input and the model that the names, or None when it names none.

paramresultCallable[[Trace], JsonValue]
= …

The function that reads a 's result from its after it ended. The default is the content of the 's last when that is a ModelOutput, else None.

paramresult_schemadict[str, JsonValue] | None
= None

The JSON Schema that each result must fit, or None for any result. A result that does not fit gets the reason as the result's error.

Raises:

  • ValueError: An field sits inside another model, inside a collection other than a list, tuple or Sequence, or in a union with a type other than None. The cannot fill it.
attributespecToolDef

The definition of the that the parent's model is offered, with the schema of its arguments.

methodgraph_for(task) -> Graph

Build the of the that task starts.

paramtaskInput

The input that heads the 's . Its is parsed into input.

Returns

Graph

The that build returns for the parsed input and the model that task names.

methodhand_offs(parent) -> Sequence[Event]

Return one for each call of this in the parent's latest model output, in call order.

paramparentTrace

The parent stream's of the .

Returns

Sequence[Event]

A TaskInput for each call whose arguments fit input. A call whose arguments do not fit gets a ToolOutput with the reason in its error instead, and starts no .

methodhand_back(child) -> Sequence[Event]

Return the result of one as the result of the call that handed it off.

The result holds every Source that the was shown, and each shown that such a source is part of. With the default result, a final model output that cites comes back in the of a final reply to a user: text without and citations for the sources that resolved, so the parent shows in its own . Any other result is data. A result of None, or one that does not fit result_schema, gets an error.

paramchildTrace

The stream's of the , after the ended.

Returns

Sequence[Event]

One ToolOutput, linked to the call by its call_id.

TaskInput

modelTaskInput

The input that a ToolDelegation hands off: one of the parent's model, as a 's .

The is the call's arguments, parsed into the 's , with each id replaced by the parent's . The input records the of the . The reads call_id and expects to link and check the 's result, so it reads nothing outside the 's . A that names no model runs on the model of the parent's latest input.

attributetypestr
= 'task_input'

The stored type, "task_input".

attributeactorActor
= 'model'

"model": the parent's model asked for the .

attributecall_idstr

The id of the that the 's result is the result of.

attributeexpectsdict[str, JsonValue] | None
= None

The JSON Schema that the 's result must fit, or None for any result.

Context

The builds what each model call receives. MessageBuilder is the default, and its keeps the context within the model's limits.

ContextStrategy

protocolContextStrategy

The context management of a ReActAgent: what each model call of the receives.

The uses it in three places. for_turn makes the of one , from the parts that the computes for that turn. added_tools are the that the strategy offers itself, such as , which the 's runs. wrap gives the model the strategy's own , such as . MessageBuilder is the default strategy.

The three parts are one context management, because they depend on each other. A strategy that compacts must build contexts that show the summary of each Compaction in place of the that it replaced. A strategy that adds a must offer it, and show what it .

Whatever the strategy, the checks the rules of each call, the ends the past the , and the model reads and numbers with the of the built context.

attributeadded_toolsSequence[Tool[Any]]

The that the strategy offers itself, such as . The 's runs them.

methodfor_turn(*, render_input, model, prompt, tools, budget, citations, limits) -> ContextBuilder

Return the of one .

paramrender_inputRenderInput

How an Input renders as a user message, with the instructions that its ask for.

parammodelstr

The name of the model that the runs on.

parampromptCallable[[str | None], str] | None

The system prompt as a function of an example , or None for no system prompt. The is None when the model does not cite.

paramtoolstuple[ToolDef, ...]

The that the offers.

parambudgetBudget

The 's . Its withdraws_tools says when to offer no .

paramcitationsCitationStrategy | None

The of the model, or None when the does not cite.

paramlimitsModelLimits

The limits of the model.

Returns

ContextBuilder

The of the 's model .

methodwrap(step, limits) -> Step

Return the model with the strategy's own around it, such as .

paramstepLlmStep

The model of the .

paramlimitsModelLimits

The limits of the model that step calls.

Returns

Step

The wrapped , or step itself when the strategy wraps nothing.

MessageBuilder

dataclassMessageBuilder(policy=ContextPolicy(), *, show=xml(), select=None, renderers=dict(), render_input=None, model=None, prompt=None, tools=(), budget=None, citations=None, limits=None)

The for a : the messages and the that one model call gets.

The messages are the system prompt that prompt writes, then the that select picks from the . Each shows by show, under its number in the whole , so a selection never renumbers. An 's own types become messages by renderers.

The builder is also the default ContextStrategy of a ReActAgent. Its own settings come first: policy, show, select and renderers. The parts of one follow. A ReActAgent gives them with for_turn. A of your own gives them when it makes the builder. The policy's reopen is the that the builder adds, and the policy's compact wraps the model . So the , and stay in one place: the builder that reads the summaries that they write.

With limits, the policy decides the of each result, again at each call. Each result is made smaller by the function of its for that , and cut at the cap of its . A compressed result starts with a line that names its handle. A stubbed result is only that line and what keep, and its call stays. A shrunk result keeps what kept when it shrank, so a later never changes it. An input's always show as recorded. Without limits, each result is full and each text shows as recorded.

The policy's reopen is offered after tools, from the first call that shortens a result or follows a summary. After a Compaction, the that it replaced are left out, and its summary follows the prompt in the system message. On the call after the last trip of budget, no are offered, included, so the model writes its final output.

Example

from soev_agents.runtime import LlmStep, tool_def
from soev_agents.toolkit import ContextPolicy, MessageBuilder, ModelLimits, Text, Tokens, rendered_by

# model is a ChatModel, turn_model is the model name of the turn, PROMPT is the system prompt text,
# search is a tool that the `tool` decorator made, and graph is the Graph of the turn.
builder = MessageBuilder(
    ContextPolicy(result_cap=Tokens(4_000)),
    render_input=rendered_by(Text),
    model=model.resolve(turn_model),
    prompt=lambda citation: PROMPT,
    tools=(tool_def(search),),
    limits=ModelLimits(window=Tokens(128_000)),
)
graph.add_node("answer", LlmStep(builder=builder, model=model))
parampolicyContextPolicy
= ContextPolicy()

How the builder keeps the context within the limits of the model.

paramshowShow
= xml()

The of . The default is xml().

paramselectCallable[[Trace], Sequence[Event]] | None
= None

Which of the a call sees, or None for all of them. only makes the usual selection.

paramrenderersMapping[type[Event], RenderEvent]
= dict()

How each of the 's own types becomes messages, by class. A subclass uses the renderer of its nearest class. A subclass of a built-in type, such as an Input subclass, renders as its built-in type, and the builder does not use its renderer.

paramrender_inputRenderInput | None
= None

How an Input renders, or None before the 's parts are given.

parammodelstr | None
= None

The name of the model that each call goes to, or None before the 's parts are given.

parampromptCallable[[str | None], str] | None
= None

The system prompt as a function of an example of citations, or None for no system prompt. The is None when citations is None.

paramtoolstuple[ToolDef, ...]
= ()

The that each call offers.

parambudgetBudget | None
= None

The 's , or None to never withdraw the .

paramcitationsCitationStrategy | None
= None

The of the model, or None when the does not cite.

paramlimitsModelLimits | None
= None

The limits of the model, or None to nothing and check no size.

attributeadded_toolstuple[Tool[Any], ...]

The that the builder adds to the 's : the policy's reopen, if it has one.

methodfor_turn(*, render_input, model, prompt, tools, budget, citations, limits) -> MessageBuilder

Return a copy of this builder with the parts of one .

A ReActAgent calls it for each .

paramrender_inputRenderInput

How an Input renders as a user message.

parammodelstr

The name of the model that the runs on, as the 's input names it.

parampromptCallable[[str | None], str] | None

The system prompt as a function of an example , or None for no system prompt.

paramtoolstuple[ToolDef, ...]

The that each call offers.

parambudgetBudget

The 's . Its withdraws_tools says when to offer no .

paramcitationsCitationStrategy | None

The of the model, or None when the does not cite.

paramlimitsModelLimits

The limits of the model.

Returns

MessageBuilder

A new builder. This builder does not change.

methodwrap(step, limits) -> Step

Return step, with around it when the policy has a compact.

paramstepLlmStep

The model whose context this builder builds.

paramlimitsModelLimits

The limits of the model that step calls.

Returns

Step

step itself when the policy has no compact. Else a that first lets the model write a summary when the context is over the when of compact, or does not fit. Then the makes the call from the context that this builder builds after the summary. The raises CompactionError when the summary replaces nothing, and ContextFullError when the context does not fit and no summary makes room.

method__call__(trace) -> ModelContext

Build the context of the next model call from trace.

paramtraceTrace

The of the model .

Returns

ModelContext

The ChatRequest, the name of the model, the and the of the call.

Raises:

  • ContextFullError: With limits, the estimated prompt plus the policy's output_reserve does not fit in the model's window. A retry of the same call cannot help.
  • ValueError: The policy's target is not below its start_at in the model's window.
  • UnrenderedEventError: A selected has a type that is neither built in nor in renderers.
  • MissingTurnError: The builder has no render_input or no model.
  • ShortenError: A function of a removed, added or reordered an , or changed the error.
methodexplain(trace) -> tuple[Shrunk, ...]

Return why each shrunk result in trace has its , for the next model call.

paramtraceTrace

The of the model .

Returns

tuple[Shrunk, ...]

One Shrunk for each shrunk result, in the order of the results in the . Empty without limits.

Raises:

  • MissingTurnError: The builder has no render_input or no model.
  • ValueError: The policy's target is not below its start_at in the model's window.
  • UnrenderedEventError: A selected has a type that is neither built in nor in renderers.
  • ShortenError: A function of a removed, added or reordered an , or changed the error.

ContextPolicy

dataclassContextPolicy(*, start_at=Share(0.6), target=Share(0.4), min_gain=Share(0.1), shrink=…, compact=None, protect=…, full=as_recorded, compressed=drop_text, tools=dict(), result_cap=Tokens(8000), output_reserve=Tokens(8192), reasoning=NEVER, max_images=None, reopen=Reopen())

How a MessageBuilder keeps what a model is sent within what the model accepts.

Each default is the whole default: a field that you give replaces it, and nothing is added to it.

At each model call, the builder estimates the size of the context. When the size is over start_at, the builder applies the of shrink in order, until the size is under target. A with its own when runs over that size instead. The builder works the out again at each call, from the first model call of the , so nothing is stored. When the context is still over the threshold of compact after the , the model summarises earlier history. A call whose prompt leaves less than output_reserve in the window is refused before it is made: the builder raises ContextFullError.

Example

from soev_agents.toolkit import (
    Compact,
    Compress,
    ContextPolicy,
    Forms,
    MessageBuilder,
    ReActConfig,
    Stub,
    turns,
)

# model is a ChatModel, and PROMPT is the system prompt text.
policy = ContextPolicy(
    shrink=(Compress(turns[:-2]), Stub(turns[:-4])),
    compact=Compact(where=turns[:-2]),
    tools={"read_document": Forms(cap=None)},
)
config = ReActConfig(model=model, prompt=PROMPT, context=MessageBuilder(policy))
paramstart_atThreshold
= Share(0.6)

The size of the context above which the start.

paramtargetThreshold
= Share(0.4)

The size of the context that the bring it under. It must be below start_at.

parammin_gainThreshold | None
= Share(0.1)

The least that one pass of the must free, or None for any gain. A pass that frees less is not made, so that the prompt cache does not break for a few tokens.

paramshrinktuple[Shrink, ...]
= …

The , in the order to apply them. The default compresses the results of every but the last two, and stubs those of every but the last four. When the context is over Share(0.85), it also stubs those of the last three turns.

paramcompactCompact | None
= None

How the model summarises earlier history, or None to never summarise.

paramprotecttuple[Floor, ...]
= …

The . The of an is the of its result, lifted to the highest that applies to it. The default, Floor(cited, FULL), keeps each cited Source full.

paramfullShorten
= as_recorded

How each result looks in the full . The default, as_recorded, shows it as recorded.

paramcompressedShorten
= drop_text

How each result looks in the compressed . The default, drop_text, removes the text of each Source.

paramtoolsMapping[str, Forms]
= dict()

The Forms of a , by its name. They replace full, compressed and result_cap for that .

paramresult_capTokens | None
= Tokens(8000)

The most tokens of one result that the model reads, whatever its left, or None to never cut. A cut result says about how many tokens were left out.

paramoutput_reserveTokens
= Tokens(8192)

The tokens kept free in the window for the model's output. It is not sent as a limit, so the output can use more.

paramreasoningReasoning
= NEVER

Which reasoning of earlier model outputs is sent back to the model.

parammax_imagesint | None
= None

The most images that one ChatRequest sends, for that cap them, or None to send them all. The newest images are sent, of the user and of the results alike. Each older image becomes a note that it was left out.

paramreopenReopen | None
= Reopen()

The that shows the model again what was shortened or removed, or None for no such . The builder offers it from the first model call that shortens a result or follows a summary, until the 's are withdrawn. and required-tool instructions never apply to it.

Raises:

  • ValueError: target is not below start_at, or max_images is negative.
methodshorten_for(tool, form) -> Shorten

Return the function that makes a result of tool look as it does in form.

paramtoolstr

The name of the .

paramformForm

FULL or COMPRESSED. Any other gets the function of COMPRESSED.

Returns

Shorten

The function of the 's own Forms in tools, or else the policy's full or compressed.

methodcap_for(tool) -> Tokens | None

Return the most tokens of a result of tool that the model reads.

paramtoolstr

The name of the .

Returns

Tokens | None

The cap of the 's own Forms, or result_cap when the has none or its cap is "policy". None never cuts.

ShowElements

type aliasShowElements = Callable[[Sequence[Element]], str]

as the 's Show renders them, under their numbers in the .

A RenderInput and a RenderEvent get one, to show the of their . The Show gets None as the name of the .

RenderEvent

type aliasRenderEvent = Callable[[Any, ShowElements], Sequence[Message]]

A function that renders an 's own as the messages that the model reads.

It gets the , and the function that shows the of the under their numbers. Give it to a MessageBuilder in renderers, by the class of the .

only

functiononly(*types) -> Callable[[Trace], Sequence[Event]]

Return a selection of the of types, subclasses included, for MessageBuilder.select.

paramtypestype[Event]

The classes to select, such as only(Input, ModelOutput, ToolOutput).

Returns

Callable[[Trace], Sequence[Event]]

A function that returns the of a that are of those classes, in the order of the .

MissingTurnError

errorMissingTurnError

A MessageBuilder without the parts of its was asked to build a context.

The builder needs model and render_input. A ReActAgent gives them with for_turn. A of your own gives them when it makes the builder.

UnrenderedEventError

errorUnrenderedEventError

An that a MessageBuilder selected has a type that the builder has no renderer for.

The builder renders the built-in types itself, and an 's own types by its renderers. It raises this error for any other type when it builds a context, so that no is skipped silently.

ContextFullError

errorContextFullError

A context that does not fit in the model's window, so the model call is not made.

A MessageBuilder with limits raises it when it builds a context: the estimated prompt plus the output_reserve of its policy is more than the model's window. A retry of the same call cannot help.

When the context does not fit, the that MessageBuilder.wrap makes for a Compact first lets the model write a summary. That raises this error when the where of the Compact selects nothing that a summary did not replace yet, or when the context still does not fit after the summary.

Model limits

What one model accepts, in tokens or as a share of its window.

ModelLimits

dataclassModelLimits(window, characters_per_token=3.0)

What one model accepts: its window in tokens, and how many characters make one of its tokens.

The app gives these numbers for each model. The framework uses no tokenizer: it estimates the tokens of a prompt from its characters. After a call to the same model records the real token count of its prompt, only the characters added since then are estimated.

paramwindowTokens

The most tokens that one call can send and receive together.

paramcharacters_per_tokenfloat
= 3.0

The average number of characters in one token of the model. The default, 3.0, is low on purpose, so that the estimate counts more tokens than the prompt has.

Tokens

dataclassTokens(count)

A number of tokens, as its own type so that it is never taken for a share of a window.

Two numbers of tokens compare with < and >.

paramcountint

The number of tokens.

Share

dataclassShare(fraction)

A share of the window of the model that the next call goes to.

It is its own type, so that it is never taken for a number of tokens. Share(0.6) of a window of 100 000 tokens is 60 000 tokens.

paramfractionfloat

The share, above 0 and at most 1.

Raises:

  • ValueError: fraction is not above 0 and at most 1.

Threshold

type aliasThreshold = Share | Tokens

A size of a context: a Share of the model's window, or a number of Tokens.

A Share follows the window of the model that the call goes to. A number of Tokens is the same for each model.

Shrinks

When the context fills, lower old results to a smaller .

Shrink

protocolShrink

A function that offers results to , each with the that it goes to.

At each model call of the , the asks its while the context is too big. It applies the offers one at a time, in the order of the , and stops when the context is small enough. So a never decides when to stop. An offer that raises a , or that frees nothing, is skipped.

Compress and Stub are the built-in . A plain function with the signature of __call__ is a too.

A can also have this attribute, which the reads:

  • when: a Threshold, or None. A with a when starts when the context is over it, and stops when the context is no longer over it. A without one, or with None, starts when the context is over the policy's start_at, and goes on down to the policy's target.
method__call__(view, forms) -> Iterable[tuple[str, Form]]

Return the results to at the end of view, in the order to try them.

paramviewTrace

The before the model call that is judged.

paramformsMapping[str, Form]

The of each result so far, by ("r1", ...). A result that is not in it is full.

Returns

Iterable[tuple[str, Form]]

Pairs of a and the that the result goes to.

Compress

dataclassCompress(where, when=None)

A that compresses the results that where selects, oldest first.

It offers each selected result that is full. Without when, it starts when the context is over the policy's start_at, and goes on down to the policy's target. With when, it starts when the context is over when, and stops when the context is no longer over it.

paramwhereSelection

The results to compress.

paramwhenThreshold | None
= None

The size of the context above which it runs, or None to follow the policy's start_at and target.

method__call__(view, forms) -> list[tuple[str, Form]]

Return each full result that where selects in view, with the COMPRESSED.

paramviewTrace

The before the model call that is judged.

paramformsMapping[str, Form]

The of each result so far, by . A result that is not in it is full.

Returns

list[tuple[str, Form]]

Pairs of a and COMPRESSED, oldest result first.

Stub

dataclassStub(where, when=None)

A that replaces the output of the results that where selects by one line, oldest first.

The line names the . The that keep follow it, and the calls of the results stay. It offers each selected result that is full or compressed. Without when, it starts when the context is over the policy's start_at, and goes on down to the policy's target. With when, it starts when the context is over when, and stops when the context is no longer over it.

paramwhereSelection

The results to stub.

paramwhenThreshold | None
= None

The size of the context above which it runs, or None to follow the policy's start_at and target.

method__call__(view, forms) -> list[tuple[str, Form]]

Return each result that where selects in view and that is not stubbed, with the STUBBED.

paramviewTrace

The before the model call that is judged.

paramformsMapping[str, Form]

The of each result so far, by . A result that is not in it is full.

Returns

list[tuple[str, Form]]

Pairs of a and STUBBED, oldest result first.

Selection

dataclassSelection(unit, key)

Some results of a , selected by a Python index or slice of its , rounds or results.

Make one with turns, rounds or results: turns[:-2] selects the results of every but the last two. The count from the oldest, the current one last. An index out of range selects nothing.

paramunitUnit

The that key counts.

paramkeyint | slice

The index or slice.

methodhandles(view) -> list[str]

Return the handles of the selected results in view, oldest first.

paramviewTrace

The to select from.

Returns

list[str]

The , such as "r1", of each result in a selected .

methodpicked(count) -> list[int]

Return which of count this selects.

paramcountint

The number of .

Returns

list[int]

The of the selected , counted from 0, in the order of the slice. Empty when an index is out of range.

turns

constantturns = …

The of a , the current one last. Index or slice it for a Selection.

turns[:-2] selects the results of every but the last two.

rounds

constantrounds = …

The of a , the current one last. Index or slice it for a Selection.

rounds[:-3] selects the results of every but the last three.

results

constantresults = …

The results of a , in recorded order. Index or slice it for a Selection.

results[:-3] selects every result but the newest three.

Unit

type aliasUnit = Literal['turns', 'rounds', 'results']

What context management counts the age of results in: turns, rounds or results.

A starts at a fresh input. A starts at a model output that calls . A result is one result. turns, rounds and results select by each .

Shrunk

dataclassShrunk(result, form, by, at)

Why a result has its : the that gave the , and the model call at which it did.

MessageBuilder.explain returns these.

paramresultstr

The , such as "r1".

paramformForm

The that the gave the result.

parambyShrink

The that gave the .

paramatint

The number of before the model call at which the gave the .

Floors

A keeps some in a higher than their result.

Floor

dataclassFloor(applies, form)

The lowest that some can reach, whatever their result has.

The of an is the of its result, lifted to the highest that applies to it. A only shows more of a result: it never changes the of the result. The default of a ContextPolicy is Floor(cited, FULL): a Source that the model cited before its result shrank keeps its text.

paramappliesProtects

The predicate that says to which the applies.

paramformForm

The lowest of those .

Protects

protocolProtects

A predicate that says whether a applies to an .

It reads only the before the model call at which the result of the shrank. So what happens later never changes a message that the model was sent already. cited is the built-in predicate.

method__call__(element, tool, before) -> bool

Return whether the applies to element.

paramelementElement

An of a result.

paramtoolstr | None

The name of the that recorded the , or None if no recorded it.

parambeforeTrace

The before the model call at which the result shrank.

Returns

bool

True if the applies to the .

cited

constantcited = …

Whether an earlier model output cited an : the predicate of the default , Floor(cited, FULL).

A calls it with the , the name of the that recorded the , and the before the call where the 's result shrank. It is true when a of a model output in those cites the 's id. So a passage that the model relied on keeps its text after its result .

Forms

How the results of a look in each .

Form

enumForm

How much of a result the model is shown.

are ordered: STUBBED is below COMPRESSED, and COMPRESSED is below FULL. A only lowers the of a result, and a only lifts the of an . are not recorded: each model call works them out again.

attributeSTUBBED
= 0

The output is one line that names its , and the that keep. The call stays.

attributeCOMPRESSED
= 1

The output as the compressed function of its makes it, under a line that names its handle.

attributeFULL
= 2

The output as the full function of its makes it. By default, as the recorded it.

FULL

constantFULL = Form.FULL

The of a result that the model reads whole, Form.FULL.

COMPRESSED

constantCOMPRESSED = Form.COMPRESSED

The of a result with less text, under a line that names its handle, Form.COMPRESSED.

STUBBED

constantSTUBBED = Form.STUBBED

The of a result that is one line with its handle, Form.STUBBED.

Forms

dataclassForms(full=None, compressed=None, cap='policy')

How the results of one look in each .

Give it to a ContextPolicy in tools, by the name of the . A field that is None uses the policy's own function. A stubbed result is always its handle line and the that keep, so it has no function.

paramfullShorten | None
= None

The function for the full , or None to use the policy's full.

paramcompressedShorten | None
= None

The function for the compressed , or None to use the policy's compressed.

paramcapTokens | None | Literal['policy']
= 'policy'

The most tokens of a result of this that the model reads, whatever its left. None never cuts a result. "policy" uses the policy's result_cap.

Shorten

type aliasShorten = Callable[[ToolOutput, ModelLimits], ToolOutput]

A function that makes a result look as it does in one , for the model that reads it.

It gets the result as recorded, and the limits of the model that the call goes to. It can change text, data and the text of each . It must keep every , in order, and error, because and find by id, and the model reacts to the error. A MessageBuilder raises ShortenError for a function that breaks this rule.

Give one to a ContextPolicy as full or compressed, or to one in a Forms. as_recorded, drop_text, sources and json_cap make the usual ones.

ShortenText

type aliasShortenText = Callable[[str, ModelLimits], str]

A function that shortens one text for the model that reads it.

It gets the text and the limits of the model that the call goes to. sources applies one to the text of each Source of a result. cap and first_words make the usual ones.

as_recorded

functionas_recorded(output, limits) -> ToolOutput

Return the result as the recorded it: the default full .

paramoutputToolOutput

The result.

paramlimitsModelLimits

The limits of the model that reads the result. Not used.

Returns

ToolOutput

output itself.

drop_text

functiondrop_text(output, limits) -> ToolOutput

Return the result with the text of each Source removed: the default compressed .

With the xml , each source then shows as a without content. The result's own text and data stay.

paramoutputToolOutput

The result.

paramlimitsModelLimits

The limits of the model that reads the result. Not used.

Returns

ToolOutput

A copy of output. output does not change.

sources

functionsources(shorten) -> Shorten

Return a Shorten that applies shorten to the text of each Source of a result.

Other , and the result's own text and data, stay as they are. sources(cap(Tokens(500))) cuts the text of each source at 500 tokens.

paramshortenShortenText

The function for the text of one source.

Returns

Shorten

The function for the whole result.

cap

functioncap(limit, cut=…) -> ShortenText

Return a ShortenText that cuts a text at limit tokens, before the word that the limit falls in.

A cut text ends with cut, so the model can tell a cut text from a short one. A text that fits stays as it is.

paramlimitTokens

The most tokens of the text, in tokens of the model that reads it.

paramcutstr
= …

What follows the cut text. Its {tokens} becomes about how many tokens were left out. The default is "[… about {tokens} more tokens not shown]".

Returns

ShortenText

The function for one text.

first_words

functionfirst_words(count) -> ShortenText

Return a ShortenText that keeps the first count words of a text.

A text with more words becomes its first count words, with one space between them, followed by …. A shorter text stays as it is.

paramcountint

The number of words to keep.

Returns

ShortenText

The function for one text.

json_cap

functionjson_cap(limit, cut=…) -> Shorten

Return a Shorten that writes the data of a result as JSON and cuts it at limit tokens.

When the JSON is longer than limit, the result gets no data, and the cut JSON follows its text on a new line. Shorter data stays as it is, and so does a result without data.

paramlimitTokens

The most tokens of the JSON, in tokens of the model that reads it.

paramcutstr
= …

What follows the cut JSON. Its {tokens} becomes about how many tokens were left out. The default is "[… about {tokens} more tokens not shown]".

Returns

Shorten

The function for the whole result.

ShortenError

errorShortenError

A function of a removed, added or reordered an of a result, or changed its error.

and find by id, and the error is a fact that the model reacts to. A MessageBuilder raises it when it builds the context of a model call.

Compaction

When are not enough, the model writes a summary that replaces the earlier conversation.

Compact

dataclassCompact(where=turns[:-2], when=Share(0.8), instructions=…, citing=…)

How the model summarises earlier history when the context is still too big after every .

When the context of a model call is over when after every , or does not fit at all (the raises ContextFullError), the model first writes a summary of the that where selects. Then the call is made from the summary. The Compaction and the model's output are recorded together. From then on, the MessageBuilder shows the summary in the system message, in place of the that it replaced. numbers and stay those of the whole .

The running is always kept. The summary never splits a from its results: a cut that would split them moves to before the call. The summary call offers no and is not streamed. When a summary replaced every that where selects already, nothing is compacted, and a call that does not fit raises ContextFullError.

Give it to a ContextPolicy as compact.

paramwhereSelection
= turns[:-2]

The to replace. Only the selected that one from the oldest are replaced, so turns[1:] replaces nothing. turns[-3:] replaces nothing in a of more than three turns. The default, turns[:-2], replaces every except the last two.

paramwhenThreshold
= Share(0.8)

The size of the context above which the model summarises. The default is Share(0.8) of the window.

paraminstructionsstr
= …

The text that asks the model for the summary. It follows the earlier messages as a user message.

paramcitingstr
= …

The text that follows instructions when the model cites. Its {citation} becomes an example of the model's .

methodkept_from(events) -> int

Return the in events of the first that the summary keeps.

It is the start of the first that where does not select, at most the start of the running . It moves back to before a whose results it would split from the call.

parameventsSequence[Event]

The of the .

Returns

int

The , or 0 when events hold no .

CompactionError

errorCompactionError

A summary that replaces nothing.

The model that MessageBuilder.wrap makes for a Compact raises it in two cases. The model wrote an empty summary. Or the built the same ChatRequest after the summary as before it, because the builder does not show Compaction .

Reopen

The shows the model again what the shortened or removed.

Reopen

dataclassReopen(name='reopen', description=…, arguments=ReopenArguments)

The that shows the model again what a shortened or removed.

The records only which and whole results to show again. The MessageBuilder draws them from where they were first recorded, as the result of the call. Each shows inside its whole, in the of the that recorded it. Each whole result shows under its handle, cut at the cap of its . Nothing earlier in the conversation changes.

A ContextPolicy holds the as reopen. The builder offers it from the first model call that shortens a result or follows a summary, until the 's are withdrawn.

paramnamestr
= 'reopen'

The name that the model calls the by.

paramdescriptionstr
= …

What the model reads about the .

paramargumentstype[ReopenArguments]
= ReopenArguments

The class of the arguments that the model writes.

methodrunasync (arguments) -> Reopened

Record which and results to show again.

paramargumentsReopenArguments

The parsed arguments, with real ids and call ids.

Returns

Reopened

The Reopened result that names them. It holds no copy of their content.

ReopenArguments

modelReopenArguments

The arguments that the model writes to the : by number, whole results by handle.

LlmStep replaces each number with the real id of its , and each handle with the call id of its result, when it records the call.

Raises:

  • pydantic.ValidationError: The arguments name no and no result, or hold a field of another name.
attributeelementslist[Annotated[str, ElementId(Element)]]
= []

The numbers of the to show again, such as passages that show as without text.

attributeresultslist[Annotated[str, ResultHandle()]]
= []

The handles of the results to show again whole, such as "r12".

Reasoning

Which earlier reasoning of the model is sent back to it.

Reasoning

enumReasoning

Which reasoning of earlier model outputs the MessageBuilder sends back to the model.

Reasoning that is sent back counts toward the context like any text. CURRENT_TURN lets a model continue its reasoning between . When a new starts, the reasoning of the earlier is dropped, so the prompt cache misses once in each .

attributeNEVER
= 'never'

Send no reasoning back. The default of ContextPolicy.

attributeCURRENT_TURN
= 'current_turn'

Send back the reasoning of the model outputs of the running turn.

attributeALWAYS
= 'always'

Send back the reasoning of every model output.

NEVER

constantNEVER = Reasoning.NEVER

Send no reasoning of earlier model outputs back to the model, Reasoning.NEVER.

CURRENT_TURN

constantCURRENT_TURN = Reasoning.CURRENT_TURN

Send back the reasoning of the model outputs of the running turn, Reasoning.CURRENT_TURN.

ALWAYS

constantALWAYS = Reasoning.ALWAYS

Send back the reasoning of every earlier model output, Reasoning.ALWAYS.

Layout

The shows the of one as text.

Show

type aliasShow = Callable[[Sequence[Element], Numbering, str | None, CitationStrategy | None], str]

The text of one 's : a .

It gets four arguments: the , the 's , the name of the that ran, and the of the model. The name is None for the of an input. The strategy is None when the does not cite.

A shows the numbers of the , never real ids. xml makes the default . Give one to a MessageBuilder as show.

xml

functionxml(fields=None, tags=None, order=None, cite='cite') -> Show

Return the that shows each as an XML named by its type, with its number as id.

A Source, the only that can be cited, also carries the exact the model cites it with, written by its , in the attribute cite names, e.g. <passage id="7" cite="[7]">. So the model copies what to cite instead of choosing among the numbers it sees.

Every field a subclass adds and every properties key is an attribute, unless fields names the class. A Source's text is the 's content. An nests inside the its ref names when both are in the same call, in arrival order. Otherwise its names the ref as an attribute, called by the of the recorded under that number, or ref when none was.

id, the cite attribute and the attribute naming the whole are the 's own: an attribute of the same name is shown with data- before it. Text is escaped, so it never reads as a .

paramfieldsMapping[type[Element], Mapping[str, str]] | None
= None

The attributes of each class that it names: the paths it lists, each under the attribute name it maps to, e.g. {Document: {"properties.modified": "date"}}. It applies to subclasses of the class named. None shows every field and property of each class.

paramtagsMapping[type[Element], str] | None
= None

The of each class that it names, in place of its type. It applies to subclasses of the class named.

paramorderMapping[type[Element], str] | None
= None

The path per class that sorts the parts nested in one whole, e.g. {Passage: "properties.chunk_index"} for reading order. Parts without a value follow in arrival order, and not nested keep arrival order, so the record can keep a search's ranking while the model reads in document order.

paramcitestr | None
= 'cite'

The name of the attribute that holds the of a Source, or None for no such attribute.

Returns

Show

The , for the show of a MessageBuilder.

Raises:

  • ValueError: a path in fields or order does not start with a field of its class.

On this page