Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
OpenDAS
dynamo
Commits
0adfd98d
"vscode:/vscode.git/clone" did not exist on "473cb57e76f7c02aac950401921847a59bbc6df4"
Unverified
Commit
0adfd98d
authored
Mar 24, 2026
by
vvagias
Committed by
GitHub
Mar 25, 2026
Browse files
fix(frontend): carry forward real stream metadata in JailedStream finalization (#7608)
parent
db49dfd2
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
7 deletions
+28
-7
lib/llm/src/protocols/openai/chat_completions/jail.rs
lib/llm/src/protocols/openai/chat_completions/jail.rs
+12
-4
lib/llm/tests/test_jail.rs
lib/llm/tests/test_jail.rs
+16
-3
No files found.
lib/llm/src/protocols/openai/chat_completions/jail.rs
View file @
0adfd98d
...
...
@@ -513,6 +513,10 @@ impl JailedStream {
let
mut
last_annotated_id
:
Option
<
String
>
=
None
;
let
mut
last_annotated_event
:
Option
<
String
>
=
None
;
let
mut
last_annotated_comment
:
Option
<
Vec
<
String
>>
=
None
;
// Track stream response metadata so finalization chunks carry real values
let
mut
last_stream_id
=
String
::
new
();
let
mut
last_stream_model
=
String
::
new
();
let
mut
last_stream_created
:
u32
=
0
;
// Pin the stream for iteration (stack pinning is more efficient)
tokio
::
pin!
(
stream
);
...
...
@@ -521,6 +525,10 @@ impl JailedStream {
// Process each item in the stream
while
let
Some
(
response
)
=
stream
.next
()
.await
{
if
let
Some
(
chat_response
)
=
response
.data
.as_ref
()
{
last_stream_id
.clone_from
(
&
chat_response
.id
);
last_stream_model
.clone_from
(
&
chat_response
.model
);
last_stream_created
=
chat_response
.created
;
let
mut
all_emissions
=
Vec
::
new
();
if
chat_response
.choices
.is_empty
()
{
...
...
@@ -666,12 +674,12 @@ impl JailedStream {
if
!
final_emissions
.is_empty
()
{
tracing
::
debug!
(
"Stream ended while jailed, releasing accumulated content"
);
// Create a
dummy response for finalization
// Create a
finalization response carrying forward real stream metadata
let
dummy_response
=
NvCreateChatCompletionStreamResponse
{
id
:
"
stream
-end"
.to_string
()
,
id
:
last_
stream
_id
,
object
:
"chat.completion.chunk"
.to_string
(),
created
:
0
,
model
:
"unknown"
.to_string
()
,
created
:
last_stream_created
,
model
:
last_stream_model
,
choices
:
Vec
::
new
(),
usage
:
None
,
service_tier
:
None
,
...
...
lib/llm/tests/test_jail.rs
View file @
0adfd98d
...
...
@@ -1315,10 +1315,23 @@ mod tests {
"Comment should be preserved when stream ends while jailed"
);
// Verify inner response metadata carries forward real stream values (not placeholders)
let
inner
=
accumulated_chunk
.data
.as_ref
()
.unwrap
();
assert_eq!
(
inner
.id
,
"test-id"
,
"Inner response id should carry forward from real stream chunks, not be 'stream-end'"
);
assert_eq!
(
inner
.model
,
"test-model"
,
"Inner response model should carry forward from real stream chunks, not be 'unknown'"
);
assert_eq!
(
inner
.created
,
1234567890
,
"Inner response created should carry forward from real stream chunks, not be 0"
);
// Verify accumulated content is returned
let
content
=
&
accumulated_chunk
.data
.as_ref
()
.unwrap
()
.choices
[
0
]
.delta
.content
;
let
content
=
&
inner
.choices
[
0
]
.delta.content
;
assert
!
(
content
.is_some
(),
"Should have accumulated content"
);
let
content
=
content
.as_ref
()
.unwrap
();
assert
!
(
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment