Returns codeagent's UI-neutral structured artifact from an
ellmer::ContentToolResult, an on_tool_result event, or an artifact itself.
A renderer should consume supported artifacts first and fall back to
tool_result_value() when this function returns NULL. The shinychat
extra$display object is an optional presentation adapter, not the portable
data contract.
Arguments
- result
An ellmer::ContentToolResult,
on_tool_resultevent list, or artifact list.- version
Supported artifact version(s). Defaults to version 1. Use
NULLto inspect a structurally valid artifact of any version.
Examples
result <- tool_result(
"2 rows", kind = "table",
payload = list(columns = c("id", "value"), rows = 2L))
artifact <- tool_result_artifact(result)
artifact$kind
#> [1] "table"
artifact$version
#> [1] 1
tool_result_value(result)
#> [1] "2 rows"
# Generic UI fallback pattern:
if (is.null(tool_result_artifact(result))) tool_result_value(result)