The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix: resolve ACP edit previews against execution cwd
Teknium85ce5418ec74
diff --git a/acp_adapter/edit_approval.py b/acp_adapter/edit_approval.pyindex 0e78915848f..00cdc6becc7 100644--- a/acp_adapter/edit_approval.py+++ b/acp_adapter/edit_approval.py@@ -69,7 +69,8 @@ def _required_path(arguments: dict[str, Any]) -> str:path = str(arguments.get("path") or "")if not path:raise ValueError("path required")- return path+ from tools.file_tools_paths import _resolve_path_for_task+ return str(_resolve_path_for_task(path))def _proposal_for_write_file(arguments: dict[str, Any]) -> EditProposal:diff --git a/tests/acp/test_gateway_editor_cwd.py b/tests/acp/test_gateway_editor_cwd.pynew file mode 100644index 00000000000..ff5dd1e8eb1--- /dev/null+++ b/tests/acp/test_gateway_editor_cwd.py@@ -0,0 +1,29 @@+"""Editor diff preparation must use the same cwd as the actual file tool."""+import pytest++from acp_adapter.edit_approval import (+ maybe_require_edit_approval, set_edit_approval_requester, reset_edit_approval_requester,+)+from gateway.session_policy import build_policy, policy_scope++[email protected]('tool,args', [+ ('write_file', {'content': 'replacement'}),+ ('patch', {'old_string': 'original', 'new_string': 'replacement'}),+])+def test_relative_editor_diff_reads_the_session_file_not_process_cwd(tmp_path, tool, args):+ path = tmp_path / 'unique-editor-diff.txt'+ path.write_text('original')+ policy = build_policy({'source': 'acp', 'cwd': str(tmp_path), 'model': 'fixture'}, {})+ proposals = []+ with policy_scope(policy):+ token = set_edit_approval_requester(lambda p: proposals.append(p) or False)+ try:+ denied = maybe_require_edit_approval(tool, {'path': path.name, **args})+ finally:+ reset_edit_approval_requester(token)+ assert proposals and proposals[0].old_text == 'original'+ assert proposals[0].path == str(path)+ assert proposals[0].new_text == 'replacement'+ assert 'denied' in denied+ assert path.read_text() == 'original'