Skip to content

fix(tools): derive valid git diff argv in sandboxed decorator (#614) - #636

Closed
Tiktokaiagent wants to merge 1 commit into
use-agent-os:mainfrom
Tiktokaiagent:comp/614-better-git-diff-v2
Closed

fix(tools): derive valid git diff argv in sandboxed decorator (#614)#636
Tiktokaiagent wants to merge 1 commit into
use-agent-os:mainfrom
Tiktokaiagent:comp/614-better-git-diff-v2

Conversation

@Tiktokaiagent

@Tiktokaiagent Tiktokaiagent commented Aug 30, 2026

Copy link
Copy Markdown
Contributor

Summary

Replaces the inline lambda in git_diff's @sandboxed argv_factory that produced an invalid --unstaged flag. Git does not accept --unstaged — the unstaged state is the default when --cached is absent. The lambda also emitted an empty string for path when no path was provided, producing a trailing empty argv element.

Fix

  • _git_diff_argv() named function that properly handles all combinations:
    • unstaged, no path: ("git", "diff")
    • staged, no path: ("git", "diff", "--cached")
    • unstaged + path: ("git", "diff", "--", "path")
    • staged + path: ("git", "diff", "--cached", "--", "path")
  • 4 test cases covering all combinations

Changes

  • src/agentos/tools/builtin/git.py: replaced inline lambda with _git_diff_argv()
  • tests/test_tools/test_git_workdir_policy.py: 4 new test cases

Tests

Verified git workdir policy tests pass:

$ python -m pytest tests/test_tools/test_git_workdir_policy.py -q --no-header
4 passed in 0.87s
  • This pull request fully resolves the linked issue.
  • Bug fix: fixes broken sandbox decorator behavior
  • Includes regression tests for all 4 edge cases

Fixes #614

Replace the inline lambda in git_diff's @sandboxed argv_factory with
a dedicated named function that produces valid git invocations:

- No --unstaged flag (invalid in git)
- No empty string path when path=None
- Properly adds -- separator before paths

Fixes use-agent-os#614
@Tiktokaiagent Tiktokaiagent changed the title fix(tools): derive valid git diff argv in sandboxed decorator fix(tools): derive valid git diff argv in sandboxed decorator (#614) Aug 31, 2026
@andreapn

andreapn commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

Issue #614 has been resolved by #617, which landed on main with an equivalent _git_diff_argv helper.

Closing this as superseded. Thanks for the contribution.

@andreapn andreapn closed this Sep 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: sandbox decorator emits invalid --unstaged flag and empty path argument

2 participants