From f70fd30cd3b63634208d25e0f59b66d84e5cc9b8 Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Tue, 23 Dec 2025 14:05:43 +0000 Subject: [PATCH] chore: include runtime info in system prompt --- src/agents/pi-embedded-runner.ts | 10 ++++++++++ src/agents/system-prompt.ts | 19 +++++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/src/agents/pi-embedded-runner.ts b/src/agents/pi-embedded-runner.ts index 04a590d7d..a9d617501 100644 --- a/src/agents/pi-embedded-runner.ts +++ b/src/agents/pi-embedded-runner.ts @@ -23,6 +23,7 @@ import { import type { ThinkLevel, VerboseLevel } from "../auto-reply/thinking.js"; import { formatToolAggregate } from "../auto-reply/tool-meta.js"; import type { ClawdisConfig } from "../config/config.js"; +import { getMachineDisplayName } from "../infra/machine-name.js"; import { splitMediaFromOutput } from "../media/parse.js"; import { enqueueCommand } from "../process/command-queue.js"; import { CONFIG_DIR, resolveUserPath } from "../utils.js"; @@ -323,11 +324,20 @@ export async function runEmbeddedPiAgent(params: { const contextFiles = buildBootstrapContextFiles(bootstrapFiles); const promptSkills = resolvePromptSkills(skillsSnapshot, skillEntries); const tools = createClawdisCodingTools(); + const machineName = await getMachineDisplayName(); + const runtimeInfo = { + host: machineName, + os: `${os.type()} ${os.release()}`, + arch: os.arch(), + node: process.version, + model: `${provider}/${modelId}`, + }; const systemPrompt = buildSystemPrompt({ appendPrompt: buildAgentSystemPromptAppend({ workspaceDir: resolvedWorkspace, defaultThinkLevel: params.thinkLevel, extraSystemPrompt: params.extraSystemPrompt, + runtimeInfo, }), contextFiles, skills: promptSkills, diff --git a/src/agents/system-prompt.ts b/src/agents/system-prompt.ts index cbf61b4e1..fafe24220 100644 --- a/src/agents/system-prompt.ts +++ b/src/agents/system-prompt.ts @@ -4,6 +4,13 @@ export function buildAgentSystemPromptAppend(params: { workspaceDir: string; defaultThinkLevel?: ThinkLevel; extraSystemPrompt?: string; + runtimeInfo?: { + host?: string; + os?: string; + arch?: string; + node?: string; + model?: string; + }; }) { const thinkHint = params.defaultThinkLevel && params.defaultThinkLevel !== "off" @@ -11,6 +18,17 @@ export function buildAgentSystemPromptAppend(params: { : "Default thinking level: off."; const extraSystemPrompt = params.extraSystemPrompt?.trim(); + const runtimeInfo = params.runtimeInfo; + const runtimeLines: string[] = []; + if (runtimeInfo?.host) runtimeLines.push(`Host: ${runtimeInfo.host}`); + if (runtimeInfo?.os) { + const archSuffix = runtimeInfo.arch ? ` (${runtimeInfo.arch})` : ""; + runtimeLines.push(`OS: ${runtimeInfo.os}${archSuffix}`); + } else if (runtimeInfo?.arch) { + runtimeLines.push(`Arch: ${runtimeInfo.arch}`); + } + if (runtimeInfo?.node) runtimeLines.push(`Node: ${runtimeInfo.node}`); + if (runtimeInfo?.model) runtimeLines.push(`Model: ${runtimeInfo.model}`); const lines = [ "You are Clawd, a personal assistant running inside Clawdis.", @@ -51,6 +69,7 @@ export function buildAgentSystemPromptAppend(params: { 'If something needs attention, do NOT include "HEARTBEAT_OK"; reply with the alert text instead.', "", "## Runtime", + ...runtimeLines, thinkHint, );