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.
textis the LLM's final-turn answer.tool_callsis the ordered list of tools invoked, each with its arguments and the dispatcher's response.transcriptis the full message log (useful for debugging).usageis 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
58 59 60 |
# File 'lib/parse/agent/mcp_client.rb', line 58 def client @client end |
#text ⇒ Object
Returns the value of attribute text
58 59 60 |
# File 'lib/parse/agent/mcp_client.rb', line 58 def text @text end |
#tool_calls ⇒ Object
Returns the value of attribute tool_calls
58 59 60 |
# File 'lib/parse/agent/mcp_client.rb', line 58 def tool_calls @tool_calls end |
#transcript ⇒ Object
Returns the value of attribute transcript
58 59 60 |
# File 'lib/parse/agent/mcp_client.rb', line 58 def transcript @transcript end |
#usage ⇒ Object
Returns the value of attribute usage
58 59 60 |
# File 'lib/parse/agent/mcp_client.rb', line 58 def usage @usage end |
Instance Method Details
#reply(question) ⇒ Result
Continue this conversation. Equivalent to calling
client.ask(question, reset: false).
63 64 65 66 |
# File 'lib/parse/agent/mcp_client.rb', line 63 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.
Every interpolated part is attacker-influenced. The answer is LLM
output that was itself conditioned on tenant rows, and tool arguments
can echo stored values. Merely evaluating mcp.ask(...) in IRB writes
this string to the terminal, so control sequences are escaped here.
text itself is untouched: callers that render into a non-terminal
surface still get the exact bytes.
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/parse/agent/mcp_client.rb', line 76 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}. #{Parse::TerminalSafe.sanitize_line(tc[:name])}" \ "(#{Parse::TerminalSafe.sanitize_line(args_str)})" end end parts << "─── answer ───" parts << Parse::TerminalSafe.sanitize(text) parts << "─── usage ───" << " #{usage}" if usage && usage.total_tokens.positive? parts.join("\n") end |