You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- Learn about pipeline configuration in our [quickstart](./quickstart.md)
113
113
- For more details on the OpenAI Agents SDK, refer to the [Agent SDK documentation](https://openai.github.io/openai-agents-js/).
114
+
115
+
## Token Usage Tracking
116
+
117
+
!!! warning "JavaScript Agents SDK Limitation"
118
+
The JavaScript Agents SDK (`@openai/agents`) does not currently return guardrail results in the `RunResult` object. This means `totalGuardrailTokenUsage()` cannot retrieve token counts from Agents SDK runs.
119
+
120
+
**For token usage tracking, use `GuardrailsOpenAI` instead of `GuardrailAgent`.** The Python Agents SDK does support this feature.
121
+
122
+
When a guardrail **triggers** (throws `InputGuardrailTripwireTriggered` or `OutputGuardrailTripwireTriggered`), token usage IS available in the error's result object:
123
+
124
+
```typescript
125
+
try {
126
+
const result =awaitRunner.run(agent, userInput);
127
+
} catch (error) {
128
+
if (error.constructor.name==='InputGuardrailTripwireTriggered') {
For full token usage tracking across all guardrail runs (passing and failing), use the `GuardrailsOpenAI` client instead - see the [quickstart](./quickstart.md#token-usage-tracking) for details.
**Note:** The JavaScript Agents SDK (`@openai/agents`) does not currently populate guardrail results in the `RunResult` object, so `totalGuardrailTokenUsage()` will return empty results for Agents SDK runs.
260
+
261
+
### Per-Guardrail Usage
262
+
263
+
Each guardrail result includes its own `token_usage` entry:
0 commit comments