Commit eaa9292
authored
fix(motion-graphics): agent tool wiring + ffmpeg frame clipping (v0.2.26) (#29)
End-to-end agent loop now works with real LLMs (OpenAI gpt-4o-mini
verified). Caught by running the Example 03 agent factory live against
gpt-4o-mini and capturing the full failure chain. Unit tests previously
mocked these paths so the bugs were invisible.
Three real bugs fixed:
1. Tool registration (agent.py)
Passing class instances (FileTools(), RenderTools()) as tools caused the
OpenAI adapter to log 'Tool ... not recognized' and the agent to skip
tool calls entirely. Now we expose individual bound methods:
- file_tools.read_file / write_file / list_files
- lint_composition / render_composition (sync wrappers, see #2)
2. Async tools in sync agent path (agent.py)
RenderTools.lint_composition / render_composition are async but the
Agent sync path does not await coroutines. Result:
'Object of type coroutine is not JSON serializable'
Fix: wrap each async tool with a local sync function that uses
asyncio.run(...). Bytes are also stripped from the render_composition
return (unserializable, and the file already lives at output_path).
3. Odd-height screenshots break libx264 (backend_html.py)
page.screenshot(full_page=True) captured 1920x1167 for the LLM-authored
composition (SVG overflowed viewport). libx264 rejects odd height:
'height not divisible by 2 (1920x1167)'
Fix: clip to the exact 1920x1080 viewport via
page.screenshot(clip={x:0,y:0,width:1920,height:1080})
Tests updated (test_motion_graphics_agent.py):
- MockFileTools now exposes read_file/write_file/list_files methods
- tool-count assertions updated from 2 class instances to 5 callables
Verification (live, not mocked):
PRAISONAI_AUTO_APPROVE=true MOTION_LLM=gpt-4o-mini \
python examples/python/video/03_motion_graphics_agent_factory.py
Produces:
index.html (LLM-authored, 1031 bytes)
intro.mp4 (1920x1080 H.264 yuv420p, 30fps, 1.5s, 13.5KB)
87/87 unit tests pass. Version bump 0.2.25 -> 0.2.26.1 parent ddc77bc commit eaa9292
File tree
4 files changed
+75
-22
lines changed- praisonai_tools/video/motion_graphics
- tests/unit/video
4 files changed
+75
-22
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
| 3 | + | |
3 | 4 | | |
4 | 5 | | |
5 | 6 | | |
| |||
193 | 194 | | |
194 | 195 | | |
195 | 196 | | |
196 | | - | |
197 | | - | |
198 | | - | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
199 | 201 | | |
200 | 202 | | |
201 | | - | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
202 | 234 | | |
203 | 235 | | |
204 | 236 | | |
205 | | - | |
| 237 | + | |
206 | 238 | | |
207 | 239 | | |
208 | 240 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
231 | 231 | | |
232 | 232 | | |
233 | 233 | | |
234 | | - | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
235 | 238 | | |
236 | | - | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
237 | 243 | | |
238 | 244 | | |
239 | 245 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
27 | | - | |
28 | | - | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
29 | 33 | | |
30 | 34 | | |
31 | 35 | | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
32 | 45 | | |
33 | 46 | | |
34 | 47 | | |
| |||
115 | 128 | | |
116 | 129 | | |
117 | 130 | | |
118 | | - | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
119 | 138 | | |
120 | 139 | | |
121 | 140 | | |
| |||
207 | 226 | | |
208 | 227 | | |
209 | 228 | | |
210 | | - | |
211 | | - | |
212 | | - | |
213 | | - | |
214 | | - | |
215 | | - | |
216 | | - | |
217 | | - | |
218 | | - | |
219 | | - | |
220 | | - | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
0 commit comments