Skip to content

feat: upstream spec sync - #572

Open
howardjohn wants to merge 4 commits into
64bit:mainfrom
howardjohn:sync-openapi-2026-07-10-full
Open

feat: upstream spec sync#572
howardjohn wants to merge 4 commits into
64bit:mainfrom
howardjohn:sync-openapi-2026-07-10-full

Conversation

@howardjohn

Copy link
Copy Markdown
Contributor

Following the standard flow for the new sync. They seemed to change the openapi spec substantially as part of some structure change, hence the massive yaml diff. I spot checked all of the chat and responses changes and they look correct based on recent additions (explicit cache points, inline moderation, and Max reasoning)

@64bit

64bit commented Jul 11, 2026

Copy link
Copy Markdown
Owner

Please see openai/openai-openapi#557

@64bit 64bit added the spec sync Requires syncing new changes published in the upstream spec - openai-openapi label Jul 12, 2026
@howardjohn

Copy link
Copy Markdown
Contributor Author

@64bit thanks! I updated back to the github repo. Still failing a few test but working on it.

Medium,
High,
Xhigh,
Max,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

this would be useful for me.

howardjohn added a commit to agentgateway/agentgateway that referenced this pull request Aug 4, 2026
Fixes #2503

## Summary

Add provider-level OpenAI inline moderation configuration and inject it
into OpenAI chat completions and Responses requests.

This follows the same provider-config pattern as Bedrock guardrails,
where guardrail configuration is set by the gateway rather than trusted
from the client.

```yaml
backends:
- ai:
    provider:
      openAI:
        model: gpt-5
        moderation:
          # optional; defaults to omni-moderation-latest
          model: omni-moderation-latest
          policy:
            input:  { mode: block } # or score
            output: { mode: score }
```

The config structs match the shape proposed in
[async-openai#572](64bit/async-openai#572). No
dependency bump is needed because agentgateway already renders its own
OpenAI request types.

This PR wires `openAI.moderation` through:

- local config and generated schema docs
- xDS/proto
- Kubernetes API, CRD, and controller translation
- OpenAI request rendering for chat completions and Responses

Request injection happens during OpenAI request rendering before final
serialization. Translated request flows such as Anthropic-format client
to OpenAI backend are still covered by exposing typed translated OpenAI
requests from the conversion layer.

## Behavior

- `openAI.moderation.model` defaults to `omni-moderation-latest` when
omitted, including local config, xDS/proto decode, Kubernetes CRD
defaulting, and controller translation.
- Gateway-configured moderation overrides any client-supplied
`moderation` field, so clients cannot weaken the configured guardrail.
- Client-supplied `moderation` passes through unchanged when gateway
moderation is not configured, including unknown fields and future OpenAI
parameter shapes.
- Moderation results are preserved on passthrough OpenAI response flows,
including non-streaming and streaming responses.
- Existing external `/v1/moderations` prompt guard behavior is
unchanged.
- `Passthrough` and `Detect` routes are not modified, consistent with
other body-mutating LLM features.

Known out-of-scope gap: translated response flows do not surface OpenAI
moderation results back into non-OpenAI response formats in this PR.

## Notes for reviewers

- When moderation is not configured, OpenAI requests keep the direct
serialization path.
- When moderation is configured, the gateway inserts the moderation
object before final serialization; it no longer does a rendered-body
serialize -> parse -> serialize round trip.
- Local config moderation modes remain lower-case (`score` / `block`) to
match the OpenAI shape; Kubernetes API enum values use `Score` / `Block`
per repo convention and are translated to proto enum values by the
controller.
- Most of the `api/resource.pb.go` diff is generated churn from adding a
nested proto enum, which renumbers subsequent enum indexes.

## Testing

New tests cover:

- local config deserialization and defaulting
- controller golden output and defaulting
- request injection for completions, Responses, and translated request
flows
- client override behavior
- unknown client-field passthrough
- non-streaming response preservation
- streaming response chunk preservation

Validation run after rebasing onto current `upstream/main` (`a1d420a3`):

- `make generate-apis`
- `git diff --exit-code -- api/resource.pb.go api/resource_json.gen.go
controller/api/v1alpha1/agentgateway/zz_generated.deepcopy.go
controller/install/helm/agentgateway-crds/templates/agentgateway.dev_agentgatewaybackends.yaml`
- `git diff --check upstream/main..HEAD`
- `python3 -m json.tool schema/config.json`
- `go build ./controller/pkg/syncer/backend`
- `go vet ./controller/pkg/syncer/backend`
- `go test ./controller/api/v1alpha1/agentgateway -run TestNonExistent
-count=0`
- `go test ./controller/pkg/syncer/backend -run
TestBuildAIBackend/Valid_OpenAI_backend_with_inline_moderation -count=1`
- `go test ./controller/pkg/syncer/backend -count=1`
- `make -C controller analyze`

---------

Signed-off-by: GuruduGanesh <ganesh.gurudu@gmail.com>
Signed-off-by: John Howard <john.howard@solo.io>
Co-authored-by: John Howard <john.howard@solo.io>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

spec sync Requires syncing new changes published in the upstream spec - openai-openapi

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants