Skip to content

Conversation

@sergei-bronnikov
Copy link

@sergei-bronnikov sergei-bronnikov commented Oct 7, 2025

https://bugtracker.codiodev.com/issue/codio-17073/Update-Bricks-LLM-to-Support-GPT-5-API-Calls

Summary by CodeRabbit

  • New Features

    • Added proxy support for OpenAI Responses API with non-streaming and streaming modes.
    • Displays accurate usage metrics and cost calculations, including tool-call costs.
    • Enforces policy checks for background usage and allowed tools.
    • Propagates response headers and enhances logging/telemetry with privacy-aware controls.
  • Chores

    • Upgraded Go toolchain and base Docker images.
    • Updated major dependencies (e.g., OpenAI client, Gin, AWS SDK, Redis, Datadog) for performance and compatibility.
    • General dependency cleanup and reorganization.

@destitutus
Copy link
Member

@coderabbitai full review, summary

@coderabbitai
Copy link

coderabbitai bot commented Oct 8, 2025

@destitutus: I'll perform a full review of all the changes in this PR and regenerate the summary for the GPT-5 support implementation.

✅ Actions performed

Summary regeneration triggered.

@coderabbitai
Copy link

coderabbitai bot commented Oct 8, 2025

Walkthrough

Updates Go/Docker base versions and dependencies, adds OpenAI Responses API support. Introduces request/response types, cost estimation for responses and tools, middleware validations, new routes, logging, and a proxy handler with non‑streaming and SSE streaming support.

Changes

Cohort / File(s) Summary
Build images
Dockerfile.dev, Dockerfile.prod
Bump base build image from golang:1.23.2 to golang:1.24.7; no other Dockerfile changes.
Dependencies
go.mod
Upgrade Go toolchain to 1.24.7; update multiple direct/indirect deps (AWS SDK v2, Gin, DataDog, Redis, astisub, OpenAI clients, OTel, Prometheus, protobuf, x/*); add new indirects; reorganize require blocks; no module path changes.
Authenticator import order
internal/authenticator/authenticator.go
Reorders an import within the block; no functional changes.
OpenAI provider: costs and types
internal/provider/openai/cost.go, internal/provider/openai/types.go
Add response/tool cost maps, AllowedTools, and cost estimation methods for responses and tool calls; introduce ResponseRequest and ResponseRequestToolUnion types.
Proxy: OpenAI responses support
internal/server/web/proxy/middleware.go, internal/server/web/proxy/proxy.go, internal/server/web/proxy/responses.go
Add routes /api/providers/openai/v1/responses[...]; middleware parses/validates Responses requests and extends estimator interface; implement handler with non‑streaming and SSE streaming proxying, header propagation, telemetry, and cost/token accounting; add conditional request/response logging.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant C as Client
  participant P as Proxy (Gin)
  participant H as Responses Handler
  participant O as OpenAI Responses API
  participant E as Estimator

  Note over P,H: Non-streaming flow
  C->>P: POST /api/providers/openai/v1/responses
  P->>H: getResponsesHandler(...)
  H->>O: POST /v1/responses (proxied)
  O-->>H: 200 + JSON body
  H->>E: EstimateResponseApiTotalCost(model, usage)
  H->>E: EstimateResponseApiToolCallsCost(tools, model)
  E-->>H: Costs
  H-->>P: Status + body + headers
  P-->>C: Forwarded response
Loading
sequenceDiagram
  autonumber
  participant C as Client
  participant P as Proxy (Gin)
  participant H as Responses Handler
  participant O as OpenAI Responses API (SSE)
  participant E as Estimator

  Note over P,H: Streaming (SSE) flow
  C->>P: POST /api/providers/openai/v1/responses (stream=true)
  P->>H: getResponsesHandler(...)
  H->>O: POST /v1/responses (Accept: text/event-stream)
  loop SSE events
    O-->>H: data: {delta/...}
    H-->>C: Stream line
    Note right of H: Accumulate content and usage
  end
  H->>E: EstimateResponseApiTotalCost(model, usage)
  H->>E: EstimateResponseApiToolCallsCost(tools, model)
  E-->>H: Costs
  H-->>P: Finalize metrics/context
  P-->>C: Stream end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~75 minutes

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch 17073_GPT_5_support

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a51ccb9 and f2af8a0.

⛔ Files ignored due to path filters (1)
  • go.sum is excluded by !**/*.sum
📒 Files selected for processing (9)
  • Dockerfile.dev (1 hunks)
  • Dockerfile.prod (1 hunks)
  • go.mod (1 hunks)
  • internal/authenticator/authenticator.go (1 hunks)
  • internal/provider/openai/cost.go (6 hunks)
  • internal/provider/openai/types.go (1 hunks)
  • internal/server/web/proxy/middleware.go (4 hunks)
  • internal/server/web/proxy/proxy.go (3 hunks)
  • internal/server/web/proxy/responses.go (1 hunks)

Comment @coderabbitai help to get the list of available commands and usage tips.

destitutus
destitutus previously approved these changes Oct 8, 2025
@sergei-bronnikov sergei-bronnikov merged commit ca86bd2 into main Oct 20, 2025
2 checks passed
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