Skip to content

feat(tools): add scoped path filtering to git_log - #624

Closed
Preciousuche wants to merge 1 commit into
use-agent-os:mainfrom
Preciousuche:feat/tools-git-log-path-filter
Closed

feat(tools): add scoped path filtering to git_log#624
Preciousuche wants to merge 1 commit into
use-agent-os:mainfrom
Preciousuche:feat/tools-git-log-path-filter

Conversation

@Preciousuche

Copy link
Copy Markdown
Contributor

Description

closes #623

### Summary
Adds optional path filtering to the built-in `git_log` tool in `src/agentos/tools/builtin/git.py`.

### Problem
Previously, `git_log` only supported `count` and `workdir`. When an agent investigated changes to a specific file or directory, it had to retrieve the top `N` commits across the entire repository. This consumed unnecessary context tokens and missed older commits that touched the target file.

### Changes
- Added optional `path: str | None = None` parameter to `git_log()`.
- Validated `path` using `_reject_foreign_git_path(path)` to prevent directory traversal and foreign Windows path injections.
- Added `_git_log_argv` helper to derive clean sandboxed arguments (`git log --max-count=N -- path`).
- Added unit tests in `tests/test_tools/test_git_workdir_policy.py` and path-scoping integration tests in `tests/test_security/test_git_output_redaction.py`.

### Verification
- `uv run pytest tests/test_tools/test_git_workdir_policy.py` (7 passed)
- `uv run pytest tests/test_security/test_git_output_redaction.py` (23 passed)
- `ruff check`, `ruff format`, and `mypy` all passed with 0 errors.

@andreapn

andreapn commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

Closing along with #623, which I closed as wontfix. git_log returns correct results today; the missing path costs some extra tokens, not correctness, and every built-in tool parameter is permanent schema surface plus path validation plus a sandbox fingerprint to keep in sync (#614 in this same batch is that fingerprint drifting out of sync once a tool takes a path).

Full reasoning: #623 (comment)

Thanks for the patch — the argument in the issue was well made, it just lands on the wrong side of "does this earn permanent tool surface".

@andreapn andreapn closed this Aug 31, 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.

[Feature}:Add Scoped Path Filtering to git_log Built-in Tool

3 participants