getsentry / getsentry/sentry-javascript

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

Aperta
#22,355 5 commenti 2 reazioni 0 assegnatari Vedi su GitHub
agents javascript Task Tech Debt Type: Improvement
Lingua principale
TypeScript
Stelle
8.7k
Fork
1.8k
Merge medio
1g 17h
PR unite (30g)
515

Descrizione

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

Guida per i contributori

Apri la guida per i contributori

Direzione di ricerca

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.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
typescript
Ambito
observability
Tipo di issue
Bug
Difficoltà
3/5
Tempo stimato
1-2 giorni
Stato di attività
Tranquilla
Chiarezza
Abbastanza chiara
Idoneità per principianti
68/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.