Skip to content

feat: add internal policy gem foundation and controls#134

Open
Vigno04 wants to merge 7 commits intoNativu5:mainfrom
Vigno04:feature/gems-foundation
Open

feat: add internal policy gem foundation and controls#134
Vigno04 wants to merge 7 commits intoNativu5:mainfrom
Vigno04:feature/gems-foundation

Conversation

@Vigno04
Copy link
Copy Markdown
Contributor

@Vigno04 Vigno04 commented Mar 25, 2026

Summary

  • Add internal policy gem synchronization foundation
  • Add configurable gem controls in runtime config
  • Keep this phase internal only (no non-OpenAI public gems endpoints)

Context

I created an API similar to this before discovering the existence of this project, and I am now porting some of my features into it in incremental PRs.

Notes

  • This PR intentionally avoids exposing non-OpenAI-compatible gem endpoints.
  • Focus is internal foundation for future conditional policy usage.

@luuquangvu
Copy link
Copy Markdown
Collaborator

I don't understand the purpose of forcing internal gems when initializing the client you're working on. Can you explain it more clearly? Why would it block video or audio generation?

@Vigno04
Copy link
Copy Markdown
Contributor Author

Vigno04 commented Mar 25, 2026

The inplemented gem is an example but it could be used in many different ways, for example:

  1. You have an api endpoint that does not support video output, you can use the gem to try and block it
  2. and endpoint that does not support super long messages the gem can help you have shorter ones

In my specific api video out wasn't supported so i just ported the same message but there are almost infinite use cases and is very easily adaptable to the specific one a user might want, for now i kept only internal access but it could even be expanded

@luuquangvu
Copy link
Copy Markdown
Collaborator

I think it would be better to allow users to proactively enable gems, declare the gem name and prompt they want, and add them in configuration or environment variables as they wish. The default should be disabled, allowing advanced users to choose. Forcing a gem like that would affect many users because gems are essentially system prompts.

@Vigno04
Copy link
Copy Markdown
Contributor Author

Vigno04 commented Mar 25, 2026

Yeah, I know, above the default there is the explanation on how to add one, it's fairly easy, i just put an example there if the main contributor think a default could be useful to block currently not supported method or adding some info on how the data gets passed, adding them trough config is pretty easy to inplement

@Vigno04
Copy link
Copy Markdown
Contributor Author

Vigno04 commented Mar 25, 2026

For example sone endpoint could pass system prompt or tools but they are passed as text inside so maybe adding an explanation could be useful to Gemini, still it's very easy to add or remove gems and they gets automatically managed so it's just a design choice then

Copy link
Copy Markdown
Contributor

Copilot AI left a 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 an internal foundation for “policy gems” management/synchronization across Gemini clients, controlled via runtime configuration, intended to support future conditional policy usage without exposing public gem endpoints.

Changes:

  • Introduces gemini.gems configuration (enablement, fetch behavior, hidden-gem inclusion, policy-gem settings).
  • Adds PolicyGemSpec + sync_policy_gems() to upsert/deduplicate/cleanup server-managed policy gems.
  • Extends GeminiClientWrapper to initialize gem cache and sync policy gems during client init, plus helper methods for gem lookup and CRUD.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
config/config.yaml Adds gemini.gems settings to the default YAML config.
app/utils/config.py Adds Pydantic models for gemini.gems and gemini.gems.policies runtime config.
app/services/policy_gems.py New service implementing policy gem spec + sync/upsert/delete logic.
app/services/client.py Initializes gem cache/policy gems on client init; adds gem helper APIs and locking.
README.md Documents the new gemini.gems YAML snippet.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 6 out of 7 changed files in this pull request and generated 7 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@Vigno04
Copy link
Copy Markdown
Contributor Author

Vigno04 commented Apr 4, 2026

i think now it is finished if you want to look into it @Nativu5

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.

3 participants