getsentry / getsentry/sentry-javascript
AI integration deep proxies return new function references on every property access
- Ngôn ngữ chính
- TypeScript
- Star
- 8.7k
- Fork
- 1.8k
- Merge trung bình
- 1 ngày 17 giờ
- Pull request đã merge (30 ngày)
- 515
Mô tả
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
Hướng dẫn đóng góp
Hướng nghiên cứu
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.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- typescript
- Lĩnh vực
- observability
- Loại issue
- Lỗi
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức độ hoạt động
- Ít trao đổi
- Độ rõ ràng
- Khá rõ ràng
- Mức phù hợp với người mới
- 68/100