Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

refactor(threads): clean up attachment handling in edit operation

Steven Enamakel184a63c69206
diff --git a/crates/openhuman-core/src/threads/attachments.rs b/crates/openhuman-core/src/threads/attachments.rs
index fe7e6af43f..68cdc84858 100644
--- a/crates/openhuman-core/src/threads/attachments.rs
+++ b/crates/openhuman-core/src/threads/attachments.rs
@@ -6,7 +6,7 @@
//! when a turn is about to execute.
use serde::{Deserialize, Serialize};
-use serde_json::{Value, json};
+use serde_json::{json, Value};
use tinychannels_bus::{ContentPart, MediaReference};
use tinystoragedrivers::Precondition;
@@ -266,8 +266,8 @@ pub(crate) async fn restage_persisted_parts(
) -> Result<Vec<ContentPart>, String> {
use base64::Engine as _;
- let mut resolved = resolve_persisted_parts(ctx, thread_id, persisted_message_id, requested)
- .await?;
+ let mut resolved =
+ resolve_persisted_parts(ctx, thread_id, persisted_message_id, requested).await?;
let config = ctx
.load_config()
.await
diff --git a/crates/openhuman-core/src/threads/ops/edit.rs b/crates/openhuman-core/src/threads/ops/edit.rs
index 9b73d42a4e..9f4542cd1c 100644
--- a/crates/openhuman-core/src/threads/ops/edit.rs
+++ b/crates/openhuman-core/src/threads/ops/edit.rs
@@ -39,19 +39,19 @@
//! turn.
use serde::{Deserialize, Serialize};
-use serde_json::{Value, json};
+use serde_json::{json, Value};
use tinyagents_session::transcript::{
SessionRef, SessionTranscript, TranscriptLocator, TranscriptMessage, TranscriptMeta,
TruncateCut,
};
-use crate::core::Outcome;
use crate::core::runtime::DispatchCtx;
-use crate::threads::ThreadsError;
+use crate::core::Outcome;
use crate::threads::store::{self as conversations, reply_run_id, run_reply_message_id};
+use crate::threads::ThreadsError;
-use super::support::{TranscriptStore, transcript_store, workspace_dir};
+use super::support::{transcript_store, workspace_dir, TranscriptStore};
#[derive(Debug, Clone, Deserialize)]
#[serde(deny_unknown_fields)]
@@ -116,9 +116,10 @@ pub async fn edit_message(
let store = transcript_store(ctx, &thread_id)
.await
.map_err(ThreadsError::Message)?;
- let has_existing_refs = request.attachments.iter().any(|part| {
- crate::threads::attachments::has_opaque_ref(part)
- });
+ let has_existing_refs = request
+ .attachments
+ .iter()
+ .any(|part| crate::threads::attachments::has_opaque_ref(part));
let staged_parts = if request.attachments.is_empty() {
Vec::new()
} else if has_existing_refs {
diff --git a/crates/openhuman-core/src/threads/ops/edit_attachment_tests.rs b/crates/openhuman-core/src/threads/ops/edit_attachment_tests.rs
index 46838f3dec..4249d465c3 100644
--- a/crates/openhuman-core/src/threads/ops/edit_attachment_tests.rs
+++ b/crates/openhuman-core/src/threads/ops/edit_attachment_tests.rs
@@ -161,11 +161,7 @@ async fn editing_an_image_row_restages_only_its_exact_opaque_reference() {
)
.await;
assert!(other_row.is_err());
- crate::threads::attachments::discard_staged_parts(
- &ctx,
- "edit-image-source",
- &replacement_refs,
- )
- .await
- .unwrap();
+ crate::threads::attachments::discard_staged_parts(&ctx, "edit-image-source", &replacement_refs)
+ .await
+ .unwrap();
}