Skip to content

feat: Instrument OpenAI agents api (openai.beta.agents) - #2471

Merged
Luca Forstner (lforst) merged 3 commits into
mainfrom
lforst/dum-e/beirut-1827d13283
Sep 14, 2026
Merged

Luca Forstner (lforst) merged 3 commits into
mainfrom
lforst/dum-e/beirut-1827d13283

Conversation

@lforst

Copy link
Copy Markdown
Member

No description provided.

Comment thread js/src/logger.ts
}

/** @internal */
export function _internalExportParentSynchronously(

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this seems like it has a lot more slop (reflect calls?) then exportSpanSynchronously had

Comment thread js/src/openai-agents-api.ts Outdated
value.root.length > 0 &&
typeof value.rootKey === "string" &&
value.rootKey.length > 0 &&
typeof value.rootParent === "string" &&

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should clean these conditionals up

Comment thread js/src/openai-agents-api.ts Outdated
try {
decoded = JSON.parse(token.slice(TOKEN_PREFIX.length));
} catch {
throw new TypeError("Invalid OpenAI Agents trace token");

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i dont think we need to be this defensive, also json parsing feels wrong

Comment on lines +188 to +199
const parent = _internalExportParentSynchronously(getSpanParentObject());
if (!parent) {
return encodeToken(null);
}
const parentComponents = SpanComponentsV4.fromStr(parent);
const rowId = newId();
const useLegacyIds = resolveUseLegacyUuidIds();
const spanId = useLegacyIds
? newId()
: newId().replaceAll("-", "").slice(0, 16);
const rootSpanId = useLegacyIds ? spanId : newId().replaceAll("-", "");
const root = new SpanComponentsV4({

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

feel like all of this should be a helper

@lforst
Luca Forstner (lforst) merged commit 95f0fa6 into main Sep 14, 2026
53 checks passed
@lforst
Luca Forstner (lforst) deleted the lforst/dum-e/beirut-1827d13283 branch September 14, 2026 15:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants