Module: LLM::Tracer::Rescue
- Includes:
- Rescue
- Defined in:
- lib/llm/tracer/rescue.rb
Overview
The Rescue module prepends itself to every subclass of LLM::Tracer and ensures that a tracer callback never crashes an agent.
When an error occurs, it is dumped to standard error and does not travel up the stack. But LLM::Interrupt, and any other exception not covered by the 'ERRORS' constant can crash the tracer. So it handles most cases but not all, and LLM::Interrupt travelling up the stack is intentional.
Instance Method Summary collapse
- #on_interrupt ⇒ Object
- #on_request_start ⇒ Object
- #on_request_finish ⇒ Object
- #on_request_error ⇒ Object
- #on_tool_start ⇒ Object
- #on_tool_interrupt ⇒ Object
- #on_tool_finish ⇒ Object
- #on_tool_error ⇒ Object
- #on_exit ⇒ Object
Methods included from Rescue
Instance Method Details
#on_interrupt ⇒ Object
84 85 86 87 88 89 90 |
# File 'lib/llm/tracer/rescue.rb', line 84 def on_interrupt(...) super rescue LLM::Interrupt raise rescue *ERRORS => ex crash(ex:) end |
#on_request_start ⇒ Object
28 29 30 31 32 33 34 |
# File 'lib/llm/tracer/rescue.rb', line 28 def on_request_start(...) super rescue LLM::Interrupt raise rescue *ERRORS => ex crash(ex:) end |
#on_request_finish ⇒ Object
36 37 38 39 40 41 42 |
# File 'lib/llm/tracer/rescue.rb', line 36 def on_request_finish(...) super rescue LLM::Interrupt raise rescue *ERRORS => ex crash(ex:) end |
#on_request_error ⇒ Object
44 45 46 47 48 49 50 |
# File 'lib/llm/tracer/rescue.rb', line 44 def on_request_error(...) super rescue LLM::Interrupt raise rescue *ERRORS => ex crash(ex:) end |
#on_tool_start ⇒ Object
52 53 54 55 56 57 58 |
# File 'lib/llm/tracer/rescue.rb', line 52 def on_tool_start(...) super rescue LLM::Interrupt raise rescue *ERRORS => ex crash(ex:) end |
#on_tool_interrupt ⇒ Object
60 61 62 63 64 65 66 |
# File 'lib/llm/tracer/rescue.rb', line 60 def on_tool_interrupt(...) super rescue LLM::Interrupt raise rescue *ERRORS => ex crash(ex:) end |
#on_tool_finish ⇒ Object
68 69 70 71 72 73 74 |
# File 'lib/llm/tracer/rescue.rb', line 68 def on_tool_finish(...) super rescue LLM::Interrupt raise rescue *ERRORS => ex crash(ex:) end |