Skip to content
Merged
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
9 changes: 7 additions & 2 deletions R/session.R
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,6 @@ handle_message_from_server <- function(msg) {
)

# cat(paste(capture.output(str(body)), collapse="\n"), file=stderr())

} else {
body <- jsonrpc_response(
data$id,
Expand All @@ -136,6 +135,12 @@ handle_message_from_server <- function(msg) {
}

as_tool_call_result <- function(data, result) {
is_error <- FALSE
if (inherits(result, "btw::BtwToolResult")) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Doing so conditionally so that we can continue to support arbitrary functions as tools.

is_error <- !is.null(result@error)
result <- result@value %||% result@error
}

jsonrpc_response(
data$id,
list(
Expand All @@ -145,7 +150,7 @@ as_tool_call_result <- function(data, result) {
text = paste(result, collapse = "\n")
)
),
isError = FALSE
isError = is_error
)
)
}
Expand Down