Title: fix(media): bound the ffmpeg tool's child processes, inputs and scale targets by icecrasher321 · Pull Request #6989 · simstudioai/sim · GitHub
Open Graph Title: fix(media): bound the ffmpeg tool's child processes, inputs and scale targets by icecrasher321 · Pull Request #6989 · simstudioai/sim
X Title: fix(media): bound the ffmpeg tool's child processes, inputs and scale targets by icecrasher321 · Pull Request #6989 · simstudioai/sim
Description: Problem The copilot ffmpeg tool shells out to FFmpeg in the Sim app process — not in a sandbox (docker/app.Dockerfile installs the binary for exactly this) — and nothing bounded the run. runCommand had no timer, no .kill() and no signal, so a transcode ran until it finished and survived the request that asked for it: a stopped copilot turn left the encode pinning both cores of a shared instance. scale=30000:30000 reached libavfilter unvalidated, which sizes its per-frame buffers from those numbers (~2.7 GB a frame) inside a child that shares the instance's memory. Change Deadline + kill. Every operation shares one 10-minute wall-clock deadline; both the deadline and the caller's cancellation SIGKILL the child. Per-operation rather than per-command, because concat runs a full re-encode per input — a per-command timeout would let N inputs multiply into N timeouts. Cancellation is wired to context.abortSignal. Every abort reason on that controller is an explicit user stop (UserStop / RedisPoller / MarkerObservedAtBodyClose); the copilot lifecycle tracks a passive client disconnect separately as publisher.clientDisconnected and does not abort on it. So an encode dies when the user presses stop and never otherwise. Worth flagging separately: userStopSignal, which the existing assertServerToolNotAborted calls read, is declared on ServerToolContext but never populated — createServerToolHandler forwards only abortSignal, and ToolExecutionContext has no such field. Those assertions are currently no-ops on this path. Left alone here; abortSignal is the signal that actually arrives. ffprobe had the same shape in miniature. fluent-ffmpeg's static ffprobe hands back no process handle, so a timeout could only race the callback and leave a wedged prober alive — and concat probes once per input, so the leak scaled with the request. Now runs through execFile, which takes timeout, killSignal and signal natively. Scale targets are rejected outside 16–4096 with a message the model can act on, plus an area cap. concat's targets come from the source container rather than a caller assertion, so those are clamped instead of rejected. Two holes not in the original report: readOut buffered the output with no ceiling (CRF-18 re-encodes routinely exceed their input, so the input budget did not bound it), and the handler accepted unlimited input files. Both capped; the byte check now runs against the recorded size before the download rather than after. Single source of truth FFMPEG_LIMITS holds the four numbers the Go tool catalog mirrors into its schema, pinned by ffmpeg-schema-parity.test.ts. Without it, changing a limit here would leave the model reading a stale ceiling off its own schema — silent, and user-visible as "the tool said 4096 but refused at 2048". Verified non-vacuous: flipping maxInputFiles to 21 and maxScaleDimension to 2048 fails it on exactly those assertions. Scope note on the generated bindings Regenerating the catalog the obvious way pulls in load_slide_layout, an unrelated tool from copilot 7e741a39 (house deck system / slide-layout library) that this branch has not synced. The bindings here were generated from the copilot commit these files already matched, plus only this change — proven by first regenerating from the unmodified baseline contract and confirming a byte-identical match with the committed files. The diff touches exactly Ffmpeg, GenerateAudio, GenerateImage, GenerateVideo; zero slide-layout leakage. That feature syncs whenever someone brings it over. Verification tsc --noEmit, lint:check, 2586 tests across lib/copilot + lib/media + lib/uploads + lib/workspace-files, and check:api-validation / boundaries / client-boundary / utils — all pass, rebased onto latest staging (which includes #6986's provenance change to this same file). Companion Companion: https://github.com/simstudioai/mothership/pull/447 That PR carries the schema side — the tool-catalog wording and the maxItems/minimum/maximum this branch mirrors. Merge in lockstep. 🤖 Generated with Claude Code
Open Graph Description: Problem The copilot ffmpeg tool shells out to FFmpeg in the Sim app process — not in a sandbox (docker/app.Dockerfile installs the binary for exactly this) — and nothing bounded the run. runCommand...
X Description: Problem The copilot ffmpeg tool shells out to FFmpeg in the Sim app process — not in a sandbox (docker/app.Dockerfile installs the binary for exactly this) — and nothing bounded the run. runCommand...
Opengraph URL: https://github.com/simstudioai/sim/pull/6989
X: @github
Domain: github.com
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react-reconciler,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@d5750093facf |
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:6485b17d-7d99-206b-0aae-ce4d3c717680 |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | C840:19FA2E:8140AE:B79B7E:6AFB4C88 |
| html-safe-nonce | 8fb58d2e429515c67c86a0e3c8ea7bc34531675bc17464416589a712742fc949 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDODQwOjE5RkEyRTo4MTQwQUU6Qjc5QjdFOjZBRkI0Qzg4IiwidmlzaXRvcl9pZCI6IjM1MTk4MTU5NTQyODM0MjkyMCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | dff5e4bbc2858a7108e3cded9ccab1bd75393cb6ca62633b59e4861fe0267f38 |
| hovercard-subject-tag | pull_request:4339984502 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/simstudioai/sim/pull/6989/files |
| twitter:image | https://avatars.githubusercontent.com/u/17950982?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/17950982?s=400&v=4 |
| og:image:alt | Problem The copilot ffmpeg tool shells out to FFmpeg in the Sim app process — not in a sandbox (docker/app.Dockerfile installs the binary for exactly this) — and nothing bounded the run. runCommand... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | acf7616d06cc051644705b379878c9bb13dc5e70ecf4ffd9b34140f8ac01d7e1 |
| turbo-cache-control | no-preview |
| diff-view | unified |
| go-import | github.com/simstudioai/sim git https://github.com/simstudioai/sim.git |
| octolytics-dimension-user_id | 199344406 |
| octolytics-dimension-user_login | simstudioai |
| octolytics-dimension-repository_id | 912559512 |
| octolytics-dimension-repository_nwo | simstudioai/sim |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 912559512 |
| octolytics-dimension-repository_network_root_nwo | simstudioai/sim |
| turbo-body-classes | logged-out env-production page-responsive full-width |
| disable-turbo | true |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 26504db649b58525278f77a52b80ba5f10d5f4de |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width