Skip to content

refactor(BA-5961): introduce AppProxyClientRegistry for app-proxy domain clients#11491

Closed
jopemachine wants to merge 8 commits into
mainfrom
refactor/BA-5961-app-proxy-client-registry
Closed

refactor(BA-5961): introduce AppProxyClientRegistry for app-proxy domain clients#11491
jopemachine wants to merge 8 commits into
mainfrom
refactor/BA-5961-app-proxy-client-registry

Conversation

@jopemachine
Copy link
Copy Markdown
Member

Summary

  • Add BaseAppProxyDomainClient mirroring BaseDomainClient, and refactor DeploymentChatClient from a BackendAIAppProxyClient subclass to a domain client composed over one.
  • Introduce AppProxyClientRegistry (client/v2/approxy_registry.py) with the same shape as BackendAIClientRegistry / V2ClientRegistry: create() / close() lifecycle and @cached_property accessors (currently deployment_chat).
  • Add create_appproxy_registry CLI helper alongside create_v2_registry, and switch ./bai deployment chat to consume the registry instead of instantiating DeploymentChatClient directly.
  • Update the unit test fixture to inject a BackendAIAppProxyClient into DeploymentChatClient via the new constructor.

Resolves BA-5961.

@jopemachine jopemachine added the skip:changelog Make the action workflow to skip towncrier check label May 6, 2026
@github-actions github-actions Bot added size:L 100~500 LoC comp:client Related to Client component comp:cli Related to CLI component labels May 6, 2026
@jopemachine jopemachine removed the skip:changelog Make the action workflow to skip towncrier check label May 6, 2026
jopemachine and others added 8 commits May 14, 2026 16:04
…ain clients

Apply the BackendAIClientRegistry / V2ClientRegistry pattern to app-proxy
clients. DeploymentChatClient was previously a direct subclass of
BackendAIAppProxyClient, instantiated by the CLI with a raw ClientConfig;
this divergence from the manager-side SDK shape (where domain clients are
lazy-loaded via a registry) does not scale once more app-proxy domain
clients are added (custom containers, /generate, etc.).

- Add BaseAppProxyDomainClient mirroring BaseDomainClient.
- Compose DeploymentChatClient via BaseAppProxyDomainClient instead of
  subclassing BackendAIAppProxyClient.
- Add AppProxyClientRegistry in client/v2/approxy_registry.py with the
  same lifecycle as BackendAIClientRegistry (create / close /
  @cached_property accessors).
- Add create_appproxy_registry helper alongside create_v2_registry.
- Switch ./bai deployment chat to consume the registry.
- Update tests for the new DeploymentChatClient constructor.

Resolves BA-5961.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Mirror the test_registry.py pattern used by BackendAIClientRegistry:
factory creation, domain client type/inheritance, cached_property
identity, and close() delegation.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Drop the runtime list and the "domain clients add X / Y / Z" enumeration —
that's downstream-specific filler that does not belong on the base class.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
App-proxy fronts more than deployment runtimes (e.g. health checks);
drop the "deployment-specific" framing.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@jopemachine jopemachine force-pushed the refactor/BA-5961-app-proxy-client-registry branch from 769d8dc to f466c7f Compare May 14, 2026 07:04
@jopemachine jopemachine marked this pull request as ready for review May 15, 2026 04:26
@jopemachine jopemachine requested a review from a team as a code owner May 15, 2026 04:26
Copilot AI review requested due to automatic review settings May 15, 2026 04:26
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

This PR refactors the app-proxy (“direct-to-deployment”) SDK layer to follow the same domain-client + registry composition pattern used by the existing v2 client registries, and updates the bai deployment chat CLI flow accordingly.

Changes:

  • Introduces BaseAppProxyDomainClient and refactors DeploymentChatClient from inheriting BackendAIAppProxyClient to being composed over it.
  • Adds AppProxyClientRegistry with lazy @cached_property domain client accessors and updates CLI to use it.
  • Updates unit tests/fixtures to construct domain clients via injected BackendAIAppProxyClient, and adds new registry unit tests.

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
tests/unit/client/v2/test_deployment_chat_client.py Updates fixture to inject BackendAIAppProxyClient into DeploymentChatClient.
tests/unit/client_v2/test_approxy_registry.py Adds unit tests for AppProxyClientRegistry lifecycle and cached properties.
src/ai/backend/client/v2/deployment_chat.py Refactors DeploymentChatClient into an app-proxy domain client composed over _client.
src/ai/backend/client/v2/base_client.py Updates BackendAIAppProxyClient docstring to reflect new composition approach.
src/ai/backend/client/v2/base_appproxy_domain.py Adds BaseAppProxyDomainClient base class for app-proxy domain clients.
src/ai/backend/client/v2/approxy_registry.py Adds AppProxyClientRegistry for lazy app-proxy domain client construction and lifecycle.
src/ai/backend/client/cli/v2/helpers.py Adds create_appproxy_registry helper for CLI usage.
src/ai/backend/client/cli/v2/deployment/chat/commands.py Switches bai deployment chat to use the app-proxy registry and close it explicitly.
pyproject.toml Adds Ruff per-file ignore for lazy import pattern in the new registry module.
changes/11491.enhance.md Adds a Towncrier fragment announcing the new app-proxy registry.

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

Comment thread src/ai/backend/client/v2/approxy_registry.py
Comment on lines +135 to +136
jar are intentionally ignored — only TLS / timeout knobs from the
manager-side config are reused.
Comment thread changes/11491.enhance.md
@@ -0,0 +1 @@
Add `AppProxyClientRegistry` to expose app-proxy domain clients (`DeploymentChatClient`) with the same lazy `@cached_property` pattern as `BackendAIClientRegistry`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp:cli Related to CLI component comp:client Related to Client component size:L 100~500 LoC

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants