feat: add manifest output upload limits
This commit is contained in:
@@ -1030,7 +1030,7 @@ impl<C: LlmClient, St: Store> Pod<C, St> {
|
||||
let Segment::FileRef { path } = seg else {
|
||||
continue;
|
||||
};
|
||||
match view.resolve_file_ref(path, manifest::defaults::TOOL_OUTPUT_MAX_BYTES) {
|
||||
match view.resolve_file_ref(path, self.manifest.worker.file_upload.max_bytes) {
|
||||
Ok(item) => out.push(item),
|
||||
Err(e) => {
|
||||
self.alert(
|
||||
@@ -3149,6 +3149,7 @@ mod build_summary_prompt_tests {
|
||||
stop_sequences: vec!["\n\n".into(), "</stop>".into()],
|
||||
reasoning: None,
|
||||
tool_output: manifest::ToolOutputLimits::default(),
|
||||
file_upload: manifest::FileUploadLimits::default(),
|
||||
};
|
||||
|
||||
let config = request_config_from_worker_manifest(&manifest);
|
||||
|
||||
@@ -127,7 +127,14 @@ async fn make_pod(client: MockClient) -> Pod<MockClient, FsStore> {
|
||||
}
|
||||
|
||||
async fn make_pod_with_pwd(client: MockClient) -> (Pod<MockClient, FsStore>, std::path::PathBuf) {
|
||||
let manifest = PodManifest::from_toml(MANIFEST_TOML).unwrap();
|
||||
make_pod_with_pwd_and_manifest(client, MANIFEST_TOML).await
|
||||
}
|
||||
|
||||
async fn make_pod_with_pwd_and_manifest(
|
||||
client: MockClient,
|
||||
manifest_toml: &str,
|
||||
) -> (Pod<MockClient, FsStore>, std::path::PathBuf) {
|
||||
let manifest = PodManifest::from_toml(manifest_toml).unwrap();
|
||||
let store_tmp = tempfile::tempdir().unwrap();
|
||||
let store = FsStore::new(store_tmp.path()).await.unwrap();
|
||||
std::mem::forget(store_tmp);
|
||||
@@ -538,6 +545,55 @@ async fn run_with_resolvable_file_ref_attaches_system_message_after_user() {
|
||||
);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn run_with_file_ref_uses_manifest_file_upload_limit() {
|
||||
let client = MockClient::new(simple_text_events());
|
||||
let client_for_assert = client.clone();
|
||||
let manifest_toml = format!("{MANIFEST_TOML}\n[worker.file_upload]\nmax_bytes = 5\n");
|
||||
let (pod, pwd) = make_pod_with_pwd_and_manifest(client, &manifest_toml).await;
|
||||
std::fs::write(pwd.join("long.txt"), "abcdefghij").unwrap();
|
||||
let handle = spawn_controller(pod).await;
|
||||
|
||||
handle
|
||||
.send(Method::Run {
|
||||
input: vec![protocol::Segment::FileRef {
|
||||
path: "long.txt".into(),
|
||||
}],
|
||||
})
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let mut rx = handle.subscribe();
|
||||
let deadline = tokio::time::Instant::now() + std::time::Duration::from_secs(2);
|
||||
loop {
|
||||
tokio::select! {
|
||||
event = rx.recv() => match event {
|
||||
Ok(Event::TurnEnd { .. }) => break,
|
||||
Err(_) => break,
|
||||
_ => {}
|
||||
},
|
||||
_ = tokio::time::sleep_until(deadline) => break,
|
||||
}
|
||||
}
|
||||
tokio::time::sleep(std::time::Duration::from_millis(50)).await;
|
||||
|
||||
let requests = client_for_assert.captured_requests();
|
||||
let attachment = requests[0]
|
||||
.items
|
||||
.iter()
|
||||
.find_map(|i| {
|
||||
let text = i.as_text()?;
|
||||
text.contains("[File: long.txt]").then_some(text)
|
||||
})
|
||||
.expect("file attachment present");
|
||||
assert!(attachment.contains("abcde"), "got: {attachment:?}");
|
||||
assert!(!attachment.contains("abcdef"), "got: {attachment:?}");
|
||||
assert!(
|
||||
attachment.contains("truncated, 10 bytes total"),
|
||||
"got: {attachment:?}"
|
||||
);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn run_with_unresolved_segment_emits_alert_and_placeholder() {
|
||||
let client = MockClient::new(simple_text_events());
|
||||
|
||||
Reference in New Issue
Block a user