Summary
The Inference API (inference_api) still has direct Python imports from app_api modules. This was originally a much larger problem (7+ modules), and most have been migrated to apis.shared. Three imports remain and should be moved to complete the separation.
Remaining Imports
In backend/src/apis/inference_api/chat/converse_routes.py:
from apis.app_api.costs.calculator import CostCalculator
from apis.app_api.costs.pricing_config import create_pricing_snapshot
# Lazy import inside _validate_api_key()
from apis.app_api.auth.api_keys.service import get_api_key_service
Impact
- Inference API Docker image must include app_api code
- App API log namespaces (
apis.app_api.*) appear in AgentCore Runtime CloudWatch logs
- Changes to app_api cost or auth modules can break inference_api
- Cannot test inference_api in true isolation
Proposed Fix
Move the remaining modules to apis.shared:
apis.app_api.costs.calculator → apis.shared.costs.calculator
apis.app_api.costs.pricing_config → apis.shared.costs.pricing_config
apis.app_api.auth.api_keys.service → apis.shared.auth.api_keys (or have inference_api validate API keys via an HTTP call to app_api)
Update imports in both app_api and inference_api to use the shared location.
Context
This is the last piece of a long-running effort to decouple the two services. The original issue (identified Jan 2025) had 7+ cross-service imports. Most were resolved by creating apis.shared.sessions, apis.shared.files, apis.shared.rbac, etc. These three are the stragglers.
Acceptance Criteria
Summary
The Inference API (
inference_api) still has direct Python imports fromapp_apimodules. This was originally a much larger problem (7+ modules), and most have been migrated toapis.shared. Three imports remain and should be moved to complete the separation.Remaining Imports
In
backend/src/apis/inference_api/chat/converse_routes.py:Impact
apis.app_api.*) appear in AgentCore Runtime CloudWatch logsProposed Fix
Move the remaining modules to
apis.shared:apis.app_api.costs.calculator→apis.shared.costs.calculatorapis.app_api.costs.pricing_config→apis.shared.costs.pricing_configapis.app_api.auth.api_keys.service→apis.shared.auth.api_keys(or have inference_api validate API keys via an HTTP call to app_api)Update imports in both
app_apiandinference_apito use the shared location.Context
This is the last piece of a long-running effort to decouple the two services. The original issue (identified Jan 2025) had 7+ cross-service imports. Most were resolved by creating
apis.shared.sessions,apis.shared.files,apis.shared.rbac, etc. These three are the stragglers.Acceptance Criteria
from apis.app_apiimports exist anywhere inbackend/src/apis/inference_api/apis.sharedapis.sharedor uses an HTTP call