getsentry / getsentry/sentry-javascript
AI integration deep proxies return new function references on every property access
- 主要语言
- TypeScript
- 星标
- 8.7k
- 派生
- 1.8k
- 平均合并
- 1 天 17 小时
- 30 天内合并 PR
- 515
描述
The `get` trap in AI integration deep proxies always returns a different value instead of memoizing bound/instrumented methods.
For example, `console.log(ai.run === ai.run)` prints `false` because each access creates a new function via `instrumentMethod(...)` or `value.bind(obj)`.
This pattern exists across multiple AI integrations:
- `packages/core/src/tracing/openai/index.ts` (`createDeepProxy`)
- `packages/core/src/tracing/anthropic-ai/index.ts` (`createDeepProxy`)
- `packages/core/src/tracing/google-genai/index.ts` (`createDeepProxy`)
Suggested fix: keep a `Map` in the closure to store bound/instrumented methods, rather than creating a new value on every `get`.
> Originally posted by @isaacs in https://github.com/getsentry/sentry-javascript/pull/22119#discussion_r3581015061
贡献指南
调研方向
Start at createDeepProxy in packages/core/src/tracing/openai/index.ts, packages/core/src/tracing/anthropic-ai/index.ts, and packages/core/src/tracing/google-genai/index.ts. Trace the get trap and the instrumentMethod or bind paths, then verify that repeated access to the same method returns the same reference while preserving instrumentation behavior.
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- typescript
- 领域
- observability
- Issue 类型
- 缺陷
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 活跃度
- 冷清
- 描述清晰度
- 基本清楚
- 新手友好度
- 68/100