Skip to content

Commit c12c3e9

Browse files
Salman ParachaSalman Paracha
authored andcommitted
adding docs. Still need to fix the messages list, but waiting on PR #621
1 parent ff6e4b9 commit c12c3e9

File tree

5 files changed

+418
-8
lines changed

5 files changed

+418
-8
lines changed

crates/brightstaff/src/handlers/utils.rs

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use tokio_stream::StreamExt;
1111
use tracing::warn;
1212

1313
// Import tracing constants and signals
14-
use crate::tracing::{llm, error};
14+
use crate::tracing::{llm, error, signals as signal_constants};
1515
use crate::signals::signals::{SignalAnalyzer, InteractionQuality, FLAG_MARKER};
1616
use hermesllm::apis::openai::Message;
1717

@@ -153,12 +153,29 @@ impl StreamProcessor for ObservableStreamProcessor {
153153

154154
// Add overall quality
155155
self.span.attributes.push(Attribute {
156-
key: "signals.quality".to_string(),
156+
key: signal_constants::QUALITY.to_string(),
157157
value: AttributeValue {
158158
string_value: Some(format!("{:?}", report.overall_quality)),
159159
},
160160
});
161161

162+
// Add repair/follow-up metrics if concerning
163+
if report.follow_up.is_concerning || report.follow_up.repair_count > 0 {
164+
self.span.attributes.push(Attribute {
165+
key: signal_constants::REPAIR_COUNT.to_string(),
166+
value: AttributeValue {
167+
string_value: Some(report.follow_up.repair_count.to_string()),
168+
},
169+
});
170+
171+
self.span.attributes.push(Attribute {
172+
key: signal_constants::REPAIR_RATIO.to_string(),
173+
value: AttributeValue {
174+
string_value: Some(format!("{:.3}", report.follow_up.repair_ratio)),
175+
},
176+
});
177+
}
178+
162179
// Add flag marker to operation name if any concerning signal is detected
163180
let should_flag = report.frustration.has_frustration
164181
|| report.repetition.has_looping
@@ -176,13 +193,13 @@ impl StreamProcessor for ObservableStreamProcessor {
176193
// Add key signal metrics
177194
if report.frustration.has_frustration {
178195
self.span.attributes.push(Attribute {
179-
key: "signals.frustration.count".to_string(),
196+
key: signal_constants::FRUSTRATION_COUNT.to_string(),
180197
value: AttributeValue {
181198
string_value: Some(report.frustration.frustration_count.to_string()),
182199
},
183200
});
184201
self.span.attributes.push(Attribute {
185-
key: "signals.frustration.severity".to_string(),
202+
key: signal_constants::FRUSTRATION_SEVERITY.to_string(),
186203
value: AttributeValue {
187204
string_value: Some(report.frustration.severity.to_string()),
188205
},
@@ -191,7 +208,7 @@ impl StreamProcessor for ObservableStreamProcessor {
191208

192209
if report.repetition.has_looping {
193210
self.span.attributes.push(Attribute {
194-
key: "signals.repetition.count".to_string(),
211+
key: signal_constants::REPETITION_COUNT.to_string(),
195212
value: AttributeValue {
196213
string_value: Some(report.repetition.repetition_count.to_string()),
197214
},
@@ -200,7 +217,7 @@ impl StreamProcessor for ObservableStreamProcessor {
200217

201218
if report.escalation.escalation_requested {
202219
self.span.attributes.push(Attribute {
203-
key: "signals.escalation.requested".to_string(),
220+
key: signal_constants::ESCALATION_REQUESTED.to_string(),
204221
value: AttributeValue {
205222
string_value: Some("true".to_string()),
206223
},
@@ -209,7 +226,7 @@ impl StreamProcessor for ObservableStreamProcessor {
209226

210227
if report.positive_feedback.has_positive_feedback {
211228
self.span.attributes.push(Attribute {
212-
key: "signals.positive_feedback.count".to_string(),
229+
key: signal_constants::POSITIVE_FEEDBACK_COUNT.to_string(),
213230
value: AttributeValue {
214231
string_value: Some(report.positive_feedback.positive_count.to_string()),
215232
},

crates/brightstaff/src/tracing/constants.rs

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,45 @@ pub mod error {
141141
pub const STACK_TRACE: &str = "error.stack_trace";
142142
}
143143

144+
// =============================================================================
145+
// Span Attributes - Agentic Signals
146+
// =============================================================================
147+
148+
/// Behavioral quality indicators for agent interactions
149+
/// These signals are computed automatically from conversation patterns
150+
pub mod signals {
151+
/// Overall quality assessment
152+
/// Values: "Excellent", "Good", "Neutral", "Poor", "Severe"
153+
pub const QUALITY: &str = "signals.quality";
154+
155+
/// Total number of turns in the conversation
156+
pub const TURN_COUNT: &str = "signals.turn_count";
157+
158+
/// Efficiency score (0.0-1.0)
159+
pub const EFFICIENCY_SCORE: &str = "signals.efficiency_score";
160+
161+
/// Number of repair attempts detected
162+
pub const REPAIR_COUNT: &str = "signals.follow_up.repair.count";
163+
164+
/// Ratio of repairs to user turns
165+
pub const REPAIR_RATIO: &str = "signals.follow_up.repair.ratio";
166+
167+
/// Number of frustration indicators detected
168+
pub const FRUSTRATION_COUNT: &str = "signals.frustration.count";
169+
170+
/// Frustration severity level (0-3)
171+
pub const FRUSTRATION_SEVERITY: &str = "signals.frustration.severity";
172+
173+
/// Number of repetition instances detected
174+
pub const REPETITION_COUNT: &str = "signals.repetition.count";
175+
176+
/// Whether escalation was requested (user asked for human help)
177+
pub const ESCALATION_REQUESTED: &str = "signals.escalation.requested";
178+
179+
/// Number of positive feedback indicators detected
180+
pub const POSITIVE_FEEDBACK_COUNT: &str = "signals.positive_feedback.count";
181+
}
182+
144183
// =============================================================================
145184
// Operation Names
146185
// =============================================================================
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
mod constants;
22

3-
pub use constants::{OperationNameBuilder, operation_component, http, llm, error, routing};
3+
pub use constants::{OperationNameBuilder, operation_component, http, llm, error, routing, signals};

docs/source/guides/observability/observability.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ Observability
66
.. toctree::
77
:maxdepth: 2
88

9+
signals
910
tracing
1011
monitoring
1112
access_logging

0 commit comments

Comments
 (0)