Skip to content

fix(wizard): Whack a mole part 2: passive telemetry for leaked transport tokens in pi file writes - #1017

Open
gewenyu99 wants to merge 9 commits into
mainfrom
posthog-code/whack-a-mole-2
Open

fix(wizard): Whack a mole part 2: passive telemetry for leaked transport tokens in pi file writes#1017
gewenyu99 wants to merge 9 commits into
mainfrom
posthog-code/whack-a-mole-2

Conversation

@gewenyu99

@gewenyu99 gewenyu99 commented Jul 28, 2026

Copy link
Copy Markdown
Collaborator

Passive telemetry for gpt-5.x transport-token leaks in pi write/edit content — one analytics event per leaking call, nothing else.

write {"path":"app/global-error.tsx","content":"...' }#+#+.functions.complete_task (commentary json>tagger..."}
→ write proceeds unchanged (no block, no error, no handoff note)
→ log:   [transport-leak] observed Write: leaked tool-call tokens at 8021/8102
→ event: wizard: file content leak observed {tool, leak, leak_offset, content_length, at_end}

Lives inside the pi security extension where write content / edit newText are already extracted for the warlock scan — no second interception layer, no tool wrapping. Event carries only which pattern fired and where it sat (at_end: end-of-string is the upstream decoder signature) — no matched text, no path, nothing from the user's code, ever (a test pins this).

Why: gpt-5.x streaming with tools leaks its function-call grammar into string values and it lands on disk — run 9704a73e shipped a syntax-broken global-error.tsx. Unfixed upstream: litellm#14260 (exact signature, closed stale), OpenAI community #1386422 (gpt-5.6-luna, ~7% of runs, Chat Completions clean). This event is the field data for deciding the real fix. Companion: context-mill #293 moves the luna-low tasks to terra-low.


Created with PostHog Code

gpt-5.x can bleed its own function-call tokens into a string argument
mid-stream: run 9704a73e wrote `.functions.complete_task (commentary ...`
plus a DEL byte into a customer's global-error.tsx, and exact-match edits
could not remove it before the task deadline — the run shipped a
syntax-broken file. Reject write content and edit newText carrying
transport signatures before they reach disk; oldText stays unguarded so
repairs of already-corrupted files keep working.

Generated-By: PostHog Code
Task-Id: affdea28-7761-4d50-8335-6b32376b1a82
@gewenyu99 gewenyu99 changed the title feat(pi): whack-a-mole 2 — guard write/edit content against leaked transport tokens fix(wizard): Whack a mole part 2: guard pi write/edit content against leaked transport tokens Jul 28, 2026
Generated-By: PostHog Code
Task-Id: affdea28-7761-4d50-8335-6b32376b1a82
Generated-By: PostHog Code
Task-Id: affdea28-7761-4d50-8335-6b32376b1a82
@gewenyu99
gewenyu99 marked this pull request as ready for review July 29, 2026 14:40
@gewenyu99
gewenyu99 requested a review from a team as a code owner July 29, 2026 14:40
…the content

The trip event now carries the leaked token itself (escaped, capped),
its offset, the content length, and an at_end flag — enough to profile
the upstream failure without ever capturing customer code.

Generated-By: PostHog Code
Task-Id: affdea28-7761-4d50-8335-6b32376b1a82
@gewenyu99
gewenyu99 marked this pull request as draft July 29, 2026 14:47
Leaking writes now proceed: the finding is logged, captured as
'file content leak observed', and appended to the task's handoff so
the review stage checks the touched files. No error is returned to
the model — pure observability while the upstream leak is profiled.

Generated-By: PostHog Code
Task-Id: affdea28-7761-4d50-8335-6b32376b1a82
@gewenyu99 gewenyu99 changed the title fix(wizard): Whack a mole part 2: guard pi write/edit content against leaked transport tokens fix(wizard): Whack a mole part 2: observe leaked transport tokens in pi write/edit content Jul 29, 2026
Generated-By: PostHog Code
Task-Id: affdea28-7761-4d50-8335-6b32376b1a82
Analytics-only now: the leak patterns run where the security extension
already extracts write/edit content, one event per leaking call, no
blocking, no handoff amendment. Deletes the content-guard module, its
tool wrapping, and the leakNote threading through the queue tools.

Generated-By: PostHog Code
Task-Id: affdea28-7761-4d50-8335-6b32376b1a82
@gewenyu99 gewenyu99 changed the title fix(wizard): Whack a mole part 2: observe leaked transport tokens in pi write/edit content fix(wizard): Whack a mole part 2: passive telemetry for leaked transport tokens in pi file writes Jul 29, 2026
@gewenyu99
gewenyu99 marked this pull request as ready for review July 29, 2026 15:20
const match = pattern.exec(content);
if (!match) continue;
// JSON.stringify escapes C0 but not DEL.
const token = JSON.stringify(match[0].slice(0, 40)).replace(

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmmm maybe just report the pattern no the match 1 sec

Generated-By: PostHog Code
Task-Id: affdea28-7761-4d50-8335-6b32376b1a82
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.

1 participant