feat: capture Replicate predict_time for image / movie / sound_effect / lipsync agents
enhancement
Part of #1415.
## What
Four agents call Replicate via `replicate.run()`: `image_replicate_agent`, `movie_replicate_agent`, `sound_effect_replicate_agent`, `lipsync_replicate_agent`.
Replicate bills per second of compute (`metrics.predict_time`), but `replicate.run()` discards that. Options:
- **A**: Switch each agent to `predictions.create()` + `predictions.get(id)` polling. Get exact `metrics.predict_time` and `metrics.total_time` on completion. Cleanest, but more code.
- **B**: Wrap `replicate.run()` and time it with `Date.now()` deltas. Overestimates (includes queueing). Easy.
- **C**: Single shared helper in mulmocast (or graphai) that does `predictions.create()` and yields `{ output, predictSec }`. Apply to all 4 agents.
Recommend **C** if the deltas are similar enough that one helper covers all 4. Otherwise A per agent.
## Acceptance
- [ ] Decision recorded (A / B / C) in this issue
- [ ] All 4 agents updated to return `{ ..., usage: { provider: "replicate", model, predictSec } }`
- [ ] Integration test with a fake Replicate response containing `metrics`
- [ ] Handle the cancel / timeout case (record partial `predictSec` if available)
## Dependencies
- #1 (UsageCollector)
关闭于 2026-06-20 0 条评论