Skip to content

armgit / ARTEX

Public Imported from GitHub
0

ARTEX - AI autonomous penetration testing system (English translation; upstream: Autumn-27/ARTEX, AGPL-3.0)

fix(llmrec): context size telemetry ON by default

Николай Гусевb708ea6b9a91
diff --git a/llmrec/context_telemetry.go b/llmrec/context_telemetry.go
index 92b1fbd..1d067d0 100644
--- a/llmrec/context_telemetry.go
+++ b/llmrec/context_telemetry.go
@@ -10,19 +10,24 @@ import (
"github.com/Autumn-27/norma/llm"
)
-// ContextTelemetryEnv is the opt-in environment flag enabling per-call context
-// size telemetry into llm_context. Off by default: when unset/false, no sizing
-// work runs and no rows are written.
+// ContextTelemetryEnv switches per-call context size telemetry into llm_context.
+//
+// ON by default. Замер: на стенде, где прошло 15 прогонов, таблица llm_context была
+// ПУСТА (0 строк), потому что флаг выключен по умолчанию — то есть размер контекста
+// воркера обсуждали по суммарным токенам задачи, а не по разбивке (2026-11-22).
+// Стоимость: одна строка на вызов модели и подсчёт длин, содержимое не сохраняется
+// (по логам стенда — до ~300 вызовов на прогон, то есть до ~300 строк).
+// Выключение явное: ARTEX_CONTEXT_TELEMETRY=0|false|off|no.
const ContextTelemetryEnv = "ARTEX_CONTEXT_TELEMETRY"
-// ContextTelemetryEnabled reports whether ARTEX_CONTEXT_TELEMETRY is enabled
-// (1, true, on, yes; case-insensitive). Default is false.
+// ContextTelemetryEnabled reports whether context telemetry is on. Default true;
+// only an explicit falsy value (0, false, off, no; case-insensitive) turns it off.
func ContextTelemetryEnabled() bool {
switch strings.ToLower(strings.TrimSpace(os.Getenv(ContextTelemetryEnv))) {
- case "1", "true", "on", "yes":
- return true
+ case "0", "false", "off", "no":
+ return false
}
- return false
+ return true
}
// ContextMetrics holds size-only measurements of an assembled CompletionRequest
diff --git a/llmrec/context_telemetry_test.go b/llmrec/context_telemetry_test.go
index c3b5129..85a651b 100644
--- a/llmrec/context_telemetry_test.go
+++ b/llmrec/context_telemetry_test.go
@@ -233,11 +233,21 @@ func TestContextTelemetryFlagOffAndOnPostgres(t *testing.T) {
wantMetrics := MeasureContext(req)
wantUsage := llm.Usage{InputTokens: 1200, OutputTokens: 150, CacheReadTokens: 800, CacheWriteTokens: 100}
- // 1. Flag OFF (default): zero rows in llm_context on both Stream and Complete,
- // identical behavior regardless of recordBodies.
+ // 0. Default is ON: unset means enabled, only an explicit falsy value disables.
t.Setenv(ContextTelemetryEnv, "")
+ if !ContextTelemetryEnabled() {
+ t.Fatal("expected telemetry enabled by default when env unset")
+ }
+ t.Setenv(ContextTelemetryEnv, "off")
+ if ContextTelemetryEnabled() {
+ t.Fatal("expected telemetry disabled when ARTEX_CONTEXT_TELEMETRY=off")
+ }
+
+ // 1. Flag OFF explicitly: zero rows in llm_context on both Stream and Complete,
+ // identical behavior regardless of recordBodies.
+ t.Setenv(ContextTelemetryEnv, "0")
if ContextTelemetryEnabled() {
- t.Fatal("expected telemetry disabled when env unset")
+ t.Fatal("expected telemetry disabled when ARTEX_CONTEXT_TELEMETRY=0")
}
recOff := Wrap(syntheticTelemetryProvider{usage: wantUsage}, pg, "claude-test", "prof-a", "", "", func() bool { return false })
ctxOff := transcript.WithSessionID(WithTaskID(context.Background(), taskOff), "exp1-worker-i1")