Class: Smith::Workflow::RunResult

Inherits:
Struct
  • Object
show all
Defined in:
lib/smith/workflow.rb

Overview

‘keyword_init: true` is mandatory: `build_run_result` constructs the result via keyword arguments. Plain Ruby Structs treat the kwargs hash as the first positional field, silently leaving the remaining fields nil — verified empirically. The `keyword_init` flag routes kwargs to the right fields. `usage_entries` is the 10th field, added in this slice for hadithi billing.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#contextObject

Returns the value of attribute context

Returns:

  • (Object)

    the current value of context



30
31
32
# File 'lib/smith/workflow.rb', line 30

def context
  @context
end

#outcomeObject

Returns the value of attribute outcome

Returns:

  • (Object)

    the current value of outcome



30
31
32
# File 'lib/smith/workflow.rb', line 30

def outcome
  @outcome
end

#outputObject

Returns the value of attribute output

Returns:

  • (Object)

    the current value of output



30
31
32
# File 'lib/smith/workflow.rb', line 30

def output
  @output
end

#session_messagesObject

Returns the value of attribute session_messages

Returns:

  • (Object)

    the current value of session_messages



30
31
32
# File 'lib/smith/workflow.rb', line 30

def session_messages
  @session_messages
end

#stateObject

Returns the value of attribute state

Returns:

  • (Object)

    the current value of state



30
31
32
# File 'lib/smith/workflow.rb', line 30

def state
  @state
end

#stepsObject

Returns the value of attribute steps

Returns:

  • (Object)

    the current value of steps



30
31
32
# File 'lib/smith/workflow.rb', line 30

def steps
  @steps
end

#tool_resultsObject

Returns the value of attribute tool_results

Returns:

  • (Object)

    the current value of tool_results



30
31
32
# File 'lib/smith/workflow.rb', line 30

def tool_results
  @tool_results
end

#total_costObject

Returns the value of attribute total_cost

Returns:

  • (Object)

    the current value of total_cost



30
31
32
# File 'lib/smith/workflow.rb', line 30

def total_cost
  @total_cost
end

#total_tokensObject

Returns the value of attribute total_tokens

Returns:

  • (Object)

    the current value of total_tokens



30
31
32
# File 'lib/smith/workflow.rb', line 30

def total_tokens
  @total_tokens
end

#usage_entriesObject

Returns the value of attribute usage_entries

Returns:

  • (Object)

    the current value of usage_entries



30
31
32
# File 'lib/smith/workflow.rb', line 30

def usage_entries
  @usage_entries
end

Instance Method Details

#done?Boolean

Returns:

  • (Boolean)


32
33
34
# File 'lib/smith/workflow.rb', line 32

def done?
  state == :done
end

#failed?Boolean

Returns:

  • (Boolean)


36
37
38
# File 'lib/smith/workflow.rb', line 36

def failed?
  state == :failed
end

#failed_transitionObject



56
57
58
# File 'lib/smith/workflow.rb', line 56

def failed_transition
  failure_detail&.fetch(:transition)
end

#failure_detailObject



60
61
62
63
64
65
66
67
68
69
70
# File 'lib/smith/workflow.rb', line 60

def failure_detail
  failed_step = steps.reverse.find { |step| step[:error] }
  return nil unless failed_step

  {
    transition: failed_step[:transition],
    from: failed_step[:from],
    to: failed_step[:to],
    error: failed_step[:error]
  }
end

#last_errorObject



52
53
54
# File 'lib/smith/workflow.rb', line 52

def last_error
  steps.reverse.map { |step| step[:error] }.compact.first
end

#outcome_kindObject



44
45
46
# File 'lib/smith/workflow.rb', line 44

def outcome_kind
  outcome&.dig(:kind)
end

#outcome_payloadObject



48
49
50
# File 'lib/smith/workflow.rb', line 48

def outcome_payload
  outcome&.dig(:payload)
end

#terminal_outputObject



40
41
42
# File 'lib/smith/workflow.rb', line 40

def terminal_output
  output
end