Nous.CodeRuntime.Failure (nous v0.17.1)

Copy Markdown View Source

Why a program did not produce a value.

A failure is data, never an exception. A program that throws, loops forever, floods stdout, or dies with its substrate is a normal outcome of running model-authored code: the model gets told what happened and writes a better program. Raising would make the tool call an error and lose that loop.

The kinds are distinct because the model — and the operator reading a log — can act differently on each:

  • :exception — the program raised. Its own bug; the message is the guest's.
  • :timeout — the wall-clock budget expired. Possibly an infinite loop, possibly just slow; the program ran and may have had side effects.
  • :abort — cancelled from outside (Nous.CodeRuntime.cancel/2), e.g. the agent run was cancelled. Not the program's fault.
  • :substrate_exit — the runtime died underneath us. Ours to fix, not the model's, and the one kind that should page somebody.
  • :invalid_output — the program returned something unrepresentable.
  • :output_limit — it produced more output than the ledger allows. The retained prefix is still in Result.logs, because truncated evidence beats none.

Summary

Functions

Every failure kind.

Build a failure. Unknown kinds are rejected at construction, where the bug is, rather than surfacing as an unmatched clause somewhere downstream.

Types

kind()

@type kind() ::
  :exception
  | :timeout
  | :abort
  | :substrate_exit
  | :invalid_output
  | :output_limit

t()

@type t() :: %Nous.CodeRuntime.Failure{kind: kind(), message: String.t()}

Functions

kinds()

@spec kinds() :: [kind()]

Every failure kind.

new(kind, message)

@spec new(kind(), String.t()) :: t()

Build a failure. Unknown kinds are rejected at construction, where the bug is, rather than surfacing as an unmatched clause somewhere downstream.