-
Notifications
You must be signed in to change notification settings - Fork 3
Add safety header to LLM calls #15
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
Conversation
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.
Pull Request Overview
Adds a safety identifier to LLM calls so requests can be associated with a guardrails identifier.
- Injects safety_identifier into responses and chat payloads
- Uses a ts-ignore to bypass missing OpenAI type definitions
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 5 comments.
File | Description |
---|---|
src/resources/responses/responses.ts | Adds safety_identifier to the responses request payload. |
src/resources/chat/chat.ts | Adds safety_identifier to the chat request payload. |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
// @ts-ignore - safety_identifier is not defined in OpenAI types yet | ||
safety_identifier: 'oai-guardrails-ts', | ||
}), |
Copilot
AI
Oct 15, 2025
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.
[nitpick] Avoid using // @ts-ignore here. Prefer defining a local type augmentation (e.g., extend the request params type with safety_identifier) or use // @ts-expect-error to ensure we revisit this when types change; this prevents silently suppressing unrelated type errors.
// @ts-ignore - safety_identifier is not defined in OpenAI types yet | |
safety_identifier: 'oai-guardrails-ts', | |
}), | |
safety_identifier: 'oai-guardrails-ts', | |
} as Omit<OpenAI.Responses.ResponseCreateParams, 'input' | 'model' | 'stream' | 'tools'> & { input: typeof modifiedInput; model: typeof model; stream: typeof stream; tools?: typeof tools; safety_identifier: string }), |
Copilot uses AI. Check for mistakes.
model, | ||
stream, | ||
...kwargs, | ||
// @ts-ignore - safety_identifier is not defined in OpenAI types yet |
Copilot
AI
Oct 15, 2025
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.
[nitpick] Same as in responses: replace // @ts-ignore with a typed approach (type augmentation or // @ts-expect-error) so we don't mask other potential type issues.
// @ts-ignore - safety_identifier is not defined in OpenAI types yet | |
// @ts-expect-error - safety_identifier is not defined in OpenAI types yet |
Copilot uses AI. Check for mistakes.
// @ts-ignore - safety_identifier is not defined in OpenAI types yet | ||
safety_identifier: 'oai-guardrails-ts', |
Copilot
AI
Oct 15, 2025
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.
PR title mentions adding a 'safety header', but this change adds a request payload field. Please either adjust the title/description or implement this as an HTTP header in the request layer if a header is required.
Copilot uses AI. Check for mistakes.
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.
Thank you!
Added
safety_identifier: 'oai-guardrails-ts'
to the LLM calls