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
homanp
changed the title
add support for passing custom instructions to system prompt
feat: add support for passing custom instructions to system prompt
Dec 1, 2025
Pull Request Review: Add support for passing custom instructions to system prompt
Summary
This PR adds support for a system_prompt parameter across all interfaces (CLI, TypeScript SDK, Python SDK, MCP server) to allow users to customize guard behavior. The implementation is consistent, well-documented, and follows existing patterns.
✅ Strengths
Code Quality
Consistent implementation across all platforms (CLI, SDKs, MCP)
Clean code that follows existing patterns and conventions
Proper parameter handling with validation and error messages
Backwards compatible - the parameter is optional everywhere
Documentation
Comprehensive documentation updates across all platforms
Clear examples showing how to use the new feature
CHANGELOG properly updated with detailed descriptions
API documentation (OpenAPI spec) correctly updated
🔍 Findings
Code Quality & Best Practices
1. TypeScript SDK (sdk/typescript/src/index.ts)
✅ Proper interface design with GuardOptions extending GuardCallbacks
✅ Consistent parameter passing across all three input types (file, URL, text)
✅ Good use of conditional object building to avoid undefined values
⚠️Minor: Type assertion as any on line 126 (CLI) and 152 (MCP) - consider creating proper types
Using as any bypasses TypeScript's type checking. While this works, it reduces type safety.
Recommendation:
// In sdk/typescript/src/index.ts, export GuardOptions properlyexportinterfaceGuardOptionsextendsGuardCallbacks{systemPrompt?: string;}// Then in CLI and MCP, import and use the typeimporttype{GuardOptions}from"superagent-ai";constoptions: GuardOptions={};
2. Documentation Encoding Issue (Minor)
Location: docs/content/docs/cli.mdx:393, 406
There appear to be encoding issues in the documentation:
=� BLOCKED: [reasoning] // Should be an emoji
=� Superagent Guard blocked... // Encoding corruption
Recommendation: Ensure proper UTF-8 encoding for emoji characters in documentation.
API Design Considerations
✅ Well-designed API extension
Parameter naming is consistent (system_prompt in API/JSON, systemPrompt in TypeScript, system_prompt in Python)
Optional parameter doesn't break existing code
Clear and descriptive parameter name
Follows existing patterns in the codebase
📝 Recommendations
High Priority
Add test coverage for the new systemPrompt parameter across all SDKs
Fix documentation encoding issues for emoji characters
Medium Priority
Improve type safety by removing as any assertions and properly typing options
Document behavior when system_prompt conflicts with default guard behavior (if applicable)
Low Priority
Consider adding validation for system_prompt length limits (if any exist on the API side)
Consider adding examples in README files showing real-world use cases
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Add support for passing custom instructions to the guard model
Related Issue
Fixes #1082 #1081
Checklist