> ## Documentation Index
> Fetch the complete documentation index at: https://wb-21fd5541-sweeps-updates.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# instrumentOpenAIAgents

> TypeScript SDK 레퍼런스

export const GitHubLink = ({url, compact = false}) => <a href={url} target="_blank" rel="noopener noreferrer" className={compact ? "source-link" : "github-source-link"}>
    {compact ? "소스 보기" : <>
    <svg width="20" height="20" viewBox="0 0 24 24" fill="currentColor" xmlns="http://www.w3.org/2000/svg">
      <path d="M12 0C5.37 0 0 5.37 0 12c0 5.31 3.435 9.795 8.205 11.385.6.105.825-.255.825-.57 0-.285-.015-1.23-.015-2.235-3.015.555-3.795-.735-4.035-1.41-.135-.345-.72-1.41-1.23-1.695-.42-.225-1.02-.78-.015-.795.945-.015 1.62.87 1.845 1.23 1.08 1.815 2.805 1.305 3.495.99.105-.78.42-1.305.765-1.605-2.67-.3-5.46-1.335-5.46-5.925 0-1.305.465-2.385 1.23-3.225-.12-.3-.54-1.53.12-3.18 0 0 1.005-.315 3.3 1.23.96-.27 1.98-.405 3-.405s2.04.135 3 .405c2.295-1.56 3.3-1.23 3.3-1.23.66 1.65.24 2.88.12 3.18.765.84 1.23 1.905 1.23 3.225 0 4.605-2.805 5.625-5.475 5.925.435.375.81 1.095.81 2.22 0 1.605-.015 2.895-.015 3.3 0 .315.225.69.825.57A12.02 12.02 0 0024 12c0-6.63-5.37-12-12-12z" />
    </svg>
    GitHub 소스 코드
      </>}
  </a>;

```ts theme={null}
instrumentOpenAIAgents(): Promise<boolean>
```

<GitHubLink url="https://github.com/wandb/weave/blob/7c9efdc9fe05ffcaf2430dd652ef9bc5b3ffdfaa/sdks/node/src/integrations/openai.agent.ts#L169" />

패키지를 사용할 수 있으면 OpenAI Agents에 Weave tracing을 수동으로 등록합니다.

**참고: 일반적으로는 이 함수를 호출할 필요가 없습니다!** Weave를 임포트하면 OpenAI Agents는
모듈 로더 훅을 통해 자동으로 계측됩니다. 이 함수는 자동 계측이 작동하지 않는
예외적인 경우(예: 동적 임포트, 훅을 우회하는 번들러)를 위해 제공됩니다.

이 함수는 사용자의 node\_modules에서 @openai/agents를 동적으로 임포트하려고 시도하고
TracingProcessor를 등록합니다. 패키지가 설치되어 있지 않으면 오류를 발생시키지 않고
false를 반환합니다.

<div id="returns">
  ## 반환값
</div>

`Promise`\<`boolean`>

`Promise<boolean>` - 등록에 성공하면 `true`, `@openai/agents`를 사용할 수 없으면 `false`

<div id="examples">
  ## 예시
</div>

```typescript twoslash theme={null}
// @noErrors
// ✅ 권장 방법: Weave를 임포트하기만 하면 계측이 자동으로 수행됩니다!
import * as weave from 'weave';
await weave.init('my-project');

// OpenAI Agents는 훅을 통해 이미 계측되어 있으므로 별도의 설정이 필요하지 않습니다
import { Agent } from '@openai/agents';
const agent = new Agent({ ... });
await agent.run(input); // Weave에서 자동으로 트레이스됩니다
```

```typescript twoslash theme={null}
// @noErrors
// ⚠️ 자동 훅이 작동하지 않는 엣지 케이스에서만 필요합니다
import { instrumentOpenAIAgents } from 'weave';

const registered = await instrumentOpenAIAgents();
if (!registered) {
  console.log('OpenAI Agents not found - install @openai/agents to enable tracing');
}
```

<div id="remarks">
  ## 참고
</div>

**자동 계측이 작동하는 방식**: Weave를 임포트하면 `addCJSInstrumentation()` 및 `addESMInstrumentation()`을 통해 모듈 로더
훅을 등록합니다. 이후 코드에서 `@openai/agents`를 임포트하면, 이 훅이 해당 임포트를 가로채
모듈에 Weave tracing을 자동으로 패치합니다. 이 과정은 자동으로 투명하게 처리되므로 사용자가 별도로 할 일은 없습니다!

**이 함수를 사용해야 하는 경우**: 자동 계측이 실패할 때만 이 함수를 사용하세요. 예를 들면 다음과 같습니다.

* 모듈 훅을 우회하는 동적 임포트를 사용하는 경우
* import-in-the-middle을 지원하지 않는 번들러를 사용하는 경우
* 계측이 수행되는 시점을 명시적으로 제어해야 하는 경우

**맞춤형 프로세서 로직을 위한 대안**: 맞춤형 tracing 동작이 필요한 경우,
`createOpenAIAgentsTracingProcessor()`를 사용해 수동으로 등록하세요:

```typescript twoslash theme={null}
// @noErrors
import { addTraceProcessor } from '@openai/agents';
import { createOpenAIAgentsTracingProcessor } from 'weave';

const processor = createOpenAIAgentsTracingProcessor();
addTraceProcessor(processor);
```
