Imp.Predict.ReActV2.StepError exception (Imp v0.7.0)

Copy Markdown View Source

An Imp.Predict.ReActV2 turn that stopped because it could not get a model response.

Imp.Predict.ReActV2 returns {:error, %StepError{}} when a request of the turn failed and no further request could answer it: the last request of an interrupted turn failed, or a step failed with an Imp.OperationalSafetyError, which ends the turn at once. Two fields carry what a caller acts on:

  • :reason — the failed request's error, unchanged, as Imp.Predict returns it: an Imp.LMError, {:lm_failed, client, exception} for a client that raised, {:adapter_format_failed, adapter, exception} for a renderer that raised, or an Imp.OperationalSafetyError. Imp.Errors.retryable?/1 and Imp.Errors.context_window_exceeded?/1 read it through this struct, and Imp.OperationalSafetyError guards find a safety error inside it.
  • :history — the turn's Imp.History as far as it got: the history a finished turn returns in its prediction's :history metadata, with every step that ran, its tool calls and their results, and the provider's reasoning continuation. The tools those steps called have run, so a host that keeps a conversation stores it as it stores a finished turn's.

Imp.Errors.retryable?/1 on this error answers whether the last model request may be sent again, not whether the turn may: the tools in :history have already run, and running the turn again from its inputs runs them again. A host that continues continues from :history.

No partial prediction exists: a turn that stopped here has no outputs.

Inspecting the error shows the reason and how many messages the history holds, not the history: a host that logs or records an inspected error does not write the trajectory, with its provider reasoning continuation, there.

Summary

Types

t()

@type t() :: %Imp.Predict.ReActV2.StepError{
  __exception__: true,
  history: Imp.History.t(),
  message: String.t(),
  reason: term()
}