Class: Brute::Middleware::OTel::ToolResults
- Defined in:
- lib/brute/middleware/otel/tool_results.rb
Overview
Records tool results being sent back to the LLM as span events.
Runs PRE-call: when env is present, the orchestrator is sending tool execution results back to the LLM. Each result gets a span event with the tool name and success/error status.
Instance Method Summary collapse
Methods inherited from Base
Constructor Details
This class inherits a constructor from Brute::Middleware::Base
Instance Method Details
#call(env) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/brute/middleware/otel/tool_results.rb', line 18 def call(env) span = env[:span] if span && (results = env[:tool_results]) span.set_attribute("brute.tool_results.count", results.size) results.each do |name, value| error = value.is_a?(Hash) && value[:error] attrs = { "tool.name" => name.to_s } if error attrs["tool.status"] = "error" attrs["tool.error"] = value[:error].to_s else attrs["tool.status"] = "ok" end span.add_event("tool_result", attributes: attrs) end end @app.call(env) end |