fix(core): avoid redundant final computer screenshots - #1827
Conversation
🦋 Changeset detectedLatest commit: 1b75d67 The changes in this PR will be included in the next version bump. This PR includes changesets to release 6 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
🟢 Approval recommended
The change is narrowly scoped to removing a redundant screenshot call, and the updated/added tests cover the reported regression scenarios and verify the single-capture behavior.
Pull request overview
Fixes duplicate computer screenshot captures in the agents-core runner by deferring explicit screenshot actions to the existing single “final post-batch” capture, so each computer tool call produces exactly one screenshot observation.
Changes:
- Treat
computer_callscreenshotactions as no-ops during action dispatch and rely on the single final capture. - Update/extend test coverage for direct execution, HITL resume, and legacy replay to assert a single screenshot capture.
- Add a patch changeset for
@openai/agents-core.
File summaries
| File | Description |
|---|---|
packages/agents-core/src/runner/toolExecution.ts |
Stops invoking computer.screenshot() for action.type === 'screenshot', leaving only the final capture after all actions. |
packages/agents-core/test/runner/toolExecution.test.ts |
Adds/updates assertions to ensure exactly one screenshot per computer call and validates ordering for non-screenshot actions. |
packages/agents-core/test/runner/turnResolution.test.ts |
Adjusts resume-related expectations to match single-capture behavior. |
packages/agents-core/test/toolInvocationReplay.test.ts |
Updates replay expectations to reflect removing the redundant screenshot call. |
.changeset/single-final-computer-screenshot.md |
Declares a patch bump for the bug fix in @openai/agents-core. |
Review details
- Files reviewed: 5/5 changed files
- Comments generated: 0
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
sylvesterkaczmarek
left a comment
There was a problem hiding this comment.
Deferring every explicit screenshot changes the semantics of the action sequence, rather than only removing a duplicate capture. For [screenshot, click], the caller asked the backend to capture before the click, but this patch deliberately executes click first and captures only afterward. A screenshot can also be an observable or synchronizing operation for remote computer implementations. A safer shape would be to execute explicit screenshots in order, cache the most recent capture, and reuse it only when no later non-screenshot action invalidates it. That still gives one capture for [screenshot] and [click, screenshot], while preserving the requested ordering for [screenshot, click].
|
Addressed in 1ee899c. Explicit screenshot actions now execute at their original sequence position. The most recent capture is reused only when no later non-screenshot action invalidates it; otherwise the runner captures the final state after the remaining actions. Added regressions for both [screenshot, click]\ and [click, screenshot]. The focused execution, HITL resume, and replay suite passes (337 tests), along with build, type, dist, lint, and formatting checks. The Windows full-suite run reached 6,363 passes; its 92 failures are confined to existing Unix sandbox, POSIX path/permission, and Windows child-process fixtures, while all changed-path tests pass. |
sylvesterkaczmarek
left a comment
There was a problem hiding this comment.
Re-reviewed the current action loop. Explicit screenshots now run in sequence, a later non-screenshot action invalidates the cached capture, and only a final explicit screenshot is reused. The [screenshot, click] and [click, screenshot] regressions cover the ordering boundary I raised. My concern is resolved.
seratch
left a comment
There was a problem hiding this comment.
Thanks for the update. The current revision restores the caching and invalidation approach that we previously decided against in #1736. The official computer-use handlers treat screenshot actions as no-ops within the batch and capture the final screen afterward.
Please remove the screenshot cache and invalidation logic, make the screenshot switch case a no-op, and use the existing final capture. Update the [screenshot, click] regression to expect the click followed by one screenshot, with that image returned as the observation. This addresses #1735 without adding an intermediate-capture contract.
|
Thanks for clarifying. Addressed in 1b75d67: the screenshot case is now a no-op, and the cache/invalidation logic is removed. The existing final capture supplies the observation. The [screenshot, click] regression now expects click followed by exactly one screenshot and checks that the returned image reflects the completed click. Focused execution/HITL/replay: 337 passed; runner: 692 passed; full Linux suite: 6453 passed, 2 skipped. Build, type checks, lint, and formatting also passed. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 1b75d67cc7
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
seratch
left a comment
There was a problem hiding this comment.
Please fix all the codex feedback
|
@seratch Could you confirm the intended screenshot semantics before I change the implementation again? Your earlier review requested removing the cache/invalidation logic and treating screenshot actions as no-ops, with one final capture. That is implemented in 1b75d67. The new automated finding requests the opposite: capture at each screenshot action's position, cache the image, and invalidate it after subsequent actions, citing the guide's statement that batched actions execute in order. For [screenshot, click], should the expected calls remain click -> screenshot, or should they be screenshot -> click -> screenshot? If final-only capture is still intended, I can clarify the screenshot exception in the appropriate documentation, coordinated with release timing, rather than restore the approach rejected in #1736. I have left the finding open pending clarification. |
|
Thanks for flagging the conflicting feedback. The intended behavior remains one final capture per completed batch: [screenshot, click] should execute click followed by screenshot. My later request to address all Codex feedback was too broad. The intermediate-capture finding does not change the specific direction previously requested. The current implementation matches that direction; no cache or invalidation logic is needed. |
Summary
Test plan
git diff --checkpassed.Issue number
Fixes #1735
Checks
@openai/agents-core.