From 1a3c4fa6afa46eeed8fc7bb49104a4b5162a2052 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 16 Jun 2026 00:51:50 +0000 Subject: [PATCH] Remove code execution and task-mode steering Simplify Chloei to a basic streaming agent whose only tools are Tavily web search (tavily_search, tavily_extract). - Remove the code_execution tool: delete code-execution-tools.ts, drop its wiring from the agent runtime tool set / metadata extraction / error handling, and prune the "code_execution" tool name and prompt references. - Remove the task-mode feature: delete inferPromptTaskMode, the detection regexes, and TASK_MODE_OVERLAYS; createPromptSteeringBlocks now emits only the provider overlay. Drop the now-unused prompt-message-utils.ts and the taskMode plumbing through the route and agent-context. - Keep provider overlays (Qwen/Kimi tuning) and the streaming protocol's optional operation/provider fields (Tavily still uses operation). - Update affected unit tests and refresh CLAUDE.md / README docs. --- CLAUDE.md | 27 +- README.md | 2 +- src/app/api/agent/route.ts | 7 +- src/lib/server/agent-context.ts | 7 - src/lib/server/agent-prompt-steering.ts | 196 ------ src/lib/server/llm/agent-runtime.ts | 21 +- src/lib/server/llm/code-execution-tools.ts | 628 ------------------ src/lib/server/prompt-message-utils.ts | 31 - src/lib/shared/agent/messages.ts | 6 +- src/lib/shared/agent/reasoning-privacy.ts | 3 +- src/lib/shared/llm/system-instructions.ts | 1 - tests/agent-context.test.mjs | 20 +- .../agent-prompt-steering-inference.test.mjs | 224 ------- tests/agent-prompt-steering.test.mjs | 73 -- tests/agent-route-behavior.test.mjs | 4 - tests/agent-route-contract.test.mjs | 5 - tests/agent-stream-events.test.mjs | 12 +- tests/agent-system-prompt.test.mjs | 25 +- tests/assistant-activity-timeline.test.mjs | 44 +- tests/code-execution-tools.test.mjs | 65 -- tests/stubs/agent-prompt-steering.mjs | 9 - 21 files changed, 55 insertions(+), 1355 deletions(-) delete mode 100644 src/lib/server/llm/code-execution-tools.ts delete mode 100644 src/lib/server/prompt-message-utils.ts delete mode 100644 tests/agent-prompt-steering-inference.test.mjs delete mode 100644 tests/agent-prompt-steering.test.mjs delete mode 100644 tests/code-execution-tools.test.mjs diff --git a/CLAUDE.md b/CLAUDE.md index 1e4ebee0..cae23bc0 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -2,7 +2,7 @@ This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. -Chloei is a **Next.js 16 / React 19** authenticated AI chat app backed by the **Vercel AI Gateway**. A single streaming agent endpoint (`/api/agent`) runs a multi-step tool-using loop (web search, code execution) and streams NDJSON to the browser. Auth, sessions, threads, and rate limiting are **PostgreSQL-backed** (Better Auth + Kysely/`pg`). +Chloei is a **Next.js 16 / React 19** authenticated AI chat app backed by the **Vercel AI Gateway**. A single streaming agent endpoint (`/api/agent`) runs a multi-step tool-using loop (Tavily web search) and streams NDJSON to the browser. Auth, sessions, threads, and rate limiting are **PostgreSQL-backed** (Better Auth + Kysely/`pg`). > **Maintaining this file:** keep it accurate and concise — stale or bloated guidance makes Claude ignore the parts that matter. Cite durable anchors (file paths + symbol names), not line numbers. When you change a subsystem, update the matching section here in the same PR. @@ -76,10 +76,6 @@ Before the model sees them, messages pass through `toModelMessages` (`agent-runt This boundary is **enforced by Next.js bundling at build time** (importing `pg`/`better-auth`/server modules into a client bundle is a build error), **not** by an ESLint rule. Keep it in mind when adding imports. -### Task Modes - -**Task mode** (`inferPromptTaskMode` in `agent-prompt-steering.ts`) is inferred from message content and drives only the **prompt overlay text** (`TASK MODE OVERLAY: `). Modes: `general`, `coding`, `debugging`, `writing`, `research`, `high_stakes`, `closed_answer`, `instruction_following`. The tool-step budget is a single fixed constant (`AGENT_TOOL_MAX_STEPS`) — there is no per-request runtime-profile selection. (The `research` task mode is an automatic content-based overlay, not a user-facing toggle.) - ### System Prompt Composition `buildAgentSystemInstruction` (`src/lib/server/agent-context.ts`) assembles the prompt per-request from labeled blocks delimited by `--- BEGIN