-
Notifications
You must be signed in to change notification settings - Fork 2.8k
[inworld] add User-Agent and X-Request-Id for better traceability #4784
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
Ian Lee seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account. You have signed the CLA already but the status is still pending? Let us recheck it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
02df037 to
c00c2f6
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🟡 request_id variable overwritten, breaking traceability in error reports
In ChunkedStream._run(), the request_id variable is assigned a UUID at line 1003 for use as the X-Request-Id HTTP header, but then immediately overwritten at line 1018 with utils.shortuuid() for the emitter's request_id. This means that when errors are reported at lines 1051 and 1058, the request_id passed to APIStatusError is the shortuuid, not the UUID that was actually sent to the server in the X-Request-Id header.
Root Cause and Impact
The PR introduces request_id = str(uuid.uuid4()) at line 1003 for the X-Request-Id header, but the pre-existing request_id = utils.shortuuid() at line 1018 overwrites it:
request_id = str(uuid.uuid4()) # line 1003 - UUID for X-Request-Id header
async with self._tts._ensure_session().post(
...,
headers={"X-Request-Id": request_id}, # line 1009 - UUID sent to server
) as resp:
request_id = utils.shortuuid() # line 1018 - OVERWRITES with shortuuid
...
raise APIStatusError(
request_id=request_id, # line 1051 - now shortuuid, not UUID!
)Impact: The whole purpose of this PR is to add X-Request-Id for better traceability. When an error occurs during response processing, the request_id reported in the exception is a different value than what was sent to the server, defeating the traceability goal. The server-side X-Request-Id UUID cannot be correlated with the client-side error.
The fix should use a different variable name for one of the two IDs, e.g. http_request_id for the header UUID and keep request_id for the emitter.
(Refers to line 1018)
Prompt for agents
In livekit-plugins/livekit-plugins-inworld/livekit/plugins/inworld/tts.py, the `request_id` variable in `ChunkedStream._run()` is used for two different purposes: (1) as the X-Request-Id HTTP header value (UUID, line 1003) and (2) as the emitter's request_id (shortuuid, line 1018). The second assignment overwrites the first, so error handlers at lines 1051 and 1058 report the wrong ID.
To fix this, rename the header variable at line 1003 to something like `http_request_id` and use it only for the header at line 1009. Keep the existing `request_id = utils.shortuuid()` at line 1018 for the emitter and error reporting. Alternatively, use the UUID for both purposes (remove line 1018 and use the UUID everywhere), depending on whether the emitter needs a shortuuid specifically.
Was this helpful? React with 👍 or 👎 to provide feedback.
c00c2f6 to
6a76565
Compare
No description provided.