Skip to content

Commit e972b68

Browse files
committed
WIP
1 parent 606eee6 commit e972b68

File tree

3 files changed

+8
-3
lines changed

3 files changed

+8
-3
lines changed

src/agent/llm.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ export async function getNextAssistantResponse(history: Message[], config: Confi
5252
try {
5353
return await generateText({
5454
model: llmProvider,
55-
system: `You are a helpful AI assistant named Tobi. You can use tools to help the user with coding and file system tasks.`,
55+
system: config.systemPrompt,
5656
// eslint-disable-next-line @typescript-eslint/no-explicit-any
5757
messages: truncatedHistory as any,
5858
experimental_telemetry: {

src/agent/state.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { create } from "zustand";
33
import type { Message } from "./types.js";
44
import { getNextAssistantResponse } from "./llm.js";
55
import { runTool } from "./tools/index.js";
6-
import { loadConfig, type Config, HISTORY_PATH, CONFIG_DIR } from "@/config.js";
6+
import { loadConfig, type Config, HISTORY_PATH } from "@/config.js";
77
import type { ToolCallPart } from "ai";
88
import { FatalError, ToolError, TransientError } from "./errors.js";
99
import fs from "fs";

src/config.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ const mcpServerSchema = z
2424
.strict();
2525

2626
const configSchema = z.object({
27+
systemPrompt: z.string().optional().describe("The global system prompt to use for the agent."),
2728
defaultModel: z.string().describe("The 'name' of the model to use by default."),
2829
models: z.array(modelSchema),
2930
history: z
@@ -52,6 +53,7 @@ const configSchema = z.object({
5253
export type Config = z.infer<typeof configSchema>;
5354

5455
const defaultConfig: Config = {
56+
systemPrompt: `You are a helpful AI assistant named Tobi. You can use tools to help the user with coding and file system tasks.`,
5557
defaultModel: "gpt-4.1-mini",
5658
models: [
5759
{ name: "gpt-4.1-mini", provider: "openai", modelId: "gpt-4.1-mini" },
@@ -87,7 +89,10 @@ export async function loadConfig(): Promise<Config> {
8789
try {
8890
const configContent = await fs.readFile(CONFIG_PATH, "utf-8");
8991
const parsedConfig = json5.parse(configContent);
90-
return configSchema.parse(parsedConfig);
92+
93+
// Merge user's config over defaults. This makes adding new keys in updates non-breaking.
94+
const mergedConfig = { ...defaultConfig, ...parsedConfig };
95+
return configSchema.parse(mergedConfig);
9196
} catch (error: unknown) {
9297
if (error instanceof Error && (error as NodeJS.ErrnoException).code === "ENOENT") {
9398
console.warn(`Configuration file not found. Creating a default one at: ${CONFIG_PATH}`);

0 commit comments

Comments
 (0)