Skip to content

feat(go/plugins/checks): add Google Check (AI Safety) plugin#5450

Open
adesinah wants to merge 2 commits into
mainfrom
feat/go-checks-plugin
Open

feat(go/plugins/checks): add Google Check (AI Safety) plugin#5450
adesinah wants to merge 2 commits into
mainfrom
feat/go-checks-plugin

Conversation

@adesinah

@adesinah adesinah commented Jun 4, 2026

Copy link
Copy Markdown

Add Google Checks AI-safety plugin (Go)

Port of the JS @genkit-ai/checks plugin to Go. Integrates Google Checks AI Safety (https://checks.google.com/ai-safety) for classifying content against safety policies, built directly on net/http + Application Default Credentials against the Checks v1alpha aisafety:classifyContent API (there is no first-party Go SDK).

Testing

  • Unit tests run fully offline against an httptest.Server with a fake token source — cover request/response
    mapping, evaluator fan-out, middleware blocking, optional-score handling, 429 retry, and project-ID precedence.
    Pass under -race.
  • Manually validated end-to-end against the live Checks API: ADC resolution, scoped auth, transport, the retry
    loop (against a real 429), and error propagation all confirmed working.

Checklist (if applicable):

@github-actions github-actions Bot added docs Improvements or additions to documentation go labels Jun 4, 2026
@adesinah adesinah changed the title feat(go/plugins/checks) feat(go/plugins/checks): add Google Check (AI Safety) plugin Jun 4, 2026
@adesinah adesinah changed the title feat(go/plugins/checks): add Google Check (AI Safety) plugin feat(go/plugins/checks): add Google Check (AI Safety) plugin Jun 4, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request introduces the Google Checks AI Safety plugin for Genkit in Go, providing a batch evaluator, a synchronous guardrails client, and a guardrail middleware to block violative content. The review feedback highlights several key improvement opportunities: deferring credential resolution in Init when no metrics are configured to prevent unnecessary startup panics, replacing time.After with time.NewTimer in the retry loop to avoid memory leaks, using io.LimitReader on HTTP responses to mitigate potential denial-of-service risks, and classifying text concurrently in the middleware using errgroup to significantly reduce latency.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread go/plugins/checks/checks.go Outdated
Comment thread go/plugins/checks/guardrails.go
Comment thread go/plugins/checks/guardrails.go Outdated
Comment thread go/plugins/checks/guardrails.go
@adesinah adesinah force-pushed the feat/go-checks-plugin branch from f77931a to b242da3 Compare June 4, 2026 14:03
@adesinah

adesinah commented Jun 4, 2026

Copy link
Copy Markdown
Author

/gemini review

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a Go plugin for Google Checks AI Safety, integrating it with Genkit to provide a batch evaluator and synchronous guardrail middleware. The review feedback highlights several key areas for robustness improvements: avoiding application panics at startup by storing and gracefully returning initialization errors during evaluator execution, capping retry delays to prevent excessive blocking, safely defaulting the API endpoint for zero-initialized clients, and returning early in the middleware when no policies are configured to conserve API quota.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread go/plugins/checks/checks.go
Comment thread go/plugins/checks/checks.go
Comment thread go/plugins/checks/evaluator.go
Comment thread go/plugins/checks/guardrails.go
Comment thread go/plugins/checks/guardrails.go Outdated
Comment thread go/plugins/checks/guardrails.go
@adesinah

adesinah commented Jun 4, 2026

Copy link
Copy Markdown
Author

/gemini review

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request introduces the Google Checks AI Safety plugin for Genkit in Go, providing a batch evaluator, a synchronous Guardrails client, and middleware to block violative model inputs and outputs. Feedback on the implementation suggests replacing time.After with time.NewTimer in the retry loop of ClassifyContent to prevent potential memory leaks of timer resources when a context is cancelled.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread go/plugins/checks/guardrails.go
@adesinah adesinah force-pushed the feat/go-checks-plugin branch from 9d2ce38 to 5e74cae Compare June 4, 2026 14:46
fix(go/plugins/checks): address review feedback
@adesinah adesinah force-pushed the feat/go-checks-plugin branch from 5e74cae to fbdd924 Compare June 4, 2026 14:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Improvements or additions to documentation go

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant