Fix Request ID Header Propagation in Client Calls
- Dominant language
- Python
- Stars
- 670
- Forks
- 183
- Avg merge
- 17h 7m
- Merged PRs (30d)
- 358
Description
## Motivation
When Manager makes calls to Agent, Storage-Proxy, or App-Proxy through client classes, the `X-BackendAI-RequestID` header is not consistently included. This breaks the request tracing chain across components.
- AgentClient, StorageProxyManagerFacingClient, AppProxyClient do not automatically forward request ID
- Current request ID from ContextVar is not being read and attached to outgoing requests
## Required Features
- Modify client base classes to automatically include `X-BackendAI-RequestID` header
- Read current request ID from `current_request_id()` context function
- Apply to all client implementations: AgentClient, StorageProxyManagerFacingClient, AppProxyClient
- Handle cases where request ID is not set (generate new UUID or skip header)
## Impact
- `src/ai/backend/manager/clients/agent/client.py`
- `src/ai/backend/manager/clients/storage_proxy/manager_facing_client.py`
- `src/ai/backend/manager/clients/appproxy/client.py`
- Potentially common client base class if exists
## Testing Scenarios
- Verify request ID is forwarded when making client calls within a request context
- Verify behavior when no request ID is set in context
- Integration test: trace request ID from API entry through to Agent/Storage-Proxy calls
JIRA Issue: BA-3721
Contributor guide
Assessment
This issue has not been assessed yet.