fix: disable experimental API betas by default, reduce side query token usage, standardize Headers type (#281)
* fix: disable experimental API betas by default to prevent 500 errors Tool search (defer_loading), global cache scope, and context management betas require internal Anthropic server-side support. External accounts receive 500 Internal Server Error when these are sent. Set CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS=true by default in the CLI entrypoint. Users with internal access can opt back in with =false. Also includes: cache key stability fixes (Sonnet 1M latch, system-before- messages key ordering, resume fingerprint isMeta skip), sideQuery default cleanup, and /dream command. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * refactor: standardize API headers to Headers type and enable tengu feature flags by default * fix: address PR review — dream lock, MCP betas guard, redundant Partial - Call recordConsolidation() programmatically in /dream instead of delegating to model prompt (unreliable) - Add CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS guard to MCP entrypoint (was only in CLI entrypoint, causing 500s in MCP server mode) - Remove redundant ? markers from SecretValueSource Partial<{}> type --------- Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
68
src/commands/dream/dream.ts
Normal file
68
src/commands/dream/dream.ts
Normal file
@@ -0,0 +1,68 @@
|
||||
import type { ContentBlockParam } from '@anthropic-ai/sdk/resources/messages.mjs'
|
||||
import type { Command } from '../../commands.js'
|
||||
import { isAutoMemoryEnabled, getAutoMemPath } from '../../memdir/paths.js'
|
||||
import { getProjectDir } from '../../utils/sessionStorage.js'
|
||||
import { getOriginalCwd, getSessionId } from '../../bootstrap/state.js'
|
||||
import { buildConsolidationPrompt } from '../../services/autoDream/consolidationPrompt.js'
|
||||
import {
|
||||
readLastConsolidatedAt,
|
||||
listSessionsTouchedSince,
|
||||
recordConsolidation,
|
||||
} from '../../services/autoDream/consolidationLock.js'
|
||||
|
||||
const command = {
|
||||
type: 'prompt',
|
||||
name: 'dream',
|
||||
description:
|
||||
'Run memory consolidation — synthesize recent sessions into durable memories',
|
||||
isEnabled: () => isAutoMemoryEnabled(),
|
||||
progressMessage: 'consolidating memories',
|
||||
contentLength: 0,
|
||||
source: 'builtin',
|
||||
async getPromptForCommand(): Promise<ContentBlockParam[]> {
|
||||
const memoryRoot = getAutoMemPath()
|
||||
const transcriptDir = getProjectDir(getOriginalCwd())
|
||||
|
||||
let lastAt: number
|
||||
try {
|
||||
lastAt = await readLastConsolidatedAt()
|
||||
} catch {
|
||||
lastAt = 0
|
||||
}
|
||||
|
||||
let sessionIds: string[]
|
||||
try {
|
||||
sessionIds = await listSessionsTouchedSince(lastAt)
|
||||
} catch {
|
||||
sessionIds = []
|
||||
}
|
||||
|
||||
const currentSession = getSessionId()
|
||||
sessionIds = sessionIds.filter(id => id !== currentSession)
|
||||
|
||||
if (sessionIds.length === 0) {
|
||||
sessionIds = [currentSession]
|
||||
}
|
||||
|
||||
const hoursSince =
|
||||
lastAt > 0
|
||||
? `${((Date.now() - lastAt) / 3_600_000).toFixed(1)}h ago`
|
||||
: 'never'
|
||||
|
||||
const extra = `
|
||||
**Manually triggered by user via /dream.**
|
||||
|
||||
Sessions since last consolidation (${sessionIds.length}, last run: ${hoursSince}):
|
||||
${sessionIds.map(id => `- ${id}`).join('\n')}`
|
||||
|
||||
const prompt = buildConsolidationPrompt(memoryRoot, transcriptDir, extra)
|
||||
|
||||
// Record consolidation timestamp programmatically so auto-dream
|
||||
// knows when the last manual run happened.
|
||||
await recordConsolidation()
|
||||
|
||||
return [{ type: 'text', text: prompt }]
|
||||
},
|
||||
} satisfies Command
|
||||
|
||||
export default command
|
||||
1
src/commands/dream/index.ts
Normal file
1
src/commands/dream/index.ts
Normal file
@@ -0,0 +1 @@
|
||||
export { default } from './dream.js'
|
||||
Reference in New Issue
Block a user