WEB-5004: attach referenced file contents to tool telemetry#195
Draft
pugazhendhi-m wants to merge 1 commit into
Draft
WEB-5004: attach referenced file contents to tool telemetry#195pugazhendhi-m wants to merge 1 commit into
pugazhendhi-m wants to merge 1 commit into
Conversation
Add a uniform `file_content` field to the PreToolUse and PostToolUse/Stop
payloads of all five coding-tool hooks (claude-code, cursor, codex, copilot,
augment). For a file tool (Read/Write/Edit/MCP) the hook reads the referenced
file and attaches `file_content = [{path, content, truncated}]`.
- Shared helpers (_cap_file_text, _resolve_and_read_file, _make_file_entry,
_attach_file_content) are byte-identical across all five hooks.
- Write reuses the inline content (file may not exist on disk yet); Read/Edit
read from disk, resolving relative paths against cwd.
- 64KB per-file cap with a per-entry `truncated` flag.
- Fail-open: missing/binary/non-UTF8/permission-denied/directory/unresolvable
paths are silently skipped; no new imports; never raises or blocks the editor.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GrSjwjtXsfxcBpANpkqQg4
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.
What
Adds a uniform
file_contentfield to the PreToolUse and PostToolUse/Stop telemetry payloads of all five coding-tool hooks (claude-code, cursor, codex, copilot, augment). For a file tool (Read/Write/Edit/MCP), the hook reads the referenced file and attaches:Uniform key + shape across every tool (single-file = 1-element list) so the gateway/backend can consume it identically.
How
_cap_file_text,_resolve_and_read_file,_make_file_entry,_attach_file_content) are byte-identical across all 5 hooks (per-tool parity).content(file may not exist on disk yet); Read/Edit read from disk, resolving relative paths againstcwd(claude/cursor paths are already absolute).truncatedflag.pre_tool_use_data.metadata) and POST (end-of-turn tool_use entries).Safety / fail-open
\x00) / non-UTF8 / permission-denied / directory / unresolvable-relative-path all silently skip.os.path.isfileexcludes fifos/devices/sockets (no hangs);read(cap+1)bounds huge files.os) — nobinary/unbound-hook.specchange needed.Scope notes
Follow-up (separate, gateway/backend — NOT this repo)
Gateway DLP must redact the new
file_contentfield (not just prompt bodies), otherwise.env/keys read by the agent get stored server-side. Flagged by both/csoand/reviewas the one real governance item of always-on.Testing
python3 -m py_compileclean.🤖 Generated with Claude Code
https://claude.ai/code/session_01GrSjwjtXsfxcBpANpkqQg4