feat: builtin media tools — read_image / transcribe_audio / read_video#49
Merged
Conversation
… path-resolver doc Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Three builtin agent tools that let the model read a media file from the workspace and get text back — the programmatic counterpart to the user-facing attachments from #48. Each is one specialist call via the LocalAI API, so any agent model (even text-only) can use them:
read_image(path, question?)specialist.Describeimage_urlpart → vision model → texttranscribe_audio(path)specialist.Transcribe/audio/transcriptions→ parakeet/whisper → transcriptread_video(path, question?)specialist.DescribeVideovideo_urlpart → video-capable model → textread_videoneeds no ffmpeg — LocalAI parsesvideo_urlcontent parts natively (core/http/middleware/request.go), so it mirrorsread_image.How
specialist.DescribeVideomirrorsDescribe, sending a base64video_urlpart; reusesDataURI.VideoModel; the Session gainsvideoModel/workingDir; per-tool model selection (read_image→visionModel,read_video→videoModel,transcribe_audio→transcribeModel; empty ⇒ LocalAI default). ThevisionModelfield reserved in feat: multimodal attachments — file→text, transcription, native image/audio/video (+ CLI @path//attach) #48 is now consumed.chat/mediatools.go, each holding an injected delegate (theaskUserToolpattern → unit-testable with fakes). Paths resolve againstWorkingDirviaresolveWorkspacePath(roots relative paths, matching the hostreadtool — not a sandbox). Errors are returned as the tool-result string so the model reads and reacts to them.s.toolEnabled(name)in theBuiltinToolsallowlist and added toreadOnlyTools(observational → auto-approve in default prompt mode).Testing
DescribeVideohttptest (asserts adata:video/video_urlpart is sent), each tool'sRunwith fake delegates (arg threading, empty-path guard, delegate-error → error result),resolveWorkspacePathtable test, andIsReadOnlymembership.go build ./...+go test ./chat/ ./specialist/green.Built subagent-driven with per-task spec+quality reviews and a final whole-branch review, which caught and this PR fixes the media delegates capturing the session context instead of the per-turn context (so in-flight calls now honor interrupt).
Follow-ups
Optional per-tool config docs; frame-sampling fallback for models lacking native video input (only if a text-only-video workflow is ever needed). The desktop UI is a separate nib-desktop effort.
🤖 Generated with Claude Code