Expand description
Tool media returns — the ADK pattern where a function response carries images or other media to the model alongside its JSON payload, so vision tools (screenshots, chart renderers, document croppers) feed the model something it can actually look at.
The mechanism is a convention, so it works with every existing tool
shape unchanged: a tool embeds media under the reserved "_media" key
of its JSON result (via attach), and the text-agent loop lifts it
out of the function response and delivers it to the model as
inline_data parts in the same turn. Tools that never touch _media
behave exactly as before.
ⓘ
T::simple("chart", "Render a chart", |args| async move {
let png: Vec<u8> = render(&args)?;
let mut result = json!({"rendered": true});
media::attach(&mut result, "image/png", &png);
Ok(result)
})Structs§
- Media
Attachment - One media attachment lifted from a tool result.
Constants§
- MEDIA_
KEY - Reserved result key holding media attachments.