glean/error

Types

pub type FinishReason {
  Stop
  Length
  ContentFilter
  ToolCalls
  FinishError
  Other(String)
}

Constructors

  • Stop

    The model finished its answer.

  • Length

    The answer was cut off at the output token limit.

  • ContentFilter

    A safety filter stopped the answer, or the model refused.

  • ToolCalls

    The model asked for tools.

  • FinishError

    The provider said the generation failed part way: OpenRouter’s error finish reason, Gemini’s MALFORMED_FUNCTION_CALL.

  • Other(String)
pub type GleanError {
  ProviderError(
    provider: String,
    model: String,
    status: Int,
    message: String,
  )
  ToolNotFound(tool_name: String)
  ToolExecutionError(
    tool_name: String,
    tool_call_id: String,
    reason: String,
  )
  ToolInputValidationError(
    tool_name: String,
    tool_call_id: String,
    errors: List(ValidationError),
  )
  OutputValidationError(
    errors: List(ValidationError),
    text: String,
    finish_reason: FinishReason,
    messages: List(message.Message),
    usage: usage.Usage,
  )
  MaxStepsExceeded(
    max_steps: Int,
    steps_taken: Int,
    messages: List(message.Message),
    usage: usage.Usage,
  )
  JsonParseError(input: String, message: String)
  Timeout(after_ms: Int)
  ConfigError(message: String)
}

Constructors

  • ProviderError(
      provider: String,
      model: String,
      status: Int,
      message: String,
    )

    Provider returned a non-200 status or network failure

  • ToolNotFound(tool_name: String)

    Tool call referenced a tool name not in the toolset

  • ToolExecutionError(
      tool_name: String,
      tool_call_id: String,
      reason: String,
    )

    Tool execution returned an error

  • ToolInputValidationError(
      tool_name: String,
      tool_call_id: String,
      errors: List(ValidationError),
    )

    Tool input failed schema validation

  • OutputValidationError(
      errors: List(ValidationError),
      text: String,
      finish_reason: FinishReason,
      messages: List(message.Message),
      usage: usage.Usage,
    )

    The final answer is not the JSON the agent’s schema asks for, and the retries allowed by agent.output_retries are used up.

    text is the answer that failed, messages the conversation up to and including it, and usage what the run cost. When finish_reason is Length the answer was cut off at the output token limit, so it is not retried: raise max_output_tokens instead.

  • MaxStepsExceeded(
      max_steps: Int,
      steps_taken: Int,
      messages: List(message.Message),
      usage: usage.Usage,
    )

    Max steps exceeded in the agent loop The conversation so far, including every tool call and result, so it can be inspected or resumed with run.generate_messages, and the tokens the steps used.

  • JsonParseError(input: String, message: String)

    JSON parsing failed

  • Timeout(after_ms: Int)

    Request timed out

  • ConfigError(message: String)

    Configuration error at agent build time

pub type ValidationError {
  ValidationError(path: List(String), message: String)
}

Constructors

  • ValidationError(path: List(String), message: String)

Values

pub fn to_string(error: GleanError) -> String

Convert a GleanError to a human-readable string.

pub fn validation_errors_to_string(
  errors: List(ValidationError),
) -> String

Every violation, as its path and what is wrong there, joined with ; .

✨ Search Document