Skip to content

Commit 84046e6

Browse files
Pass backend telemetry to local clients
1 parent 0049926 commit 84046e6

2 files changed

Lines changed: 39 additions & 1 deletion

File tree

local-llm/lib/00-settings.ps1

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,17 @@ $script:ClaudeEnvNames = @(
267267
"API_TIMEOUT_MS",
268268
"CLAUDE_CODE_DISABLE_AUTO_MEMORY",
269269
"CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS",
270-
"ENABLE_TOOL_SEARCH"
270+
"ENABLE_TOOL_SEARCH",
271+
"LOCALBOX_BACKEND",
272+
"LOCALBOX_LLAMA_SERVER_PID",
273+
"LOCALBOX_LLAMA_SERVER_PORT",
274+
"LOCALBOX_LLAMA_SERVER_OUT_LOG",
275+
"LOCALBOX_LLAMA_SERVER_ERR_LOG",
276+
"LOCALBOX_LLAMA_SERVER_GGUF",
277+
"LOCALBOX_LLAMA_SERVER_MODEL",
278+
"LOCALBOX_CONTEXT_KEY",
279+
"LOCALBOX_CONTEXT_TOKENS",
280+
"LOCALBOX_LOW_TPS_WARNING"
271281
)
272282

273283
$script:LocalModelToolUseRules = @"

local-llm/lib/65-claude-launch.ps1

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,33 @@ function Set-ClaudeLocalEnv {
209209
$env:ENABLE_TOOL_SEARCH = "false"
210210
}
211211

212+
function Set-LocalBackendTelemetryEnv {
213+
[CmdletBinding()]
214+
param(
215+
[Parameter(Mandatory = $true)][int]$ProcessId,
216+
[Parameter(Mandatory = $true)][int]$Port,
217+
[Parameter(Mandatory = $true)][string]$OutLogPath,
218+
[Parameter(Mandatory = $true)][string]$ErrLogPath,
219+
[Parameter(Mandatory = $true)][string]$GgufPath,
220+
[Parameter(Mandatory = $true)][string]$Model,
221+
[Parameter(Mandatory = $true)][string]$ContextKey,
222+
[int]$ContextTokens = 0
223+
)
224+
225+
$env:LOCALBOX_BACKEND = "llama.cpp"
226+
$env:LOCALBOX_LLAMA_SERVER_PID = [string]$ProcessId
227+
$env:LOCALBOX_LLAMA_SERVER_PORT = [string]$Port
228+
$env:LOCALBOX_LLAMA_SERVER_OUT_LOG = $OutLogPath
229+
$env:LOCALBOX_LLAMA_SERVER_ERR_LOG = $ErrLogPath
230+
$env:LOCALBOX_LLAMA_SERVER_GGUF = $GgufPath
231+
$env:LOCALBOX_LLAMA_SERVER_MODEL = $Model
232+
$env:LOCALBOX_CONTEXT_KEY = $ContextKey
233+
if ($ContextTokens -gt 0) {
234+
$env:LOCALBOX_CONTEXT_TOKENS = [string]$ContextTokens
235+
}
236+
$env:LOCALBOX_LOW_TPS_WARNING = "2"
237+
}
238+
212239
function Start-NoThinkProxy {
213240
# Puts the no-think proxy in front of llama-server at -TargetPort. The
214241
# proxy strips Anthropic thinking-config from requests and <think>...
@@ -1591,6 +1618,7 @@ function Start-ClaudeWithLlamaCppModel {
15911618
}
15921619

15931620
Set-ClaudeLocalEnv -BaseUrl $effectiveBaseUrl -Model $def.Root -KeepThinking:($thinkingPolicy -eq 'keep') -ContextTokens $contextTokens
1621+
Set-LocalBackendTelemetryEnv -ProcessId $proc.Id -Port $port -OutLogPath $logPaths.Out -ErrLogPath $logPaths.Err -GgufPath $ggufPath -Model $def.Root -ContextKey $ContextKey -ContextTokens $contextTokens
15941622

15951623
$backendLabel = if ($Unshackled) { "unshackled" } else { "claude" }
15961624
$toolsLabel = if ($LimitTools) { "limited" } else { "all" }

0 commit comments

Comments
 (0)