-
Notifications
You must be signed in to change notification settings - Fork 8
[nodejs] Clean up inputs/outputs for InvokeAgent spans based on new OTel format #137
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 4 commits
b4a7717
aa10faf
aa0f134
9ecfd83
a20c19a
7e9dc62
e99a70d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -250,24 +250,41 @@ export class OpenAIAgentsTraceProcessor implements TracingProcessor { | |||||||||||||||||||||
|
|
||||||||||||||||||||||
| if (inputObj && !this.suppressInvokeAgentInput) { | ||||||||||||||||||||||
| if (typeof inputObj === 'string') { | ||||||||||||||||||||||
| try { | ||||||||||||||||||||||
| const parsed = JSON.parse(inputObj as string); | ||||||||||||||||||||||
| if (Array.isArray(parsed)) { | ||||||||||||||||||||||
| otelSpan.setAttribute( | ||||||||||||||||||||||
| OpenTelemetryConstants.GEN_AI_INPUT_MESSAGES_KEY, | ||||||||||||||||||||||
| this.buildInputMessages(parsed) | ||||||||||||||||||||||
| ); | ||||||||||||||||||||||
| return; | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
| } catch { | ||||||||||||||||||||||
| // If parsing fails, fall back to raw string behavior | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
| otelSpan.setAttribute(OpenTelemetryConstants.GEN_AI_INPUT_MESSAGES_KEY, inputObj); | ||||||||||||||||||||||
| } else if (Array.isArray(inputObj)) { | ||||||||||||||||||||||
| // Store the complete _input structure as JSON | ||||||||||||||||||||||
| // build the input messages from array | ||||||||||||||||||||||
|
||||||||||||||||||||||
| // build the input messages from array | |
| // Build the input messages from array |
Copilot
AI
Jan 13, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The new private method 'buildInputMessages' is missing JSDoc documentation. Other private methods in this file have JSDoc comments explaining their purpose. Add a JSDoc comment describing what this method does, its parameters, and return value.
| /** | |
| * Builds a JSON-encoded representation of input messages for tracing. | |
| * Extracts the text content of user-role messages when available, otherwise | |
| * falls back to serializing the full input array. | |
| * | |
| * @param arr - Array of message objects containing a role and string content. | |
| * @returns A JSON string of user message contents, or the original array if no valid user content is found. | |
| */ |
Copilot
AI
Jan 13, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The variable name 'userTexts' is misleading in the context of 'buildOutputMessages'. This variable collects output texts (type 'output_text'), not user texts. Consider renaming to 'outputTexts' for clarity.
Uh oh!
There was an error while loading. Please reload this page.