Repository navigation
Description
Summary
Add two opt-in tools, RecordStart and RecordStop, so the agent can record the screen to an MP4 file. Like the built-in recorders on each OS (macOS Cmd+Shift+5, Windows Snipping Tool, GNOME screen recorder), the agent picks what to record: the entire screen, a single window, or a region (position plus width and height).
Use cases:
- Unattended audit trail - record what the agent did on the machine while the user was away.
- Tutorials - ask the agent to demonstrate a feature and keep the recording, scoped to just the app window or area that matters.
Proposed behaviour
-
RecordStartstarts one recording and returns the target file path plus the captured rectangle. It takes an optional capture target:mode:screen(default),window, orregion.window(only withmode=window):frontmost(default),app:<name>,pid:<number>, or a bare application name - the same syntax as theComputertool'starget.region(only withmode=region):{x, y, width, height}in the frame coordinate space - the same shape and space as theComputertool's screenshotregion, so the agent can take coordinates straight from a screenshot or accessibility bounding box.
{"mode": "screen"} {"mode": "window", "window": "app:Safari"} {"mode": "region", "region": {"x": 0, "y": 80, "width": 1280, "height": 720}} -
If a recording is already running,
RecordStartreturns an error instead of starting a second one. -
RecordStoptakes no arguments. It stops the active recording, finalizes the file, and returns its path, duration, and size. If nothing is recording, it returns a clear error. -
Output:
~/.infer/tmp/recordings/<timestamp>.mp4(H.264,yuv420p, so it plays in browsers and QuickTime). -
Max duration: 120s by default (configurable). When the cap is reached, the recording stops and is finalized on its own, and
RecordStopstill returns the file. -
Graceful shutdown: when the CLI exits (normal exit, Ctrl+C, SIGTERM), an active recording is stopped and finalized, not left as a truncated/corrupt MP4 or an orphaned ffmpeg process.
-
Cross-platform: macOS, Linux (X11), Windows.
-
Disabled by default.
Implementation notes (reuse what already exists)
-
Config - add a
recordingsection tocomputer_use.yaml(config/computer_use.go), next toscreenshot, so it gets the existing env var mapping for free:computer_use: recording: enabled: false # INFER_COMPUTER_USE_RECORDING_ENABLED max_duration: 120 # seconds, INFER_COMPUTER_USE_RECORDING_MAX_DURATION output_dir: "" # empty = ~/.infer/tmp/recordings framerate: 24 # INFER_COMPUTER_USE_RECORDING_FRAMERATE; also pinned as the output rate (-r)
Register the tools in
internal/computer/tools.goonly whencomputer_use.recording.enabledis true (the same wayComputerdepends oncomputer_use.enabled). -
Encoder - use ffmpeg.
internal/audioalready resolves and downloads ffmpeg into~/.infer/bin(BinaryStore,speech_to_text.ffmpeg_path), andinternal/audio/recorder.goalready builds per-OS ffmpeg capture arguments and stops ffmpeg gracefully. Reuse that instead of adding a new dependency.- Caveat (found while verifying feat(computer): add RecordStart and RecordStop screen recording tools #1304): the
~/.infer/binfallback downloads theinference-gateway/binariesasset, which is an audio-only build on every OS (macOS/Windows--disable-everything, Linux--disable-libx264 --disable-libxcb): no H.264 encoder and no avfoundation / x11grab / gdigrab. Recording currently only works with a full ffmpeg onPATH(Homebrew, apt, ...). Tracked as a follow-up below.
- Caveat (found while verifying feat(computer): add RecordStart and RecordStop screen recording tools #1304): the
-
Capture target -> one rectangle - each mode resolves to a rectangle when the recording starts, so there is only one capture path per OS:
screen: the full primary display (the same display theComputertool sees).region: validate against the frame bounds and scale from frame space to native screen pixels the waycaptureRegionininternal/computer/executor.goalready does (ScaleAPIToScreen). Out-of-bounds or empty regions return the same kind of error as the screenshot action ("region [...] is outside the WxH frame space").window: resolve the window's bounds when the recording starts. No matching window returns an actionable error. robotgo's purego build has no window-bounds API, so feat(computer): add RecordStart and RecordStop screen recording tools #1304 resolves them natively: macOS through awindowaction in the existing AX helper (needs the Accessibility permission), Linux through EWMH (_NET_ACTIVE_WINDOW/_NET_CLIENT_LIST_STACKING+WM_CLASS), Windows throughGetForegroundWindow/ DWM extended frame bounds (robotgo only maps an app name to pids).- On HiDPI/Retina displays ffmpeg captures physical pixels, so convert logical to physical coordinates (see
scalePhysicalToLogicalininternal/computer/infrastructure/display/robot_controller.go). libx264withyuv420pneeds even width and height, so round the rectangle down to even numbers.
-
ffmpeg inputs per OS:
OS Entire screen Region / window rectangle macOS -f avfoundation -i "<screen index>:none"(needs the Screen Recording permission)same input + -vf crop=W:H:X:Y(avfoundation has no region option)Linux (X11) -f x11grab -i $DISPLAY-f x11grab -video_size WxH -i $DISPLAY+X,YWindows -f gdigrab -i desktop-f gdigrab -offset_x X -offset_y Y -video_size WxH -i desktop -
Stopping - ffmpeg only writes the MP4
moovatom on a clean shutdown. Stop it by writingqto stdin, which works on every OS (os.Interruptis not supported on Windows). Kill it only after a timeout. -
Approval -
RecordStartshould followcomputer_use.approvallike the other observation actions. A visible status indicator in the TUI while a recording is running would be good.- As shipped in feat(computer): add RecordStart and RecordStop screen recording tools #1304: the default
computer_use.approval: neveranddestructiveboth letRecordStartrun without a prompt; onlyalwaysgates it. The chat status bar showsRECwhile recording. Headless runs (no one sees the badge) should be at least judge-gated: #1310.
- As shipped in feat(computer): add RecordStart and RecordStop screen recording tools #1304: the default
Out of scope (follow-ups)
- Following a window that moves or resizes during the recording.
windowmode records the window's bounds at start; anything that covers that area is recorded too. Native window capture (gdigrabtitle=, x11grab-window_id, ScreenCaptureKit on macOS) can come later. - Picking a non-primary display.
- Wayland capture (x11grab does not work there; needs PipeWire/portal).
- Audio capture, pause/resume, several recordings at once, automatic cleanup/retention of old recordings.
- Headless
RecordStartgated by at least the LLM judge: #1310. - A recording-capable ffmpeg for the
~/.infer/binfallback (see the Encoder caveat above), or skip the download for recording and ask for a full ffmpeg onPATH. - Desktop app support: the Desktop runs each chat turn as a fresh
infer headless --format ag-uiprocess, so a recording is finalized when the turn that started it ends and aRecordStopin a later turn finds nothing running. TheRECstatus event is TUI-only (not emitted in AG-UI output), and Desktop settings have nocomputer_use.recording.enabledtoggle.
Verification on #1304
- macOS (avfoundation, Retina): screen, region, and window modes; the one-at-a-time guard;
RecordStopwith nothing running; themax_durationcap; finalize on Ctrl+C; headless start/stop and exit-while-recording. All produced playable H.264yuv420pMP4s and left no ffmpeg running. - Linux X11 (Debian 12, Xvfb + openbox, ffmpeg 5.1): the same modes plus
app:<name>, a missing window, noDISPLAY, andXDG_SESSION_TYPE=wayland. Found and fixed an output frame-rate drift (x11grab gave 23-26fps and duplicated frames) by pinning the output rate with-r. - Windows: not verified yet.
Acceptance Criteria
-
RecordStart/RecordStopare not registered unlesscomputer_use.recording.enabledis true (andINFER_COMPUTER_USE_RECORDING_ENABLED=trueenables them). -
RecordStartwith no arguments records the entire primary screen. -
RecordStartwithmode=regionrecords exactly the given frame-space rectangle (scaled to native pixels, rounded to even dimensions). An out-of-bounds or empty region returns a clear error that includes the frame size. -
RecordStartwithmode=windowrecords the bounds of the matched window (frontmost,app:<name>,pid:<number>, or an app name). No matching window returns a clear error. -
RecordStartreturns the file path and the captured rectangle. -
RecordStartwrites to~/.infer/tmp/recordings/<timestamp>.mp4(or the configuredoutput_dir) and creates the directory if it does not exist. -
RecordStopreturns the path, duration, and size of a playable MP4 (checked withffprobe). - A recording stops and finalizes on its own at
max_duration(default 120s). - Calling
RecordStarttwice, orRecordStopwith nothing recording, returns a clear error and does not break the active recording. - On CLI exit (normal exit, SIGINT, SIGTERM), an active recording is finalized and no ffmpeg process is left running.
- Works on macOS, Linux (X11), and Windows in all three modes. If ffmpeg is missing or screen capture is not supported (for example Wayland, or no macOS permission), the tool returns an actionable error.
- Unit tests cover the per-OS ffmpeg argument building for each mode (screen, region, window), frame-to-screen scaling and even-dimension rounding, region validation, the max-duration cap, and the single-active-recording guard.
-
docs/tools-reference.mdanddocs/configuration-reference.mddocument the tools, the capture modes, and the new config keys/env vars.
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
[-][FEATURE] Implement RecordStart(position) and RecordStop(position)[/-][+][FEATURE] Add RecordStart and RecordStop screen recording tools[/+]feat: build ffmpeg with screen capture and libx264 (#31)
feat(computer): add RecordStart and RecordStop screen recording tools (…
inference-gateway-releaser commentedon Sep 25, 2026
🎉 This issue has been resolved in version 0.208.0 🎉
The release is available on:
Your semantic-release bot 📦🚀