Skip to content

Experiment with CLI usage heuristics#47992

Draft
scottopell wants to merge 1 commit intomainfrom
dd/feat/llm-cli-heuristic-agenttelemetry
Draft

Experiment with CLI usage heuristics#47992
scottopell wants to merge 1 commit intomainfrom
dd/feat/llm-cli-heuristic-agenttelemetry

Conversation

@scottopell
Copy link
Contributor

Summary

Workflow Automation • View in Workflow Automation

Add an Agent CLI LLM-user heuristic flow and route it into cross-org Agent Telemetry, with scoring now explicitly prioritizing temporal behavior over all other signals.

Changes

  • Added a new CLI heuristic engine at pkg/cli/heuristic/llm_user_heuristic.go.
    • Computes an LLM-user heuristic score for CLI diagnostics sessions.
    • Uses session state persisted in /tmp/dd-agent-cli-heuristic-state.json.
    • Tracks temporal signals and execution/syntax signals.
  • Added heuristic tests at pkg/cli/heuristic/llm_user_heuristic_test.go.
  • Added a new internal Agent CMD endpoint at /agent/cli-heuristic in comp/api/commonendpoints/impl/common_endpoints.go.
    • Endpoint forwards payload to Agent Telemetry via SendEvent("llm_cli_heuristic", payload).
  • Registered a new default agent telemetry event in comp/core/agenttelemetry/impl/config.go:
    • name: llm_cli_heuristic
    • request_type: agent-cli-heuristic
    • payload_key: agent_cli_heuristic
  • Integrated CLI emission points:
    • cmd/agent/subcommands/status/command.go posts heuristic payload for agent status.
    • pkg/cli/subcommands/health/command.go posts heuristic payload for agent health.
  • Added endpoint test coverage in comp/api/commonendpoints/impl/common_endpoints_test.go.

Follow-up tuning in this update

  • Removed environment-based signals from scoring:
    • TERM
    • NO_COLOR / inferred color support
    • terminal size (COLUMNS/LINES)
  • Kept syntax/execution signals:
    • machine-first flags on first invocation (--json, -j, -p, --pretty-json)
    • parent-process pipe filters to jq/grep/yq
  • Reweighted scoring to make temporal behavior dominant:
    • very fast inter-command latency for complex diagnostics: +60
    • very low shell aging: +30
    • machine-first flags: +6
    • pipe filters: +4

Testing

  • go test -tags test ./pkg/cli/heuristic
  • go test -tags test ./pkg/cli/subcommands/health ./cmd/agent/subcommands/status ./comp/api/commonendpoints/impl ./comp/core/agenttelemetry/impl
  • Format tool run (goimports/gofmt).
  • Previous lint limitation remains environment-related (golangci-lint/go toolchain mismatch), but targeted builds and tests pass.

PR by Bits - View session in Datadog

Comment @DataDog to request changes

Co-authored-by: scottopell <996472+scottopell@users.noreply.github.com>
@datadog-datadog-prod-us1-2
Copy link
Contributor

View session in Datadog

Bits Dev status: ✅ Done

CI Auto-fix: Disabled | Enable

Comment @DataDog to request changes

@datadog-prod-us1-4
Copy link

I can only run on private repositories.

@github-actions
Copy link
Contributor


Thank you for your submission, we really appreciate it. Like many open-source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution. You can sign the CLA by just posting a Pull Request Comment same as the below format.


I have read the CLA Document and I hereby sign the CLA


You can retrigger this bot by commenting recheck in this Pull Request. Posted by the CLA Assistant Lite bot.

@github-actions github-actions bot added the medium review PR review might take time label Mar 18, 2026
@agent-platform-auto-pr
Copy link
Contributor

Go Package Import Differences

Baseline: 6ad2f1d
Comparison: f9ba8b9

binaryosarchchange
agentlinuxamd64
+1, -0
+github.com/DataDog/datadog-agent/pkg/cli/heuristic
agentlinuxarm64
+1, -0
+github.com/DataDog/datadog-agent/pkg/cli/heuristic
agentwindowsamd64
+1, -0
+github.com/DataDog/datadog-agent/pkg/cli/heuristic
agentdarwinamd64
+1, -0
+github.com/DataDog/datadog-agent/pkg/cli/heuristic
agentdarwinarm64
+1, -0
+github.com/DataDog/datadog-agent/pkg/cli/heuristic
iot-agentlinuxamd64
+1, -0
+github.com/DataDog/datadog-agent/pkg/cli/heuristic
iot-agentlinuxarm64
+1, -0
+github.com/DataDog/datadog-agent/pkg/cli/heuristic
heroku-agentlinuxamd64
+1, -0
+github.com/DataDog/datadog-agent/pkg/cli/heuristic
cluster-agentlinuxamd64
+1, -0
+github.com/DataDog/datadog-agent/pkg/cli/heuristic
cluster-agentlinuxarm64
+1, -0
+github.com/DataDog/datadog-agent/pkg/cli/heuristic

@agent-platform-auto-pr
Copy link
Contributor

Files inventory check summary

File checks results against ancestor 6ad2f1d1:

Results for datadog-agent_7.78.0~devel.git.683.f9ba8b9.pipeline.103289181-1_amd64.deb:

No change detected

@agent-platform-auto-pr
Copy link
Contributor

Static quality checks

✅ Please find below the results from static quality gates
Comparison made with ancestor 6ad2f1d
📊 Static Quality Gates Dashboard
🔗 SQG Job

Successful checks

Info

Quality gate Change Size (prev → curr → max)
agent_deb_amd64 +16.12 KiB (0.00% increase) 748.919 → 748.935 → 750.720
agent_deb_amd64_fips +16.12 KiB (0.00% increase) 707.285 → 707.300 → 711.230
agent_heroku_amd64 +16.12 KiB (0.01% increase) 312.824 → 312.840 → 320.580
agent_msi +15.0 KiB (0.00% increase) 602.495 → 602.510 → 1062.520
agent_rpm_amd64 +16.12 KiB (0.00% increase) 748.903 → 748.919 → 750.690
agent_rpm_amd64_fips +16.12 KiB (0.00% increase) 707.268 → 707.284 → 711.210
agent_rpm_arm64 +16.12 KiB (0.00% increase) 727.410 → 727.426 → 732.890
agent_rpm_arm64_fips +16.12 KiB (0.00% increase) 688.726 → 688.742 → 694.440
agent_suse_amd64 +16.12 KiB (0.00% increase) 748.903 → 748.919 → 750.690
agent_suse_amd64_fips +16.12 KiB (0.00% increase) 707.268 → 707.284 → 711.210
agent_suse_arm64 +16.12 KiB (0.00% increase) 727.410 → 727.426 → 732.890
agent_suse_arm64_fips +16.12 KiB (0.00% increase) 688.726 → 688.742 → 694.440
docker_agent_amd64 +16.12 KiB (0.00% increase) 809.250 → 809.266 → 813.040
docker_agent_arm64 +16.12 KiB (0.00% increase) 812.559 → 812.574 → 819.570
docker_agent_jmx_amd64 +16.13 KiB (0.00% increase) 1000.165 → 1000.181 → 1003.920
docker_agent_jmx_arm64 +16.13 KiB (0.00% increase) 992.253 → 992.269 → 999.170
docker_cluster_agent_amd64 +8.06 KiB (0.00% increase) 203.688 → 203.696 → 206.270
iot_agent_deb_amd64 +16.12 KiB (0.04% increase) 43.065 → 43.081 → 43.290
iot_agent_deb_arm64 +16.12 KiB (0.04% increase) 40.124 → 40.140 → 40.920
iot_agent_deb_armhf +16.06 KiB (0.04% increase) 40.860 → 40.876 → 41.030
iot_agent_rpm_amd64 +16.12 KiB (0.04% increase) 43.066 → 43.082 → 43.290
iot_agent_suse_amd64 +16.12 KiB (0.04% increase) 43.066 → 43.082 → 43.290
9 successful checks with minimal change (< 2 KiB)
Quality gate Current Size
docker_cluster_agent_arm64 218.167 MiB
docker_cws_instrumentation_amd64 7.142 MiB
docker_cws_instrumentation_arm64 6.689 MiB
docker_dogstatsd_amd64 39.207 MiB
docker_dogstatsd_arm64 37.445 MiB
dogstatsd_deb_amd64 29.847 MiB
dogstatsd_deb_arm64 28.003 MiB
dogstatsd_rpm_amd64 29.847 MiB
dogstatsd_suse_amd64 29.847 MiB
On-wire sizes (compressed)
Quality gate Change Size (prev → curr → max)
agent_deb_amd64 +54.69 KiB (0.03% increase) 174.183 → 174.237 → 177.700
agent_deb_amd64_fips -10.33 KiB (0.01% reduction) 165.175 → 165.165 → 172.230
agent_heroku_amd64 +2.86 KiB (0.00% increase) 74.899 → 74.902 → 79.970
agent_msi +8.0 KiB (0.01% increase) 137.719 → 137.727 → 146.220
agent_rpm_amd64 +8.82 KiB (0.00% increase) 177.116 → 177.125 → 180.780
agent_rpm_amd64_fips neutral 167.174 MiB → 173.370
agent_rpm_arm64 +25.57 KiB (0.02% increase) 159.632 → 159.657 → 161.610
agent_rpm_arm64_fips -37.96 KiB (0.02% reduction) 151.281 → 151.244 → 155.910
agent_suse_amd64 +8.82 KiB (0.00% increase) 177.116 → 177.125 → 180.780
agent_suse_amd64_fips neutral 167.174 MiB → 173.370
agent_suse_arm64 +25.57 KiB (0.02% increase) 159.632 → 159.657 → 161.610
agent_suse_arm64_fips -37.96 KiB (0.02% reduction) 151.281 → 151.244 → 155.910
docker_agent_amd64 +16.89 KiB (0.01% increase) 267.206 → 267.223 → 271.240
docker_agent_arm64 +9.63 KiB (0.00% increase) 254.475 → 254.485 → 259.800
docker_agent_jmx_amd64 +25.05 KiB (0.01% increase) 335.850 → 335.874 → 339.870
docker_agent_jmx_arm64 -2.0 KiB (0.00% reduction) 319.125 → 319.123 → 324.390
docker_cluster_agent_amd64 neutral 71.289 MiB → 72.920
docker_cluster_agent_arm64 -4.2 KiB (0.01% reduction) 66.926 → 66.921 → 68.220
docker_cws_instrumentation_amd64 neutral 2.999 MiB → 3.330
docker_cws_instrumentation_arm64 neutral 2.729 MiB → 3.090
docker_dogstatsd_amd64 neutral 15.155 MiB → 15.820
docker_dogstatsd_arm64 neutral 14.478 MiB → 14.830
dogstatsd_deb_amd64 neutral 7.886 MiB → 8.790
dogstatsd_deb_arm64 neutral 6.772 MiB → 7.710
dogstatsd_rpm_amd64 neutral 7.896 MiB → 8.800
dogstatsd_suse_amd64 neutral 7.896 MiB → 8.800
iot_agent_deb_amd64 +8.52 KiB (0.07% increase) 11.349 → 11.357 → 12.040
iot_agent_deb_arm64 +4.39 KiB (0.04% increase) 9.664 → 9.668 → 10.450
iot_agent_deb_armhf +4.76 KiB (0.05% increase) 9.896 → 9.901 → 10.620
iot_agent_rpm_amd64 +2.14 KiB (0.02% increase) 11.370 → 11.372 → 12.060
iot_agent_suse_amd64 +2.14 KiB (0.02% increase) 11.370 → 11.372 → 12.060

@cit-pr-commenter-54b7da
Copy link

Regression Detector

Regression Detector Results

Metrics dashboard
Target profiles
Run ID: 3e76d034-d7e7-4394-90bb-db4d0b71cd98

Baseline: 6ad2f1d
Comparison: f9ba8b9
Diff

Optimization Goals: ✅ No significant changes detected

Experiments ignored for regressions

Regressions in experiments with settings containing erratic: true are ignored.

perf experiment goal Δ mean % Δ mean % CI trials links
docker_containers_cpu % cpu utilization +2.26 [-0.80, +5.32] 1 Logs

Fine details of change detection per experiment

perf experiment goal Δ mean % Δ mean % CI trials links
docker_containers_cpu % cpu utilization +2.26 [-0.80, +5.32] 1 Logs
quality_gate_logs % cpu utilization +1.71 [+0.09, +3.34] 1 Logs bounds checks dashboard
tcp_syslog_to_blackhole ingress throughput +0.93 [+0.78, +1.08] 1 Logs
ddot_metrics_sum_cumulativetodelta_exporter memory utilization +0.60 [+0.38, +0.83] 1 Logs
docker_containers_memory memory utilization +0.36 [+0.26, +0.47] 1 Logs
ddot_metrics memory utilization +0.34 [+0.16, +0.52] 1 Logs
otlp_ingest_logs memory utilization +0.32 [+0.22, +0.41] 1 Logs
quality_gate_metrics_logs memory utilization +0.24 [+0.01, +0.48] 1 Logs bounds checks dashboard
tcp_dd_logs_filter_exclude ingress throughput +0.00 [-0.10, +0.10] 1 Logs
uds_dogstatsd_to_api_v3 ingress throughput -0.00 [-0.20, +0.20] 1 Logs
file_to_blackhole_500ms_latency egress throughput -0.01 [-0.40, +0.39] 1 Logs
uds_dogstatsd_to_api ingress throughput -0.01 [-0.21, +0.19] 1 Logs
file_tree memory utilization -0.05 [-0.10, +0.00] 1 Logs
file_to_blackhole_0ms_latency egress throughput -0.06 [-0.57, +0.45] 1 Logs
file_to_blackhole_100ms_latency egress throughput -0.06 [-0.14, +0.02] 1 Logs
file_to_blackhole_1000ms_latency egress throughput -0.10 [-0.53, +0.33] 1 Logs
uds_dogstatsd_20mb_12k_contexts_20_senders memory utilization -0.13 [-0.19, -0.07] 1 Logs
ddot_metrics_sum_delta memory utilization -0.16 [-0.34, +0.02] 1 Logs
quality_gate_idle memory utilization -0.25 [-0.30, -0.20] 1 Logs bounds checks dashboard
ddot_metrics_sum_cumulative memory utilization -0.35 [-0.49, -0.21] 1 Logs
ddot_logs memory utilization -0.43 [-0.49, -0.37] 1 Logs
otlp_ingest_metrics memory utilization -0.45 [-0.60, -0.29] 1 Logs
quality_gate_idle_all_features memory utilization -0.56 [-0.59, -0.52] 1 Logs bounds checks dashboard

Bounds Checks: ✅ Passed

perf experiment bounds_check_name replicates_passed observed_value links
docker_containers_cpu simple_check_run 10/10 700 ≥ 26
docker_containers_memory memory_usage 10/10 275.22MiB ≤ 370MiB
docker_containers_memory simple_check_run 10/10 693 ≥ 26
file_to_blackhole_0ms_latency memory_usage 10/10 0.19GiB ≤ 1.20GiB
file_to_blackhole_0ms_latency missed_bytes 10/10 0B = 0B
file_to_blackhole_1000ms_latency memory_usage 10/10 0.23GiB ≤ 1.20GiB
file_to_blackhole_1000ms_latency missed_bytes 10/10 0B = 0B
file_to_blackhole_100ms_latency memory_usage 10/10 0.20GiB ≤ 1.20GiB
file_to_blackhole_100ms_latency missed_bytes 10/10 0B = 0B
file_to_blackhole_500ms_latency memory_usage 10/10 0.22GiB ≤ 1.20GiB
file_to_blackhole_500ms_latency missed_bytes 10/10 0B = 0B
quality_gate_idle intake_connections 10/10 3 = 3 bounds checks dashboard
quality_gate_idle memory_usage 10/10 172.66MiB ≤ 175MiB bounds checks dashboard
quality_gate_idle_all_features intake_connections 10/10 2 ≤ 3 bounds checks dashboard
quality_gate_idle_all_features memory_usage 10/10 489.04MiB ≤ 550MiB bounds checks dashboard
quality_gate_logs intake_connections 10/10 3 ≤ 6 bounds checks dashboard
quality_gate_logs memory_usage 10/10 206.14MiB ≤ 220MiB bounds checks dashboard
quality_gate_logs missed_bytes 10/10 0B = 0B bounds checks dashboard
quality_gate_metrics_logs cpu_usage 10/10 357.09 ≤ 2000 bounds checks dashboard
quality_gate_metrics_logs intake_connections 10/10 4 ≤ 6 bounds checks dashboard
quality_gate_metrics_logs memory_usage 10/10 400.55MiB ≤ 475MiB bounds checks dashboard
quality_gate_metrics_logs missed_bytes 10/10 0B = 0B bounds checks dashboard

Explanation

Confidence level: 90.00%
Effect size tolerance: |Δ mean %| ≥ 5.00%

Performance changes are noted in the perf column of each table:

  • ✅ = significantly better comparison variant performance
  • ❌ = significantly worse comparison variant performance
  • ➖ = no significant change in performance

A regression test is an A/B test of target performance in a repeatable rig, where "performance" is measured as "comparison variant minus baseline variant" for an optimization goal (e.g., ingress throughput). Due to intrinsic variability in measuring that goal, we can only estimate its mean value for each experiment; we report uncertainty in that value as a 90.00% confidence interval denoted "Δ mean % CI".

For each experiment, we decide whether a change in performance is a "regression" -- a change worth investigating further -- if all of the following criteria are true:

  1. Its estimated |Δ mean %| ≥ 5.00%, indicating the change is big enough to merit a closer look.

  2. Its 90.00% confidence interval "Δ mean % CI" does not contain zero, indicating that if our statistical model is accurate, there is at least a 90.00% chance there is a difference in performance between baseline and comparison variants.

  3. Its configuration does not mark it "erratic".

CI Pass/Fail Decision

Passed. All Quality Gates passed.

  • quality_gate_idle, bounds check memory_usage: 10/10 replicas passed. Gate passed.
  • quality_gate_idle, bounds check intake_connections: 10/10 replicas passed. Gate passed.
  • quality_gate_metrics_logs, bounds check missed_bytes: 10/10 replicas passed. Gate passed.
  • quality_gate_metrics_logs, bounds check intake_connections: 10/10 replicas passed. Gate passed.
  • quality_gate_metrics_logs, bounds check cpu_usage: 10/10 replicas passed. Gate passed.
  • quality_gate_metrics_logs, bounds check memory_usage: 10/10 replicas passed. Gate passed.
  • quality_gate_logs, bounds check missed_bytes: 10/10 replicas passed. Gate passed.
  • quality_gate_logs, bounds check memory_usage: 10/10 replicas passed. Gate passed.
  • quality_gate_logs, bounds check intake_connections: 10/10 replicas passed. Gate passed.
  • quality_gate_idle_all_features, bounds check memory_usage: 10/10 replicas passed. Gate passed.
  • quality_gate_idle_all_features, bounds check intake_connections: 10/10 replicas passed. Gate passed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants