diff --git a/packages/agent/src/agent.ts b/packages/agent/src/agent.ts index c668d10c4..5861b86b5 100644 --- a/packages/agent/src/agent.ts +++ b/packages/agent/src/agent.ts @@ -657,8 +657,8 @@ export class Agent { } // State mutators - setSystemPrompt(v: string[]) { - this.#state.systemPrompt = v; + setSystemPrompt(v: string[] | string) { + this.#state.systemPrompt = typeof v === "string" ? [v] : v; } setModel(m: Model) { diff --git a/packages/coding-agent/CHANGELOG.md b/packages/coding-agent/CHANGELOG.md index 55beb8bf8..d39ef17b6 100644 --- a/packages/coding-agent/CHANGELOG.md +++ b/packages/coding-agent/CHANGELOG.md @@ -15,6 +15,7 @@ - Fixed `omp dry-balance --bench` to recover from 401 token failures by re-minting the failing OAuth credential in place before switching accounts - Fixed selector-style UI components to honor `tui.select.up` and `tui.select.down` keybindings instead of hard-coding raw Up/Down arrow bytes ([#1535](https://github.com/can1357/oh-my-pi/issues/1535)). - Fixed a collapsed, still-streaming tool preview (an `eval`/`bash`/`ssh` box with output streaming in) reading as "weirdly truncated" — top border and head rows missing — once its box outgrew the viewport, snapping back to whole only while expanded with `ctrl+o` and breaking again when collapsed. A streaming preview was classified commit-unstable whenever collapsed, so the transcript offered none of its rows to native scrollback; once the box outgrew the window its head fell into the gap between the commit boundary and the window top, committed nowhere and repainted nowhere. The `provisionalPendingPreview` flag now applies only to the pending call preview (before any result) — once a streaming result exists the result renderer is the live, top-anchored shape and the block is commit-stable in both collapsed and expanded states, so its durable head always reaches scrollback. +- Fixed a crash in subagent task execution and extensions when a string (instead of a string array) was returned or set for the system prompt. Gracefully wrap string values in arrays. ## [15.13.0] - 2026-06-14 diff --git a/packages/coding-agent/src/extensibility/extensions/runner.ts b/packages/coding-agent/src/extensibility/extensions/runner.ts index 31a3f1697..3a23d0e1f 100644 --- a/packages/coding-agent/src/extensibility/extensions/runner.ts +++ b/packages/coding-agent/src/extensibility/extensions/runner.ts @@ -907,7 +907,8 @@ export class ExtensionRunner { messages.push(result.message); } if (result.systemPrompt !== undefined) { - currentSystemPrompt = result.systemPrompt; + currentSystemPrompt = + typeof result.systemPrompt === "string" ? [result.systemPrompt] : result.systemPrompt; systemPromptModified = true; } } diff --git a/packages/coding-agent/src/sdk.ts b/packages/coding-agent/src/sdk.ts index 1744adc20..d68354df5 100644 --- a/packages/coding-agent/src/sdk.ts +++ b/packages/coding-agent/src/sdk.ts @@ -404,7 +404,7 @@ export interface CreateAgentSessionOptions { scopedModels?: Array<{ model: Model; thinkingLevel?: ThinkingLevel }>; /** System prompt blocks. Array replaces default, function receives default blocks and returns final blocks. */ - systemPrompt?: string[] | ((defaultPrompt: string[]) => string[]); + systemPrompt?: string | string[] | ((defaultPrompt: string[]) => string | string[]); /** Optional provider-facing session identifier for prompt caches and sticky auth selection. * Keeps persisted session files isolated while reusing provider-side caches. */ providerSessionId?: string; @@ -2176,11 +2176,12 @@ export async function createAgentSession(options: CreateAgentSessionOptions = {} if (options.systemPrompt === undefined) { return defaultPrompt; } - if (Array.isArray(options.systemPrompt)) { - return { systemPrompt: options.systemPrompt }; - } + const customPrompt = + typeof options.systemPrompt === "function" + ? options.systemPrompt(defaultPrompt.systemPrompt) + : options.systemPrompt; return { - systemPrompt: options.systemPrompt(defaultPrompt.systemPrompt), + systemPrompt: typeof customPrompt === "string" ? [customPrompt] : customPrompt, }; }; diff --git a/python/robomp/tests/test_worker.py b/python/robomp/tests/test_worker.py index a9b070599..f2de9e17d 100644 --- a/python/robomp/tests/test_worker.py +++ b/python/robomp/tests/test_worker.py @@ -70,6 +70,7 @@ class _FakeRpcClient: messages: list = [] events: list = [] assistant_text: str = "ok" + assistant_message: dict | None = None return _Turn()