Class: Parse::Agent::MCPClient::Result
- Inherits:
-
Struct
- Object
- Struct
- Parse::Agent::MCPClient::Result
- Defined in:
- lib/parse/agent/mcp_client.rb
Overview
Result of an ‘ask` / `reply` call.
-
‘text` is the LLM’s final-turn answer.
-
‘tool_calls` is the ordered list of tools invoked, each with its arguments and the dispatcher’s response.
-
‘transcript` is the full message log (useful for debugging).
-
‘usage` is a Usage struct for this single call (sum across all LLM turns the round-trip required).
-
‘reply(question)` continues the conversation that produced this result. Chain freely: `mcp.ask(“a”).reply(“b”).reply(“c”)`.
Instance Attribute Summary collapse
-
#client ⇒ Object
Returns the value of attribute client.
-
#text ⇒ Object
Returns the value of attribute text.
-
#tool_calls ⇒ Object
Returns the value of attribute tool_calls.
-
#transcript ⇒ Object
Returns the value of attribute transcript.
-
#usage ⇒ Object
Returns the value of attribute usage.
Instance Method Summary collapse
-
#reply(question) ⇒ Result
Continue this conversation.
-
#to_s ⇒ Object
(also: #inspect)
Pretty-print for IRB: tool trace, answer, then per-call usage line.
Instance Attribute Details
#client ⇒ Object
Returns the value of attribute client
57 58 59 |
# File 'lib/parse/agent/mcp_client.rb', line 57 def client @client end |
#text ⇒ Object
Returns the value of attribute text
57 58 59 |
# File 'lib/parse/agent/mcp_client.rb', line 57 def text @text end |
#tool_calls ⇒ Object
Returns the value of attribute tool_calls
57 58 59 |
# File 'lib/parse/agent/mcp_client.rb', line 57 def tool_calls @tool_calls end |
#transcript ⇒ Object
Returns the value of attribute transcript
57 58 59 |
# File 'lib/parse/agent/mcp_client.rb', line 57 def transcript @transcript end |
#usage ⇒ Object
Returns the value of attribute usage
57 58 59 |
# File 'lib/parse/agent/mcp_client.rb', line 57 def usage @usage end |
Instance Method Details
#reply(question) ⇒ Result
Continue this conversation. Equivalent to calling ‘client.ask(question, reset: false)`.
62 63 64 65 |
# File 'lib/parse/agent/mcp_client.rb', line 62 def reply(question) raise "Result has no associated client (constructed outside MCPClient)" unless client client.ask(question, reset: false) end |
#to_s ⇒ Object Also known as: inspect
Pretty-print for IRB: tool trace, answer, then per-call usage line.
68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/parse/agent/mcp_client.rb', line 68 def to_s parts = [] if tool_calls.any? parts << "─── tool calls (#{tool_calls.size}) ───" tool_calls.each_with_index do |tc, i| args_str = tc[:arguments].is_a?(Hash) ? tc[:arguments].inspect : tc[:arguments].to_s parts << " #{i + 1}. #{tc[:name]}(#{args_str})" end end parts << "─── answer ───" parts << text.to_s parts << "─── usage ───" << " #{usage}" if usage && usage.total_tokens.positive? parts.join("\n") end |