fix: distinguish phase file writes from reads in PostToolUse hook

- Parse tool_name via jq: Write tool checks file_path match,
  Bash tool checks for redirect operator (>) with phase file path
- Reads (cat, head) no longer trigger false-positive markers
- Split guard into separate statements for clarity
- Move marker cleanup inside hook-install guard
- Expand tests: 5 cases covering Bash write, Write tool, Bash read,
  unrelated Bash, and Write to different file

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
openhands 2026-03-19 18:14:49 +00:00
parent ac04dc29a6
commit 809dd93c3b
3 changed files with 67 additions and 18 deletions

View file

@ -110,8 +110,8 @@ create_agent_session() {
}
}' > "$settings"
fi
rm -f "$phase_marker"
fi
rm -f "$phase_marker"
fi
rm -f "$idle_marker"