feat(tools): add read_audio, read_video, create_video tools and fix system prompt tool filtering

- Add read_audio tool with Gemini File API, OpenAI input_audio, and fallback support
- Add read_video tool with Gemini File API and base64 fallback for video analysis
- Add create_video tool with Gemini Veo and OpenRouter chat completions support
- Add shared gemini_file_api.go for upload → poll → generateContent pipeline
- Add shared openai_compat_call.go for custom JSON chat completions
- Fix system prompt showing denied tools: use filteredToolNames() instead of tools.List()
- Wire audio/video MediaRef context propagation in agent loop
- Register new tools in seed data, policy groups, and web UI settings
- Enforce duration (max 30s) and aspect_ratio limits on create_video
This commit is contained in:
viettranx committed 2026-03-08 14:43:18 +07:00
1 parent ea185b3f6c
commit 691ddce8fb
15 files changed
+1484 -7

No files matched your search

+37 -1
View File
@@ -359,7 +359,43 @@ func (l *Loop) runLoop(ctx context.Context, req RunRequest) (*RunResult, error)
ctx = tools.WithMediaDocRefs(ctx, docRefs)
}
// 2b. Cross-session recovery: notify team leads about orphaned pending tasks
// 2c. Collect audio MediaRefs (current + historical) for read_audio tool.
var audioRefs []providers.MediaRef
for _, ref := range mediaRefs {
if ref.Kind == "audio" {
audioRefs = append(audioRefs, ref)
}
}
for i := len(messages) - 1; i >= 0; i-- {
for _, ref := range messages[i].MediaRefs {
if ref.Kind == "audio" {
audioRefs = append(audioRefs, ref)
}
}
}
if len(audioRefs) > 0 {
ctx = tools.WithMediaAudioRefs(ctx, audioRefs)
}
// 2d. Collect video MediaRefs (current + historical) for read_video tool.
var videoRefs []providers.MediaRef
for _, ref := range mediaRefs {
if ref.Kind == "video" {
videoRefs = append(videoRefs, ref)
}
}
for i := len(messages) - 1; i >= 0; i-- {
for _, ref := range messages[i].MediaRefs {
if ref.Kind == "video" {
videoRefs = append(videoRefs, ref)
}
}
}
if len(videoRefs) > 0 {
ctx = tools.WithMediaVideoRefs(ctx, videoRefs)
}
// 2e. Cross-session recovery: notify team leads about orphaned pending tasks
// and in-progress tasks being handled by delegates.
// Safe because Bước 1 (early ClaimTask) ensures running tasks are in_progress,
// so only truly un-spawned tasks remain pending.