Repository navigation
Commit a05cd33
authored
fix(tool-loader): enable image output from declarative tools via data URI (#62)
* fix(tool-loader): support image output from declarative tools via data URI
Declarative tools that return image data were silently falling through
to text handling, causing models to receive raw base64 as plain text
instead of an image content block.
Detect data URIs (data:image/<type>;base64,...) in tool output and
return a proper ImageContent block. Works across all providers via
pi-ai's shared transform-messages layer; non-vision models receive a
graceful placeholder automatically.
* fix(tool-loader): address image URI review comments
- Scan lines for data URI instead of requiring stdout to start with it,
so stray log output from scripts doesn't silently break detection
- Add mime type allowlist (jpeg, png, gif, webp) and empty data guard;
unsupported types fall through to text handling instead of erroring silently
- Add comment explaining the magic number 5 (skipping "data:" prefix)1 parent e4f3af9 commit a05cd33
1 file changed
Lines changed: 22 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
118 | 118 | | |
119 | 119 | | |
120 | 120 | | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
121 | 143 | | |
122 | 144 | | |
123 | 145 | | |
| |||
0 commit comments