fix(sdk): pass workspace git patch to critics - #4585
Open
somalice wants to merge 1 commit into
Open
Conversation
Collaborator
|
🚦 CI is currently failing on this PR's latest commit. Please fix the failing checks before OpenHands reviews it - this is re-checked automatically once you push a new commit. (A maintainer can also request This is an automated check - no AI was used to generate this comment. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
HUMAN:
I am submitting this initial fix for #4554 and would like maintainers to confirm whether this direction is acceptable.
AGENT:
Why
CriticMixin._evaluate_with_critic()always passedgit_patch=NonetoCriticBase.evaluate(), which made thegit_patchparameter unreachable in normal SDK usage.This means patch-aware critics could not evaluate the actual workspace changes and had to rely on transcript contents instead.
Summary
CriticBase.evaluate(..., git_patch=...).git_patch=Nonewhen there are no changes or patch collection fails.Issue Number
Related to #4554
How to Test
I tested this locally with:
git diff --checkD:\python\python.exe -m py_compile openhands-sdk/openhands/sdk/agent/critic_mixin.py tests/sdk/agent/test_iterative_refinement.pyuv run --no-sync pytest tests/sdk/agent/test_iterative_refinement.py -q21 passed in 1.40suv run --frozen pre-commit run --files openhands-sdk/openhands/sdk/agent/critic_mixin.py tests/sdk/agent/test_iterative_refinement.pyVideo/Screenshots
N/A. This is a backend SDK behavior change covered by unit tests.
Design Doc
N/A.
Type
Notes
This PR does not mutate the user's git index. It only uses the existing workspace diff APIs.
The generated patch represents the workspace diff at evaluation time. If the workspace was already dirty before the agent run, pre-existing changes may be included.
Strictly scoping the patch to only agent-authored edits would require a larger follow-up change, such as capturing a baseline at conversation start.