Skip to content

fix(core): Preserve AI proxy property references#22474

Open
psh4607 wants to merge 1 commit into
getsentry:developfrom
psh4607:fix/ai-proxy-stable-references
Open

fix(core): Preserve AI proxy property references#22474
psh4607 wants to merge 1 commit into
getsentry:developfrom
psh4607:fix/ai-proxy-stable-references

Conversation

@psh4607

@psh4607 psh4607 commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

AI integration deep proxies now reuse nested proxies and wrapped methods while the underlying property is unchanged. This makes repeated property access referentially stable for OpenAI and Google GenAI clients, while still refreshing a cached entry when an SDK property is replaced.

Anthropic is unchanged because the current develop implementation instruments its methods in place and no longer uses this deep-proxy path.

Root cause

Each get trap created a new nested proxy, instrumented wrapper, or bound function on every access. Caching functions alone would not cover repeated nested access because the intermediate proxies were also recreated.

Focused regression coverage checks stable nested objects, instrumented methods, proxy-result methods, and non-instrumented bound methods.

Fixes #22355

@psh4607
psh4607 force-pushed the fix/ai-proxy-stable-references branch 3 times, most recently from 1445eaf to e002cf1 Compare July 22, 2026 04:25
@psh4607
psh4607 marked this pull request as ready for review July 22, 2026 04:54
@psh4607
psh4607 force-pushed the fix/ai-proxy-stable-references branch from e002cf1 to 8d957e5 Compare July 22, 2026 05:50
@psh4607
psh4607 force-pushed the fix/ai-proxy-stable-references branch from 8d957e5 to 681a0f6 Compare July 22, 2026 13:11
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.

AI integration deep proxies return new function references on every property access

1 participant