Add agent context compaction

This commit is contained in:
Georg Bauer
2026-07-26 10:48:29 +02:00
parent 1dcadeb882
commit 6aa45b2cf0
12 changed files with 625 additions and 2 deletions

View File

@@ -165,6 +165,12 @@ fn completion_stream_response(
send_sse_headers_with_cors(stream, request.cors).map_err(|error| (500, error))?;
while let Ok(event) = active.events.recv() {
match event {
GenerationEvent::Compacted(_) => {
return Err((
500,
"The model runtime returned an unexpected compaction event.".into(),
));
}
GenerationEvent::Chunk {
reasoning: false,
content,
@@ -737,6 +743,12 @@ fn stream_response_with_keepalive(
Err(_) => return Ok(()),
};
match event {
GenerationEvent::Compacted(_) => {
return Err((
500,
"The model runtime returned an unexpected compaction event.".into(),
));
}
GenerationEvent::Loading => {}
GenerationEvent::Context {
tokens_per_second, ..