Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ PATH
roast-ai (1.1.0)
activesupport (~> 8.0)
async (>= 2.34)
nokogiri (>= 1.18)
rainbow (>= 3.0.0)
ruby_llm (>= 1.13)
type_toolkit (>= 0.0.5)
Expand Down Expand Up @@ -108,6 +109,10 @@ GEM
net-http (0.9.1)
uri (>= 0.11.1)
netrc (0.11.0)
nokogiri (1.19.3-arm64-darwin)
racc (~> 1.4)
nokogiri (1.19.3-x86_64-linux-gnu)
racc (~> 1.4)
notiffany (0.1.3)
nenv (~> 0.1)
shellany (~> 0.0)
Expand Down
25 changes: 25 additions & 0 deletions lib/roast/cogs/agent/providers/claude/tool_result.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# typed: true
# frozen_string_literal: true

require "nokogiri"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should add this require in lib/roast.rb where all the other third-party requires are located


module Roast
module Cogs
class Agent < Cog
Expand Down Expand Up @@ -251,6 +253,29 @@ def format_taskcreate
ok_line(preview)
end

# Formats a TaskOutput tool-result line.
#
# Content: sibling tags carrying the task's state, followed by a
# trailing <output> of arbitrary unescaped text. Parsed leniently
# as an XML fragment, which tolerates the absent single root and the
# unescaped <output> body.
#
# Output: "TASKOUTPUT OK <status>" – the text of <status>, or of
# <retrieval_status> when no <status> tag is present (as on a
# pending retrieval). The status is omitted when neither is present.
#
# Examples:
# TASKOUTPUT OK completed
# TASKOUTPUT OK pending
# TASKOUTPUT OK
#
#: () -> String
def format_taskoutput
fragment = Nokogiri::XML::DocumentFragment.parse(content.to_s)
status = (fragment.at_xpath(".//status") || fragment.at_xpath(".//retrieval_status"))&.text&.strip
ok_line(status)
end

#: () -> String
def format_unknown
"UNKNOWN [#{tool_name}] OK #{tool_use_description}\n#{content}"
Expand Down
1 change: 1 addition & 0 deletions roast-ai.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ Gem::Specification.new do |spec|

spec.add_dependency("activesupport", "~> 8.0")
spec.add_dependency("async", ">= 2.34")
spec.add_dependency("nokogiri", ">= 1.18")
spec.add_dependency("rainbow", ">= 3.0.0")
spec.add_dependency("ruby_llm", ">= 1.13")
spec.add_dependency("type_toolkit", ">= 0.0.5")
Expand Down
Loading
Loading