Skip to content

[codex] Add codex-api client factory#21437

Closed
pakrym-oai wants to merge 1 commit intomainfrom
pakrym/api-client-factory
Closed

[codex] Add codex-api client factory#21437
pakrym-oai wants to merge 1 commit intomainfrom
pakrym/api-client-factory

Conversation

@pakrym-oai
Copy link
Copy Markdown
Collaborator

Why

codex-core creates several codex-api REST clients from the same provider/auth setup, but each call site constructed the concrete client directly. This makes it harder to add shared client creation behavior without touching every client type or turning ModelClient into the owner of unrelated services.

What changed

  • Added an ApiClientFactory plus an ApiClient trait implemented directly on the codex-api client types used by core.
  • Stored the factory as a peer service on SessionServices, built from the same shared model provider as ModelClient.
  • Routed compact, memories, realtime-call, and Responses streaming paths through the factory so call sites can create clients generically.
  • Kept ModelClient from owning or vending the factory; session construction creates both services from the shared provider.

Validation

  • cargo check -p codex-core
  • just fix -p codex-core
  • just bazel-lock-update
  • just bazel-lock-check

@pakrym-oai pakrym-oai closed this May 7, 2026
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.

1 participant