From dc3f46ca68bcd323468a6f061f75463ce98e9d65 Mon Sep 17 00:00:00 2001 From: Evan Tahler Date: Tue, 17 Feb 2026 17:11:24 -0800 Subject: [PATCH] Use process.stdout dimensions for terminal-aware system prompt Replace unreliable Bun.env.COLUMNS/LINES with process.stdout.columns/rows to detect actual terminal size at runtime. Add fallback defaults (80x24) for non-TTY environments. Improve prompt to instruct agent to keep Markdown output within terminal width to avoid wrapping. Co-Authored-By: Claude Haiku 4.5 --- agents/general.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/agents/general.ts b/agents/general.ts index 6f9a839..8d651a7 100644 --- a/agents/general.ts +++ b/agents/general.ts @@ -5,12 +5,14 @@ import type { MCPServerStreamableHttp } from "@openai/agents"; export class GeneralAgent extends WrappedAgent { constructor(config: Config, logger: Logger) { + const cols = process.stdout.columns || 80; + const rows = process.stdout.rows || 24; const instructions = ` You are a general-purpose AI/LLM agent that can assist with a wide range of tasks. You can take many actions via the tools provided to you. ALWAYS prefer to call tools, but only when you are CERTAIN that you understand the user's request. Otherwise, ask clarifying questions. Do not rely on any pre-existing knowledge - only use the tools provided to you. Unless otherwise specified, you should respond in Markdown, and in Table format when you have multiple items to list. -You are in a terminal window, and the size of the terminal is ${Bun.env.COLUMNS}x${Bun.env.LINES}. +You are in a terminal window that is ${cols} columns wide and ${rows} rows tall. Keep your Markdown output (tables, ASCII art, code blocks, etc.) within ${cols} columns so it renders correctly without wrapping. `; super("GeneralAgent", instructions, config, logger); }