Skip to content

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

refactor(core): clean up redundant fields and logic

Steven Enamakel8ad4c8bdc73c
diff --git a/crates/openhuman-core/src/agent/attachments/mod.rs b/crates/openhuman-core/src/agent/attachments/mod.rs
index 6243313a99..a6c04245e1 100644
--- a/crates/openhuman-core/src/agent/attachments/mod.rs
+++ b/crates/openhuman-core/src/agent/attachments/mod.rs
@@ -19,7 +19,7 @@ pub(crate) mod provider;
/// Per-model-call attachment authority copied from the live agent context.
/// The provider wrapper removes its request carrier before forwarding it.
-#[derive(Clone, Debug, Default, PartialEq, Eq)]
+#[derive(Clone, Debug, Default, PartialEq)]
pub(crate) struct AttachmentAccessScope {
pub(crate) external_channel: bool,
pub(crate) workspace: Option<PathBuf>,
diff --git a/crates/openhuman-core/src/channels/host/channel_events.rs b/crates/openhuman-core/src/channels/host/channel_events.rs
index 58d2c7987b..a652e810d9 100644
--- a/crates/openhuman-core/src/channels/host/channel_events.rs
+++ b/crates/openhuman-core/src/channels/host/channel_events.rs
@@ -85,7 +85,6 @@ impl EventHandler<DomainEvent> for ChannelApprovalSurfaceSubscriber {
namespace: "main".into(),
preparation_mode: Default::default(),
session_policy: Default::default(),
- preparation_mode: Default::default(),
source: tinychannels_bus::module_inbound::ChannelInboundSource::Legacy {
message: ChannelMessage {
reply_to_id: None,
diff --git a/crates/openhuman-core/src/channels/providers/relay/ops.rs b/crates/openhuman-core/src/channels/providers/relay/ops.rs
index f988439565..0b7c493972 100644
--- a/crates/openhuman-core/src/channels/providers/relay/ops.rs
+++ b/crates/openhuman-core/src/channels/providers/relay/ops.rs
@@ -265,7 +265,6 @@ pub(crate) async fn run_relay_turn(
namespace: "main".into(),
preparation_mode: Default::default(),
session_policy: Default::default(),
- preparation_mode: Default::default(),
},
)
.await
diff --git a/crates/openhuman-core/src/channels/runtime/dispatch/processor/native_media.rs b/crates/openhuman-core/src/channels/runtime/dispatch/processor/native_media.rs
index e872c48a1c..2366c1b0cb 100644
--- a/crates/openhuman-core/src/channels/runtime/dispatch/processor/native_media.rs
+++ b/crates/openhuman-core/src/channels/runtime/dispatch/processor/native_media.rs
@@ -90,14 +90,14 @@ pub(super) async fn resolve_typed_message(
for (index, part) in parts.iter_mut().enumerate() {
let (media, image, name) = match part {
ContentPart::Image { media, .. } => (
- media,
+ media.clone(),
true,
media.file_name.clone().unwrap_or_else(|| "image".into()),
),
ContentPart::File {
media, file_name, ..
} => (
- media,
+ media.clone(),
false,
file_name
.clone()
@@ -123,20 +123,20 @@ pub(super) async fn resolve_typed_message(
_ => return Err("native channel content kind is not supported".into()),
};
let byte_limit = if image { image_limit } else { file_limit };
+ let mime = media
+ .content_type
+ .clone()
+ .ok_or_else(|| "native media has no content type".to_owned())?;
let bytes = read_scoped_media(
&client,
&module_dispatch,
envelope.channel.id.as_str(),
&scope,
- media,
+ &media,
byte_limit,
)
.await?;
- let mime = media
- .content_type
- .as_deref()
- .ok_or_else(|| "native media has no content type".to_owned())?;
- media_payloads.push((index, part.clone(), name, mime.to_owned(), bytes));
+ media_payloads.push((index, part.clone(), name, mime, bytes));
}
for (index, input, name, mime, bytes) in media_payloads {
let staged = match crate::threads::attachments::stage_native_channel_part(
diff --git a/crates/openhuman-core/src/channels/runtime/dispatch/processor/turn.rs b/crates/openhuman-core/src/channels/runtime/dispatch/processor/turn.rs
index 220e2c8597..397502a86f 100644
--- a/crates/openhuman-core/src/channels/runtime/dispatch/processor/turn.rs
+++ b/crates/openhuman-core/src/channels/runtime/dispatch/processor/turn.rs
@@ -111,7 +111,6 @@ pub(crate) async fn process_channel_runtime_message(
let msg = prepared.message;
let history_key = prepared.history_key;
let canonical_session_key = prepared.session_key.clone();
- let prepared_thread_id = prepared.thread_id.clone();
let mut envelope = prepared.envelope;
tracing::debug!(
provider_matches_account = envelope
diff --git a/crates/openhuman-core/src/threads/attachments/staged.rs b/crates/openhuman-core/src/threads/attachments/staged.rs
index 9ac264ddd3..b23bfc9256 100644
--- a/crates/openhuman-core/src/threads/attachments/staged.rs
+++ b/crates/openhuman-core/src/threads/attachments/staged.rs
@@ -555,7 +555,7 @@ pub(crate) async fn read_authorized_native_attachment(
.map_err(|_| "native attachment workspace is unavailable".to_owned())?;
let scope = crate::agent::attachments::AttachmentAccessScope {
external_channel: false,
- workspace: Some(workspace),
+ workspace: Some(workspace.clone()),
thread_id: Some(thread_id.to_owned()),
..Default::default()
};
diff --git a/crates/openhuman-core/src/threads/store/bus.rs b/crates/openhuman-core/src/threads/store/bus.rs
index 4968a934d6..45044ac3b4 100644
--- a/crates/openhuman-core/src/threads/store/bus.rs
+++ b/crates/openhuman-core/src/threads/store/bus.rs
@@ -457,7 +457,6 @@ async fn persist_channel_turn(
namespace: "main".into(),
preparation_mode: Default::default(),
session_policy: Default::default(),
- preparation_mode: Default::default(),
source: tinychannels_bus::module_inbound::ChannelInboundSource::Legacy {
message: ChannelMessage {
reply_to_id: None,
diff --git a/crates/openhuman-core/src/web_chat/ops/start_chat.rs b/crates/openhuman-core/src/web_chat/ops/start_chat.rs
index fe7f14d903..6ba380002d 100644
--- a/crates/openhuman-core/src/web_chat/ops/start_chat.rs
+++ b/crates/openhuman-core/src/web_chat/ops/start_chat.rs
@@ -415,6 +415,11 @@ async fn start_chat_inner(
deferred_user_message: mode == QueueMode::Followup && stored_attachments.is_none(),
stored_attachments,
pending_attachments: pending_attachments.clone(),
+ native_message_input: None,
+ native_staged_parts: Vec::new(),
+ native_staged_lease: None,
+ native_message_id: None,
+ native_preparation_error: None,
},
host_authored: false,
disposition: disposition(mode),
diff --git a/crates/openhuman-core/src/web_chat/turn_host.rs b/crates/openhuman-core/src/web_chat/turn_host.rs
index b35934fdc1..dbf8e84b54 100644
--- a/crates/openhuman-core/src/web_chat/turn_host.rs
+++ b/crates/openhuman-core/src/web_chat/turn_host.rs
@@ -340,6 +340,9 @@ impl WebHost {
run_queue: Some(queue),
cancellation,
turn_deadline: request.deadline,
+ native_staged_parts: Vec::new(),
+ native_staged_lease: None,
+ native_message_id: None,
// Also the turn's workspace, so attachment reads and
// delegated sub-agents use the upload folder (#7714).
workspace: thread_dir