mirror of
https://github.com/BerriAI/litellm.git
synced 2026-12-03 01:38:46 +00:00
* feat(lens): isolate trace storage and investigation in a Rust service
* fix(lens): include Rust sources in the image build context
* feat(lens): wire service setup, scoped delivery receipts and lease attempts
* fix(lens): complete service routing and reject stale investigation results
* fix(lens): retry key propagation and validate isolated Compose setup
* fix(lens): seed through isolated ingestion and preserve upstream queue fixes
* chore: sync schema.prisma copies from root
* fix(lens): bind nullable due timestamps as text for Prisma
* chore(ui): remove stale lint suppressions
* fix(lens): address CI failures and review findings
* refactor(lens): remove retired Python worker and run evaluations in Rust
* fix(lens): reuse control connections and satisfy review checks
* test(lens): install and upgrade both Helm charts on Kubernetes
* test(lens): run connection reuse coverage as an integration test
* fix(ui): upgrade Next.js to 16.3.8 security release
* fix(lens): fence stale attempts and preserve reviewed evidence
* Revert "fix(ui): upgrade Next.js to 16.3.8 security release"
This reverts commit 2f79a51b25.
* fix(lens): stop failed investigations and stream history excerpts
* test(lens): cover model tool and result contracts
* test(lens): fix retired routes and reuse installation build artifacts
* test(lens): use portable grep in Helm installation smoke
* test(lens): wait for migrations before forwarding Helm services
* fix(lens): keep failed evidence reads retryable
* fix(lens): preserve sandbox output during process exit
---------
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
96 lines
3.2 KiB
Rust
96 lines
3.2 KiB
Rust
use litellm_lens::{
|
|
Error,
|
|
journal::{Journal, Turn},
|
|
wire,
|
|
};
|
|
use rstest::rstest;
|
|
use serde_json::json;
|
|
|
|
#[rstest]
|
|
#[case::with_initial(true, 0, None)]
|
|
#[case::without_initial(false, 0, None)]
|
|
#[case::second_turn(true, 1, Some(2))]
|
|
#[tokio::test]
|
|
async fn excerpts_match_the_serialized_history(
|
|
#[case] include_initial: bool,
|
|
#[case] turn_start: u64,
|
|
#[case] turn_end: Option<u64>,
|
|
) {
|
|
let mut journal = Journal::new(&json!({"task": "Read é終🦀 and \"quotes\"\n"}))
|
|
.await
|
|
.unwrap();
|
|
for response in ["first é終🦀", "second \"reply\"\n"] {
|
|
journal
|
|
.push(&Turn {
|
|
response: response.into(),
|
|
tool_results: vec![json!({"value": "é終🦀"}).to_string()],
|
|
validation_error: String::new(),
|
|
})
|
|
.await
|
|
.unwrap();
|
|
}
|
|
let mut request: wire::EvidenceRequest = serde_json::from_value(json!({
|
|
"action": "history", "include_initial": include_initial,
|
|
"turn_start": turn_start, "turn_end": turn_end,
|
|
}))
|
|
.unwrap();
|
|
let full = journal.reply(&request).await.unwrap().to_string();
|
|
request.char_start = 7;
|
|
request.char_end = Some(full.chars().count() as u64 - 9);
|
|
let excerpt = journal.reply(&request).await.unwrap();
|
|
assert_eq!(excerpt["characters"], full.chars().count());
|
|
assert_eq!(
|
|
excerpt["excerpt"],
|
|
full.chars()
|
|
.skip(7)
|
|
.take(full.chars().count() - 16)
|
|
.collect::<String>()
|
|
);
|
|
assert_eq!(excerpt["request"], serde_json::to_value(request).unwrap());
|
|
}
|
|
|
|
#[rstest]
|
|
#[case::initial_context(true)]
|
|
#[case::archived_turn(false)]
|
|
#[tokio::test]
|
|
async fn small_unicode_excerpts_are_readable_from_history_over_32_mib(
|
|
#[case] initial_context: bool,
|
|
) {
|
|
let content = "é終🦀".repeat(4 * 1024 * 1024);
|
|
let initial = if initial_context {
|
|
json!({"task": content})
|
|
} else {
|
|
json!({"task": "Read archived tools"})
|
|
};
|
|
let mut journal = Journal::new(&initial).await.unwrap();
|
|
if !initial_context {
|
|
journal
|
|
.push(&Turn {
|
|
response: String::new(),
|
|
tool_results: vec![content],
|
|
validation_error: String::new(),
|
|
})
|
|
.await
|
|
.unwrap();
|
|
}
|
|
let mut request: wire::EvidenceRequest = serde_json::from_value(json!({
|
|
"action": "history", "include_initial": initial_context,
|
|
}))
|
|
.unwrap();
|
|
assert!(journal.reply(&request).await.is_err());
|
|
request.char_start = 6 * 1024 * 1024;
|
|
request.char_end = Some(request.char_start + 30);
|
|
let reply = journal.reply(&request).await.unwrap();
|
|
let excerpt = reply["excerpt"].as_str().unwrap();
|
|
assert_eq!(excerpt.chars().count(), 30);
|
|
assert_eq!(excerpt.chars().filter(|ch| *ch == 'é').count(), 10);
|
|
assert_eq!(excerpt.chars().filter(|ch| *ch == '終').count(), 10);
|
|
assert_eq!(excerpt.chars().filter(|ch| *ch == '🦀').count(), 10);
|
|
assert!(reply["characters"].as_u64().unwrap() > 12 * 1024 * 1024);
|
|
request.char_end = None;
|
|
request.char_start = 1;
|
|
assert!(matches!(
|
|
journal.reply(&request).await,
|
|
Err(Error::ToolOutputTooLarge)
|
|
));
|
|
}
|