The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.
Rust agent-orchestrationai-agentsai-assistantdesktopllmlocal-firstmcppersonal-aiprivacyrustsecond-braintauri
feat(runtime): add detailed tracing for channel message processing
Steven Enamakel9d83496b11e0
diff --git a/crates/openhuman-core/src/channels/runtime/dispatch/processor/turn.rs b/crates/openhuman-core/src/channels/runtime/dispatch/processor/turn.rsindex b73448af65..597f69d024 100644--- a/crates/openhuman-core/src/channels/runtime/dispatch/processor/turn.rs+++ b/crates/openhuman-core/src/channels/runtime/dispatch/processor/turn.rs@@ -93,6 +93,21 @@ pub(crate) async fn process_channel_runtime_message(let history_key = prepared.history_key;let canonical_session_key = prepared.session_key.clone();let mut envelope = prepared.envelope;+ tracing::debug!(+ provider_matches_account = envelope+ .channel+ .account_id+ .as_deref()+ .is_some_and(|account| tinychannels_bus::provider_id(account) == envelope.channel.id),+ account_present = envelope+ .channel+ .account_id+ .as_deref()+ .is_some_and(|account| !account.trim().is_empty()),+ conversation_present = !envelope.conversation.id.trim().is_empty(),+ message_present = !envelope.message_id.trim().is_empty(),+ "prepared inbound scope for native channel turn"+ );envelope.access.delivered_via_upstream_relay = authenticated_relay;let remote_reset_scope = tinychannels_bus::module_remote::RemoteSessionScope {channel: envelope.channel.clone(),diff --git a/crates/openhuman-core/src/channels/runtime/startup/callback.rs b/crates/openhuman-core/src/channels/runtime/startup/callback.rsindex 0e66da3d71..ab02395caf 100644--- a/crates/openhuman-core/src/channels/runtime/startup/callback.rs+++ b/crates/openhuman-core/src/channels/runtime/startup/callback.rs@@ -143,9 +143,22 @@ impl ChannelHostCallbacks {let envelope: tinychannels_bus::ChannelInboundEnvelope =serde_json::from_value(message).map_err(|_| Error::failed("invalid inbound envelope"))?;- if channel.trim().is_empty()- || envelope.channel.id != tinychannels_bus::provider_id(&channel)- || envelope.channel.account_id.as_deref() != Some(channel.as_str())+ let channel_present = !channel.trim().is_empty();+ let provider_matches = envelope.channel.id == tinychannels_bus::provider_id(&channel);+ let account_matches = envelope.channel.account_id.as_deref() == Some(channel.as_str());+ let conversation_present = !envelope.conversation.id.trim().is_empty();+ let message_present = !envelope.message_id.trim().is_empty();+ tracing::debug!(+ channel_present,+ provider_matches,+ account_matches,+ conversation_present,+ message_present,+ "typed inbound envelope scope validation"+ );+ if !channel_present+ || !provider_matches+ || !account_matches|| envelope.message_id.trim().is_empty()|| envelope.conversation.id.trim().is_empty(){@@ -247,21 +260,39 @@ impl ChannelHostCallbacks {&self,request: tinychannels_bus::HostStoreVoiceMediaRequest,) -> Result<tinychannels_bus::HostStoreVoiceMediaResult> {- tracing::info!("scoped channel voice media callback entered");- if serde_json::to_vec(&request).map_or(true, |bytes| bytes.len() > MAX_VOICE_MEDIA_BYTES) {+ let serialized_len = serde_json::to_vec(&request).map_or(usize::MAX, |bytes| bytes.len());+ tracing::debug!(+ serialized_within_limit = serialized_len <= MAX_VOICE_MEDIA_BYTES,+ "scoped channel voice media callback entered"+ );+ if serialized_len > MAX_VOICE_MEDIA_BYTES {+ tracing::debug!(reason = "serialized_size", "scoped channel voice media rejected");return Err(Error::failed("voice media callback exceeds its limit"));}let decoded = base64::Engine::decode(&base64::engine::general_purpose::STANDARD,&request.audio_base64,)- .map_err(|_| Error::failed("voice media payload is invalid"))?;+ .map_err(|_| {+ tracing::debug!(reason = "invalid_base64", "scoped channel voice media rejected");+ Error::failed("voice media payload is invalid")+ })?;if decoded.is_empty() || decoded.len() > MAX_VOICE_MEDIA_DECODED_BYTES {+ tracing::debug!(reason = "decoded_size", "scoped channel voice media rejected");return Err(Error::failed("voice media exceeds its size limit"));}let scope = &request.scope;let context = self.context()?;let Some(channel) = context.channels_by_name.get(&scope.configured_instance) else {+ tracing::debug!(+ reason = "configured_instance_not_registered",+ provider_adapter_registered = context.channels_by_name.contains_key(&scope.channel.id),+ provider_matches_instance = scope.channel.id+ == tinychannels_bus::provider_id(&scope.configured_instance),+ account_matches_instance = scope.channel.account_id.as_deref()+ == Some(scope.configured_instance.as_str()),+ "scoped channel voice media rejected"+ );return Err(Error::failed("voice media account is not configured"));};if scope.configured_instance.trim().is_empty()@@ -271,6 +302,18 @@ impl ChannelHostCallbacks {|| scope.conversation.id.trim().is_empty()|| scope.turn_id.trim().is_empty(){+ tracing::debug!(+ reason = "scope_mismatch",+ provider_matches_instance = scope.channel.id+ == tinychannels_bus::provider_id(&scope.configured_instance),+ account_matches_instance = scope.channel.account_id.as_deref()+ == Some(scope.configured_instance.as_str()),+ adapter_matches_provider = tinychannels_bus::provider_id(channel.name())+ == scope.channel.id,+ conversation_present = !scope.conversation.id.trim().is_empty(),+ turn_present = !scope.turn_id.trim().is_empty(),+ "scoped channel voice media rejected"+ );return Err(Error::failed("voice media scope does not match configured account",));@@ -283,8 +326,11 @@ impl ChannelHostCallbacks {.as_deref().is_some_and(|id| id.starts_with("tinychannels_media_v1_"))})- .ok_or_else(|| Error::failed("voice media has no durable scoped reference"))?;- tracing::info!("scoped channel voice media accepted");+ .ok_or_else(|| {+ tracing::debug!(reason = "opaque_reference", "scoped channel voice media rejected");+ Error::failed("voice media has no durable scoped reference")+ })?;+ tracing::debug!("scoped channel voice media accepted");Ok(tinychannels_bus::HostStoreVoiceMediaResult {media,// A local durable reference does not grant public-link access.