fabric/input
Validated original input for one agent run. Imported history is context, never a source of actions or approvals. Provider replay strings remain opaque and are retained exactly as supplied.
Original input ends in one of two ways. new appends a current user
prompt to the history: the model answers that prompt. continuation
takes a history that already ends with the results of its last
assistant turn, such as a handed-over run’s history with the decision
as the call’s result (fabric.handover_history): the model continues
from those results, as it would have in the run that made the calls,
and no user message is invented. A continuation needs a store that
writes agent records of version 10 or later.
Types
pub type InputError {
HistoryMustStartWithUser
InvalidCallId
DuplicateCallId(id: String)
UnexpectedToolResult(id: String)
UnresolvedCalls(ids: List(String))
NotEndingInToolResults
}
Constructors
-
HistoryMustStartWithUser -
InvalidCallId -
DuplicateCallId(id: String) -
UnexpectedToolResult(id: String) -
UnresolvedCalls(ids: List(String)) -
NotEndingInToolResultsA continuation’s history does not end with a tool result: its last message is a user prompt or an assistant turn, or it is empty. Use
newto give the model a prompt instead.
Values
pub fn continuation(
history: List(model.Message),
) -> Result(Input, InputError)
Validate a history that ends with the results of its last assistant
turn and take it as the complete original input, with no prompt
appended: the run’s first model turn continues from those results.
The history must start with a user message, every call of every
assistant turn must have exactly one result, and the last message must
be a tool result (NotEndingInToolResults otherwise); a missing result
of the last turn is UnresolvedCalls.
Prefer it for a run that carries on a conversation whose calls are now
answered, such as a follow-on run after a handover. Use new instead
when the application has something new to say to the model: a
customer’s next message, or an instruction the original run never had.
pub fn messages(input: Input) -> List(model.Message)
The complete original input, including its current prompt.
pub fn new(
history: List(model.Message),
prompt: String,
) -> Result(Input, InputError)
Validate completed historical tool exchanges, then append the current prompt exactly once. Adjacent user messages and repeated call ids in different assistant turns are valid. Tool results may arrive in any order; their supplied order is preserved. Provider-specific replay validity is checked by the model adapter, not by this generic boundary.