attach
Adds attachment to the result of the tool call that runs this code, so the model gets the file with the text the tool returns: the screenshot that a browser tool took, for example.
val screenshot = Tool<Page>("screenshot", "Takes a screenshot of a web page.") { page ->
attach(Attachment.of(browser.screenshot(page.url), "image/png"))
"The screenshot of ${page.url}."
}Content copied to clipboard
Call it from a Tool or a StateTool. A tool that fails returns no attachments. It does nothing when no tool call runs the code, as when a test calls Tool.execute itself: a test that checks the files of a tool runs it with List.execute, whose results have them.