Repository navigation
Dev observability: emit agent turns as MLflow traces via OTLP (assembled prompt, tools, iterations) - #1343
Conversation
Emits one trace per agent turn when NODESPACE_MLFLOW_URL is set: - agent_turn root span: session_id, model_id, user_message - prompt_assembly child: full assembled system prompt, workspace_context, tools_offered JSON - react_iteration_N child: messages_sent, raw_response, tool_calls_parsed, tool_results, token counts - response_processing child: raw_input, normalized_output, strippers_fired Zero overhead when env var is absent (no-op OTel provider, no network connections). Adds normalize_response_traced() to capture which response strippers fired. Docs: scripts/mlflow-dev.md covers start-server + run-daemon + MCP query workflow. Co-Authored-By: Claude <[email protected]>
Code Review SummaryThis is a clean, well-scoped implementation of dev-only OTLP tracing. The zero-overhead guarantee is correctly implemented (no-op OTel provider when env var is absent, no network connections, no feature flag needed). The span hierarchy matches the issue spec, context propagation is correct ( No blockers. Three improvements are recommended before merge. FindingsSuggested Improvements[Improvement] The # Current (pulls in grpc-tonic, quinn, aws-lc-rs, etc.)
opentelemetry-otlp = { version = "0.32", features = ["trace", "grpc-tonic", "http-proto", "reqwest-rustls"] }
# Corrected (only what .with_http() needs)
opentelemetry-otlp = { version = "0.32", features = ["trace", "http-proto", "reqwest-rustls"] }[Improvement] Both functions implement the same 7-step pipeline independently. If someone adds a new stripper to pub fn normalize_response(text: &str) -> String {
normalize_response_traced(text).0
}This eliminates the synchronization requirement entirely and has no overhead when tracing is disabled, since the fired-list allocation is always [Improvement] Acceptance criterion AC5 states "No sensitive user data leaves the machine." The code correctly documents this in let host = url::Url::parse(&endpoint).ok()
.and_then(|u| u.host_str().map(|h| h.to_string()))
.unwrap_or_default();
if host != "localhost" && host != "127.0.0.1" && host != "::1" {
tracing::warn!(host = %host, "NODESPACE_MLFLOW_URL points to a non-localhost host — traces contain assembled prompts and user messages");
}This does not need to be a hard block (it's a dev tool), but a Nitpicks
Acceptance Criteria Check
The |
malibio
left a comment
There was a problem hiding this comment.
Three improvements recommended before merge — see full review comment. The grpc-tonic unused feature is the priority fix (eliminates aws-lc-rs/quinn from the build). No blockers / security vulns.
- Drop grpc-tonic feature and opentelemetry-semantic-conventions from agent Cargo.toml — only http-proto + reqwest-rustls are used; grpc-tonic was pulling in tonic 0.14, prost 0.14, quinn, aws-lc-rs unnecessarily - Refactor normalize_response to delegate to normalize_response_traced, making the traced version the single pipeline definition — adding a stripper can no longer silently diverge between the two entry-points - Fix strip_channel_blocks inline block to use the apply() closure for consistency with all other strippers - Add is_localhost() guard in init_tracer: warn at startup when NODESPACE_MLFLOW_URL points to a non-localhost host (traces carry full assembled prompts and user messages) - Add 4 unit tests for normalize_response_traced: clean text fires nothing, strip_tool_call_prose fires, strip_channel_blocks fires, and a parity test asserting normalize_response == normalize_response_traced().0 - Fix mlflow-dev.md to use --host 127.0.0.1 (not 0.0.0.0) Skipped: last-iteration response_processing span — the forced-no-tools path is an edge case fallback and adding a span there is scope expansion, not a fix for a review finding. Co-Authored-By: Claude <[email protected]>
Review AddressedAll reviewer recommendations implemented in commit e492e5b. ✅ Addressed (6):
⏭️ Skipped (1):
All tests pass (228 Rust + 4 new response_processing + 3844 frontend). |
…led prompt, tools, iterations) (#1343) * Add OTLP agent tracing via MLflow for dev observability (closes #1341) Emits one trace per agent turn when NODESPACE_MLFLOW_URL is set: - agent_turn root span: session_id, model_id, user_message - prompt_assembly child: full assembled system prompt, workspace_context, tools_offered JSON - react_iteration_N child: messages_sent, raw_response, tool_calls_parsed, tool_results, token counts - response_processing child: raw_input, normalized_output, strippers_fired Zero overhead when env var is absent (no-op OTel provider, no network connections). Adds normalize_response_traced() to capture which response strippers fired. Docs: scripts/mlflow-dev.md covers start-server + run-daemon + MCP query workflow. Co-Authored-By: Claude <[email protected]> * Address review: remove unused deps, unify pipeline, add localhost guard - Drop grpc-tonic feature and opentelemetry-semantic-conventions from agent Cargo.toml — only http-proto + reqwest-rustls are used; grpc-tonic was pulling in tonic 0.14, prost 0.14, quinn, aws-lc-rs unnecessarily - Refactor normalize_response to delegate to normalize_response_traced, making the traced version the single pipeline definition — adding a stripper can no longer silently diverge between the two entry-points - Fix strip_channel_blocks inline block to use the apply() closure for consistency with all other strippers - Add is_localhost() guard in init_tracer: warn at startup when NODESPACE_MLFLOW_URL points to a non-localhost host (traces carry full assembled prompts and user messages) - Add 4 unit tests for normalize_response_traced: clean text fires nothing, strip_tool_call_prose fires, strip_channel_blocks fires, and a parity test asserting normalize_response == normalize_response_traced().0 - Fix mlflow-dev.md to use --host 127.0.0.1 (not 0.0.0.0) Skipped: last-iteration response_processing span — the forced-no-tools path is an edge case fallback and adding a span there is scope expansion, not a fix for a review finding. Co-Authored-By: Claude <[email protected]> --------- Co-authored-by: Michael Libio <[email protected]> Co-authored-by: Claude <[email protected]>
Closes #1341