Beautiful, AI-native markdown IDE and LLM wiki
TypeScript 2nd-brainagent-skillsclaudecodexcompany-braindocsknowledge-knowledge-baseknowledge-managementllmllm-wikillm-wiki-karpathymarkdownmarkdown-editormdmdxnotespkmsecond-brainskills
Restore a remembered xhigh effort in new agent chats (PRD-7638) (#5005)
Abraham894f9b6f752c
diff --git a/.changeset/prd-7638-restore-xhigh.md b/.changeset/prd-7638-restore-xhigh.mdnew file mode 100644index 000000000..5555d4d1b--- /dev/null+++ b/.changeset/prd-7638-restore-xhigh.md@@ -0,0 +1,5 @@+---+"@inkeep/open-knowledge": patch+---++A remembered agent reasoning level such as `xhigh` now comes back in new agent chats when another remembered setting, like turning thinking on, is what makes it available.diff --git a/knip.config.ts b/knip.config.tsindex 8b615429f..6a38348d8 100644--- a/knip.config.ts+++ b/knip.config.ts@@ -143,15 +143,11 @@ export default {'packages/server': {entry: ['src/**/*.test.ts', 'src/parse-worker.ts'],project: 'src/**',- ignoreDependencies: [- '@types/shell-quote',- ],+ ignoreDependencies: ['@types/shell-quote'],},'packages/cli': {entry: ['src/**/*.test.ts', 'scripts/*.ts', 'tests/**/*.ts', 'src/parse-worker.ts'],- ignoreDependencies: [- 'yjs',- ],+ ignoreDependencies: ['yjs'],},'packages/desktop': {entry: [diff --git a/packages/app/tests/integration/bug3-source-mode-writeback.test.ts b/packages/app/tests/integration/bug3-source-mode-writeback.test.tsindex a28cc2b18..8a60e5826 100644--- a/packages/app/tests/integration/bug3-source-mode-writeback.test.ts+++ b/packages/app/tests/integration/bug3-source-mode-writeback.test.ts@@ -1,4 +1,3 @@-import { readFileSync } from 'node:fs';import { join } from 'node:path';import { setTimeout as wait } from 'node:timers/promises';diff --git a/packages/app/tests/integration/indented-jsx-byte-sacred.test.ts b/packages/app/tests/integration/indented-jsx-byte-sacred.test.tsindex 4fc2c11f9..6fcdc23f2 100644--- a/packages/app/tests/integration/indented-jsx-byte-sacred.test.ts+++ b/packages/app/tests/integration/indented-jsx-byte-sacred.test.ts@@ -1,4 +1,3 @@-import { setTimeout as wait } from 'node:timers/promises';import { normalizeBridge } from '@inkeep/open-knowledge-core';import { updateYFragment } from '@tiptap/y-tiptap';diff --git a/packages/app/tests/integration/interior-edit-freshness.test.ts b/packages/app/tests/integration/interior-edit-freshness.test.tsindex 9f2f6feb6..40b5cdfd6 100644--- a/packages/app/tests/integration/interior-edit-freshness.test.ts+++ b/packages/app/tests/integration/interior-edit-freshness.test.ts@@ -1,4 +1,3 @@-import { setTimeout as wait } from 'node:timers/promises';import { updateYFragment, yXmlFragmentToProseMirrorRootNode } from '@tiptap/y-tiptap';import { afterAll, beforeAll, describe, expect, test } from 'vitest';diff --git a/packages/app/tests/integration/keystroke-cadence-danger-space.test.ts b/packages/app/tests/integration/keystroke-cadence-danger-space.test.tsindex 2a085742b..93666af70 100644--- a/packages/app/tests/integration/keystroke-cadence-danger-space.test.ts+++ b/packages/app/tests/integration/keystroke-cadence-danger-space.test.ts@@ -1,4 +1,3 @@-import { setTimeout as wait } from 'node:timers/promises';import { updateYFragment, yXmlFragmentToProseMirrorRootNode } from '@tiptap/y-tiptap';import { afterAll, beforeAll, describe, expect, test } from 'vitest';diff --git a/packages/app/tests/integration/producer-guard-wiring.test.ts b/packages/app/tests/integration/producer-guard-wiring.test.tsindex 878d5196b..867598d34 100644--- a/packages/app/tests/integration/producer-guard-wiring.test.ts+++ b/packages/app/tests/integration/producer-guard-wiring.test.ts@@ -1,4 +1,3 @@-import { setTimeout as wait } from 'node:timers/promises';import { updateYFragment, yXmlFragmentToProseMirrorRootNode } from '@tiptap/y-tiptap';import { afterAll, beforeAll, describe, expect, test } from 'vitest';diff --git a/packages/app/tests/integration/qa-039-reconciliation-counters-http.test.ts b/packages/app/tests/integration/qa-039-reconciliation-counters-http.test.tsindex 4ada3cf26..0970ac12f 100644--- a/packages/app/tests/integration/qa-039-reconciliation-counters-http.test.ts+++ b/packages/app/tests/integration/qa-039-reconciliation-counters-http.test.ts@@ -1,4 +1,3 @@-import { randomUUID } from 'node:crypto';import { afterEach, describe, expect, test } from 'vitest';import { agentWriteMd, createTestServer, type TestServer } from './test-harness';diff --git a/packages/app/tests/integration/qa-045-restore-after-gc.test.ts b/packages/app/tests/integration/qa-045-restore-after-gc.test.tsindex cbe2b705f..b632185e1 100644--- a/packages/app/tests/integration/qa-045-restore-after-gc.test.ts+++ b/packages/app/tests/integration/qa-045-restore-after-gc.test.ts@@ -1,4 +1,3 @@-import { execFileSync } from 'node:child_process';import { randomUUID } from 'node:crypto';import { join } from 'node:path';diff --git a/packages/app/tests/integration/qa-050-rollback-undo-shipped-path.test.ts b/packages/app/tests/integration/qa-050-rollback-undo-shipped-path.test.tsindex 89bc9b4d9..c530ce4ba 100644--- a/packages/app/tests/integration/qa-050-rollback-undo-shipped-path.test.ts+++ b/packages/app/tests/integration/qa-050-rollback-undo-shipped-path.test.ts@@ -1,4 +1,3 @@-import { randomUUID } from 'node:crypto';import { afterAll, afterEach, beforeAll, describe, expect, test } from 'vitest';import type * as Y from 'yjs';diff --git a/packages/app/tests/integration/undo-after-rollback.test.ts b/packages/app/tests/integration/undo-after-rollback.test.tsindex a78aeb0e4..d3767adc9 100644--- a/packages/app/tests/integration/undo-after-rollback.test.ts+++ b/packages/app/tests/integration/undo-after-rollback.test.ts@@ -1,4 +1,3 @@-import { ROLLBACK_ORIGIN } from '@inkeep/open-knowledge-server';import { afterAll, beforeAll, describe, expect, test } from 'vitest';import * as Y from 'yjs';diff --git a/packages/app/tests/integration/undo-recycle-reset.test.ts b/packages/app/tests/integration/undo-recycle-reset.test.tsindex e7cc69c3f..b076f955c 100644--- a/packages/app/tests/integration/undo-recycle-reset.test.ts+++ b/packages/app/tests/integration/undo-recycle-reset.test.ts@@ -1,4 +1,3 @@-import { writeFileSync } from 'node:fs';import { join } from 'node:path';import { setTimeout as wait } from 'node:timers/promises';diff --git a/packages/app/tests/integration/undo-rederive-survival.test.ts b/packages/app/tests/integration/undo-rederive-survival.test.tsindex 9ddcd0730..7935e35f8 100644--- a/packages/app/tests/integration/undo-rederive-survival.test.ts+++ b/packages/app/tests/integration/undo-rederive-survival.test.ts@@ -1,4 +1,3 @@-import { prependFrontmatter } from '@inkeep/open-knowledge-core';import { Plugin, PluginKey } from '@tiptap/pm/state';import { updateYFragment, yXmlFragmentToProseMirrorRootNode } from '@tiptap/y-tiptap';diff --git a/packages/core/src/bridge/compose.ts b/packages/core/src/bridge/compose.tsindex 2a597ec3d..f4cc8a286 100644--- a/packages/core/src/bridge/compose.ts+++ b/packages/core/src/bridge/compose.ts@@ -1,4 +1,3 @@-import { prependFrontmatter, stripFrontmatter } from '../extensions/frontmatter.ts';export type ComposeAdjustment = 'none' | 'body' | 'frontmatter' | 'unresolved';diff --git a/packages/core/src/bridge/doc-boundary-space.ts b/packages/core/src/bridge/doc-boundary-space.tsindex 01ef76a9f..8fb428b90 100644--- a/packages/core/src/bridge/doc-boundary-space.ts+++ b/packages/core/src/bridge/doc-boundary-space.ts@@ -1,4 +1,3 @@-import { FRONTMATTER_RE, stripFrontmatter } from '../extensions/frontmatter.ts';import { carriedEdgeEmpties, type DocEdgeEmpties } from '../markdown/doc-edge-blank-runs.ts';diff --git a/packages/core/src/markdown/comment-promoter.ts b/packages/core/src/markdown/comment-promoter.tsindex fb0ba5a7c..fc267cbea 100644--- a/packages/core/src/markdown/comment-promoter.ts+++ b/packages/core/src/markdown/comment-promoter.ts@@ -1,4 +1,3 @@-import type { Nodes, Paragraph, PhrasingContent, Root, RootContent, Text } from 'mdast';import { SKIP, visit } from 'unist-util-visit';import type { VFile } from 'vfile';diff --git a/packages/core/src/markdown/merged-walker.ts b/packages/core/src/markdown/merged-walker.tsindex fa3cfcd86..bfd7e3109 100644--- a/packages/core/src/markdown/merged-walker.ts+++ b/packages/core/src/markdown/merged-walker.ts@@ -1,4 +1,3 @@-import type { Nodes, Parent, Root } from 'mdast';import { SKIP, visit } from 'unist-util-visit';import type { VFile } from 'vfile';diff --git a/packages/core/src/markdown/safe-url.ts b/packages/core/src/markdown/safe-url.tsindex 8be632ba4..4d3250d3a 100644--- a/packages/core/src/markdown/safe-url.ts+++ b/packages/core/src/markdown/safe-url.ts@@ -1,4 +1,3 @@-export const SAFE_URL_SCHEMES = ['https', 'http', 'mailto', 'tel', 'ftp', 'sms'] as const;const SCHEME_ALT = SAFE_URL_SCHEMES.map((s) => `${s}:`).join('|');diff --git a/packages/server/src/acp/thread-manager.integration.test.ts b/packages/server/src/acp/thread-manager.integration.test.tsindex 8140c412c..bbb73ea00 100644--- a/packages/server/src/acp/thread-manager.integration.test.ts+++ b/packages/server/src/acp/thread-manager.integration.test.ts@@ -2267,20 +2267,36 @@ describe('AcpThreadManager terminals + permission effects', () => {}, 45_000);});-function writeCascadingConfigAgent(localDir: string): void {+function writeCascadingConfigAgent(+ localDir: string,+ variant: {+ thinkingResetsThought?: boolean;+ thoughtResetsThinking?: boolean;+ rejectUnavailableThought?: boolean;+ requestLog?: string;+ } = {},+): void {const agentPath = join(localDir, 'cascade-agent.mjs');writeFileSync(agentPath,`+import { appendFileSync } from 'node:fs';+const REQUEST_LOG = ${JSON.stringify(variant.requestLog ?? null)};+const THINKING_RESETS_THOUGHT = ${variant.thinkingResetsThought === true};+const THOUGHT_RESETS_THINKING = ${variant.thoughtResetsThinking === true};+const REJECT_UNAVAILABLE_THOUGHT = ${variant.rejectUnavailableThought === true};let model = 'sonnet';+let thinkingEnabled = false;let thought = 'med';+const wideThought = () => model === 'opus' && thinkingEnabled;const thoughtOptions = () =>- model === 'opus'+ wideThought() || REJECT_UNAVAILABLE_THOUGHT? [{ value: 'low', name: 'Low' }, { value: 'med', name: 'Med' }, { value: 'high', name: 'High' }, { value: 'xhigh', name: 'XHigh' }]: [{ value: 'low', name: 'Low' }, { value: 'med', name: 'Med' }];const configOptions = () => [{ id: 'model', name: 'Model', category: 'model', type: 'select', currentValue: model,options: [{ value: 'sonnet', name: 'Sonnet' }, { value: 'opus', name: 'Opus' }] },+ { id: 'thinking_enabled', name: 'Thinking enabled', category: 'other', type: 'boolean', currentValue: thinkingEnabled },{ id: 'thought_level', name: 'Thinking', category: 'thought_level', type: 'select', currentValue: thought,options: thoughtOptions() },];@@ -2303,9 +2319,22 @@ process.stdin.on('data', (chunk) => {reply({ sessionId: 's1', configOptions: configOptions() });} else if (msg.method === 'session/set_config_option') {const { configId, value } = msg.params;- if (configId === 'model') model = value;- else if (configId === 'thought_level' && thoughtOptions().some((o) => o.value === value)) thought = value;- reply({ configOptions: configOptions() });+ if (REQUEST_LOG !== null) appendFileSync(REQUEST_LOG, configId + '\\n');+ if (configId === 'thought_level' && REJECT_UNAVAILABLE_THOUGHT && !wideThought() && value !== 'low' && value !== 'med') {+ process.stdout.write(JSON.stringify({ jsonrpc: '2.0', id: msg.id, error: { code: -32602, message: 'thought level not available yet' } }) + '\\n');+ } else {+ if (configId === 'model') {+ model = value;+ thought = 'med';+ } else if (configId === 'thinking_enabled') {+ thinkingEnabled = value;+ if (THINKING_RESETS_THOUGHT) thought = 'med';+ } else if (configId === 'thought_level' && thoughtOptions().some((o) => o.value === value)) {+ thought = value;+ if (THOUGHT_RESETS_THINKING) thinkingEnabled = false;+ }+ reply({ configOptions: configOptions() });+ }} else if (msg.method === 'session/prompt') {reply({ stopReason: 'end_turn' });} else if (msg.id !== undefined) {@@ -2534,7 +2563,7 @@ describe('AcpThreadManager initial mode apply', () => {});describe('AcpThreadManager initial config apply', () => {- test('applies remembered config before ready — model first, dependent option re-validated', async () => {+ test('restores a remembered thought level that only appears once thinking is turned on', async () => {const contentDir = tmp();const localDir = tmp();writeCascadingConfigAgent(localDir);@@ -2542,12 +2571,20 @@ describe('AcpThreadManager initial config apply', () => {const info = await manager.createThread({agent: { source: 'custom', id: 'cascade-agent' },- settings: { config: { thought_level: 'xhigh', model: 'opus', retired_option: 'gone' } },+ settings: {+ config: {+ thought_level: 'xhigh',+ model: 'opus',+ thinking_enabled: true,+ retired_option: 'gone',+ },+ },});await waitUntil(() => manager.getInfo(info.threadId)?.status === 'ready', 15_000, 'ready');const opts = manager.getInfo(info.threadId)?.configOptions ?? [];expect(opts.find((o) => o.id === 'model')?.currentValue).toBe('opus');+ expect(opts.find((o) => o.id === 'thinking_enabled')?.currentValue).toBe(true);expect(opts.find((o) => o.id === 'thought_level')?.currentValue).toBe('xhigh');await manager.closeThread(info.threadId);@@ -2571,6 +2608,178 @@ describe('AcpThreadManager initial config apply', () => {await manager.closeThread(info.threadId);}, 30_000);++ test('keeps the rest of the remembered config when one value never becomes available', async () => {+ const contentDir = tmp();+ const localDir = tmp();+ writeCascadingConfigAgent(localDir);+ const manager = makeManager(contentDir, localDir);++ const info = await manager.createThread({+ agent: { source: 'custom', id: 'cascade-agent' },+ settings: { config: { model: 'opus', thought_level: 'xhigh' } },+ });+ await waitUntil(() => manager.getInfo(info.threadId)?.status === 'ready', 15_000, 'ready');++ const opts = manager.getInfo(info.threadId)?.configOptions ?? [];+ expect(opts.find((o) => o.id === 'model')?.currentValue).toBe('opus');+ expect(opts.find((o) => o.id === 'thought_level')?.currentValue).toBe('med');++ await manager.closeThread(info.threadId);+ }, 30_000);++ test('restores remembered options whatever order they were stored in', async () => {+ const contentDir = tmp();+ const localDir = tmp();+ writeCascadingConfigAgent(localDir);+ const manager = makeManager(contentDir, localDir);++ const info = await manager.createThread({+ agent: { source: 'custom', id: 'cascade-agent' },+ settings: { config: { thinking_enabled: true, thought_level: 'high', model: 'opus' } },+ });+ await waitUntil(() => manager.getInfo(info.threadId)?.status === 'ready', 15_000, 'ready');++ const opts = manager.getInfo(info.threadId)?.configOptions ?? [];+ expect(opts.find((o) => o.id === 'model')?.currentValue).toBe('opus');+ expect(opts.find((o) => o.id === 'thinking_enabled')?.currentValue).toBe(true);+ expect(opts.find((o) => o.id === 'thought_level')?.currentValue).toBe('high');++ await manager.closeThread(info.threadId);+ }, 30_000);++ test('applies the model before a remembered value the model change would reset', async () => {+ const contentDir = tmp();+ const localDir = tmp();+ writeCascadingConfigAgent(localDir);+ const manager = makeManager(contentDir, localDir);++ const info = await manager.createThread({+ agent: { source: 'custom', id: 'cascade-agent' },+ settings: { config: { thought_level: 'low', model: 'opus' } },+ });+ await waitUntil(() => manager.getInfo(info.threadId)?.status === 'ready', 15_000, 'ready');++ const opts = manager.getInfo(info.threadId)?.configOptions ?? [];+ expect(opts.find((o) => o.id === 'model')?.currentValue).toBe('opus');+ expect(opts.find((o) => o.id === 'thought_level')?.currentValue).toBe('low');++ await manager.closeThread(info.threadId);+ }, 30_000);++ test('logs remembered options that did not come back, keeping missing options apart from unavailable values', async () => {+ const contentDir = tmp();+ const localDir = tmp();+ writeCascadingConfigAgent(localDir);+ const infoLog = vi.spyOn(log, 'info');+ const manager = makeManager(contentDir, localDir);++ const info = await manager.createThread({+ agent: { source: 'custom', id: 'cascade-agent' },+ settings: { config: { model: 'opus', thought_level: 'xhigh', retired_option: 'gone' } },+ });+ await waitUntil(() => manager.getInfo(info.threadId)?.status === 'ready', 15_000, 'ready');++ expect(infoLog).toHaveBeenCalledWith(+ {+ threadId: info.threadId,+ missingConfigIds: ['retired_option'],+ unmatchedConfigIds: ['thought_level'],+ sessionStateUnknown: false,+ },+ '[acp-threads] some remembered config options did not come back in the new session',+ );++ await manager.closeThread(info.threadId);+ }, 30_000);++ test('applies a remembered value again when a later option resets it in the same pass', async () => {+ const contentDir = tmp();+ const localDir = tmp();+ writeCascadingConfigAgent(localDir, { thinkingResetsThought: true });+ const manager = makeManager(contentDir, localDir);++ const info = await manager.createThread({+ agent: { source: 'custom', id: 'cascade-agent' },+ settings: { config: { model: 'opus', thought_level: 'low', thinking_enabled: true } },+ });+ await waitUntil(() => manager.getInfo(info.threadId)?.status === 'ready', 15_000, 'ready');++ const opts = manager.getInfo(info.threadId)?.configOptions ?? [];+ expect(opts.find((o) => o.id === 'thinking_enabled')?.currentValue).toBe(true);+ expect(opts.find((o) => o.id === 'thought_level')?.currentValue).toBe('low');++ await manager.closeThread(info.threadId);+ }, 30_000);++ test('retries a remembered value the agent rejected once a later option makes it available', async () => {+ const contentDir = tmp();+ const localDir = tmp();+ writeCascadingConfigAgent(localDir, { rejectUnavailableThought: true });+ const warnLog = vi.spyOn(log, 'warn');+ const infoLog = vi.spyOn(log, 'info');+ const manager = makeManager(contentDir, localDir);++ const info = await manager.createThread({+ agent: { source: 'custom', id: 'cascade-agent' },+ settings: { config: { model: 'opus', thought_level: 'xhigh', thinking_enabled: true } },+ });+ await waitUntil(() => manager.getInfo(info.threadId)?.status === 'ready', 15_000, 'ready');++ const opts = manager.getInfo(info.threadId)?.configOptions ?? [];+ expect(opts.find((o) => o.id === 'thought_level')?.currentValue).toBe('xhigh');+ expect(infoLog).toHaveBeenCalledWith(+ expect.objectContaining({ threadId: info.threadId, configId: 'thought_level', pass: 0 }),+ '[acp-threads] initial config apply attempt failed',+ );+ for (const message of [+ '[acp-threads] initial config apply failed',+ '[acp-threads] some remembered config options could not be applied to the new session',+ ]) {+ expect(warnLog).not.toHaveBeenCalledWith(expect.anything(), message);+ }++ await manager.closeThread(info.threadId);+ }, 30_000);++ test('stops retrying when two remembered options keep resetting each other', async () => {+ const contentDir = tmp();+ const localDir = tmp();+ const requestLog = join(localDir, 'set-config-requests.log');+ writeCascadingConfigAgent(localDir, {+ thinkingResetsThought: true,+ thoughtResetsThinking: true,+ requestLog,+ });+ const infoLog = vi.spyOn(log, 'info');+ const manager = makeManager(contentDir, localDir);++ const info = await manager.createThread({+ agent: { source: 'custom', id: 'cascade-agent' },+ settings: { config: { model: 'opus', thinking_enabled: true, thought_level: 'low' } },+ });+ await waitUntil(() => manager.getInfo(info.threadId)?.status === 'ready', 15_000, 'ready');++ expect(readFileSync(requestLog, 'utf8').trim().split('\n')).toEqual([+ 'model',+ 'thinking_enabled',+ 'thought_level',+ 'thinking_enabled',+ 'thought_level',+ 'thinking_enabled',+ ]);+ expect(infoLog).toHaveBeenCalledWith(+ {+ threadId: info.threadId,+ missingConfigIds: [],+ unmatchedConfigIds: ['thought_level'],+ sessionStateUnknown: false,+ },+ '[acp-threads] some remembered config options did not come back in the new session',+ );++ await manager.closeThread(info.threadId);+ }, 30_000);});describe('AcpThreadManager prompt queueing', () => {diff --git a/packages/server/src/acp/thread-manager.ts b/packages/server/src/acp/thread-manager.tsindex 2458d0517..843b6b1d9 100644--- a/packages/server/src/acp/thread-manager.ts+++ b/packages/server/src/acp/thread-manager.ts@@ -2933,44 +2933,76 @@ export class AcpThreadManager {): Promise<void> {const sessionId = record.sessionId;if (sessionId === null) return;- const isModel = (id: string): boolean =>- (record.info.configOptions ?? []).find((o) => o.id === id)?.category === 'model';- const ids = Object.keys(config).sort((a, b) => Number(isModel(b)) - Number(isModel(a)));let applied = false;- const rejected: string[] = [];- for (const configId of ids) {- const value = config[configId];- if (value === undefined) continue;- const option = (record.info.configOptions ?? []).find((o) => o.id === configId);- if (option === undefined) continue;- if (!sessionStateUnknown && option.currentValue === value) continue;- if (!initialConfigValueValid(option, value)) continue;- const request: SetSessionConfigOptionRequest =- typeof value === 'boolean'- ? { sessionId, configId, type: 'boolean', value }- : { sessionId, configId, value };- try {- const response: SetSessionConfigOptionResponse = await conn.agent.request(- acpMethods.agent.session.setConfigOption,- request,- );- record.info.configOptions = response.configOptions;- applied = true;- } catch (err) {- rejected.push(configId);- this.opts.log.warn(- { err, threadId: record.info.threadId, configId },- '[acp-threads] initial config apply failed',- );+ const rejected = new Set<string>();+ const findOption = (id: string) => (record.info.configOptions ?? []).find((o) => o.id === id);+ const passLimit = Object.keys(config).length + 1;+ let pending = Object.entries(config);+ for (let pass = 0; pending.length > 0 && pass < passLimit; pass += 1) {+ const isModel = (id: string): boolean => findOption(id)?.category === 'model';+ let changed = false;+ const ordered = [...pending].sort(([a], [b]) => Number(isModel(b)) - Number(isModel(a)));+ for (const [configId, value] of ordered) {+ const option = findOption(configId);+ if (option === undefined) continue;+ if ((!sessionStateUnknown || pass > 0) && option.currentValue === value) continue;+ if (!initialConfigValueValid(option, value)) continue;+ const request: SetSessionConfigOptionRequest =+ typeof value === 'boolean'+ ? { sessionId, configId, type: 'boolean', value }+ : { sessionId, configId, value };+ try {+ const response: SetSessionConfigOptionResponse = await conn.agent.request(+ acpMethods.agent.session.setConfigOption,+ request,+ );+ record.info.configOptions = response.configOptions;+ rejected.delete(configId);+ applied = true;+ changed = true;+ } catch (err) {+ rejected.add(configId);+ this.opts.log.info(+ { err, threadId: record.info.threadId, configId, pass },+ '[acp-threads] initial config apply attempt failed',+ );+ }+ if (record.closed) return;}- if (record.closed) return;+ if (!changed) break;+ pending = Object.entries(config).filter(+ ([configId, value]) => findOption(configId)?.currentValue !== value,+ );}- if (rejected.length > 0) {+ if (rejected.size > 0) {this.opts.log.warn(- { threadId: record.info.threadId, rejectedConfigIds: rejected, sessionStateUnknown },+ {+ threadId: record.info.threadId,+ rejectedConfigIds: [...rejected],+ sessionStateUnknown,+ },'[acp-threads] some remembered config options could not be applied to the new session',);}+ const missingConfigIds: string[] = [];+ const unmatchedConfigIds: string[] = [];+ for (const [configId, value] of Object.entries(config)) {+ if (rejected.has(configId)) continue;+ const option = findOption(configId);+ if (option === undefined) missingConfigIds.push(configId);+ else if (option.currentValue !== value) unmatchedConfigIds.push(configId);+ }+ if (missingConfigIds.length > 0 || unmatchedConfigIds.length > 0) {+ this.opts.log.info(+ {+ threadId: record.info.threadId,+ missingConfigIds,+ unmatchedConfigIds,+ sessionStateUnknown,+ },+ '[acp-threads] some remembered config options did not come back in the new session',+ );+ }if (applied) this.emitInfo(record);}