Merge remote-tracking branch 'origin/master' into worktree/web-multimodal-image-input
# Conflicts: # .agents/notes/implemented/architecture/2026-07-25-web-input-machine-and-slash-pipeline.i18n.yaml # apps/web/tests/code-mode-fixture.snapshot.ts # docs/architecture.i18n.yaml # docs/core-data-structures/core.i18n.yaml # docs/module-graph.md # packages/README.i18n.yaml # packages/client/runtime/README.i18n.yaml # packages/client/runtime/README.md # packages/client/runtime/README.zh.md # packages/client/test-runtime/tests/runtime.spec.tsx # packages/client/ui-conversation/README.i18n.yaml # packages/client/ui-conversation/package.json # packages/client/ui-conversation/src/client/chat/ChatView.tsx # packages/client/ui-conversation/src/client/skeleton/ConversationSession.tsx # packages/client/ui-conversation/src/client/skeleton/InputBar.tsx # packages/client/ui-conversation/tests/skeleton.spec.tsx # packages/compact/compact-basic/README.i18n.yaml # packages/compact/compact-basic/README.zh.md # packages/compact/compact-basic/src/summarizer.ts # packages/host/apiproxy/src/api/sessions.ts # packages/llm/llm-pi-ai/README.i18n.yaml # packages/llm/llm/README.i18n.yaml # packages/ui/tui/README.i18n.yaml # pnpm-lock.yaml
This commit is contained in:
@@ -20,6 +20,7 @@ import type {
|
||||
LlmResolvedModelInfo,
|
||||
Message,
|
||||
StreamChunk,
|
||||
TokenUsage,
|
||||
} from '@deepseek-ai/dsh-llm'
|
||||
import { Session, SessionId } from '@deepseek-ai/dsh-session'
|
||||
import TokenMeterService from '@deepseek-ai/dsh-token-meter'
|
||||
@@ -234,6 +235,8 @@ function oversizedToolResult(chars = 3_000, withCompactablePrompt = false): Sess
|
||||
|
||||
class TestCompactService extends BasicCompactService {
|
||||
summary: ContentBlock[] = [{ type: 'text', text: 'small checkpoint' }]
|
||||
rawOutput: ContentBlock[] | undefined
|
||||
usage: TokenUsage | undefined
|
||||
summaryProvider = 'summary-provider'
|
||||
summaryModel = 'summary-model'
|
||||
error: unknown
|
||||
@@ -244,15 +247,24 @@ class TestCompactService extends BasicCompactService {
|
||||
input: SummarizationInput,
|
||||
_agent: Agent,
|
||||
signal?: AbortSignal,
|
||||
): Promise<{ summary: ContentBlock[]; provider: string; model: string; maxTokens?: number }> {
|
||||
): Promise<{
|
||||
summary: ContentBlock[]
|
||||
rawOutput?: ContentBlock[]
|
||||
provider: string
|
||||
model: string
|
||||
maxTokens?: number
|
||||
usage?: TokenUsage
|
||||
}> {
|
||||
this.calls.push({ input, signal })
|
||||
this.mutateDuringSummary?.()
|
||||
if (this.error !== undefined) throw this.error
|
||||
return {
|
||||
summary: this.summary,
|
||||
...this.rawOutput === undefined ? {} : { rawOutput: this.rawOutput },
|
||||
provider: this.summaryProvider,
|
||||
model: this.summaryModel,
|
||||
maxTokens: 123,
|
||||
...this.usage === undefined ? {} : { usage: this.usage },
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -830,6 +842,11 @@ describe('optional model-free tool-result pruning', () => {
|
||||
describe('compaction region transaction', () => {
|
||||
it('lands a framed, replayable checkpoint with exact pricing provenance', async () => {
|
||||
const compact = service()
|
||||
compact.rawOutput = [
|
||||
{ type: 'reasoning', text: 'private compact thought' },
|
||||
...compact.summary,
|
||||
]
|
||||
compact.usage = { inputTokens: 40, outputTokens: 5 }
|
||||
const session = conversation(3)
|
||||
const before = [...session.surface.nodes]
|
||||
const result = await compact.compactRegion(
|
||||
@@ -850,6 +867,8 @@ describe('compaction region transaction', () => {
|
||||
provider: 'summary-provider',
|
||||
model: 'summary-model',
|
||||
maxTokens: 123,
|
||||
rawOutput: compact.rawOutput,
|
||||
usage: compact.usage,
|
||||
})
|
||||
const head = session.deriveMessages()[0]!
|
||||
expect(head.content[0]?.type).toBe('text')
|
||||
@@ -1089,6 +1108,7 @@ describe('compaction region transaction', () => {
|
||||
|
||||
class ScriptedAdapter extends LlmAdapter {
|
||||
lastOptions: GenerateOptions | undefined
|
||||
usage: TokenUsage | undefined
|
||||
|
||||
constructor(
|
||||
private readonly blocks: readonly ContentBlock[],
|
||||
@@ -1109,6 +1129,7 @@ class ScriptedAdapter extends LlmAdapter {
|
||||
yield { type: 'block-end', index, block }
|
||||
}
|
||||
}
|
||||
if (this.usage !== undefined) yield { type: 'usage', usage: this.usage }
|
||||
yield { type: 'finish', reason: this.finish }
|
||||
}
|
||||
}
|
||||
@@ -1118,7 +1139,14 @@ class ExposedCompactService extends BasicCompactService {
|
||||
input: SummarizationInput,
|
||||
owner: Agent,
|
||||
signal?: AbortSignal,
|
||||
): Promise<{ summary: ContentBlock[]; provider: string; model: string; maxTokens?: number }> {
|
||||
): Promise<{
|
||||
summary: ContentBlock[]
|
||||
rawOutput?: ContentBlock[]
|
||||
provider: string
|
||||
model: string
|
||||
maxTokens?: number
|
||||
usage?: TokenUsage
|
||||
}> {
|
||||
return this.summarize(input, owner, signal)
|
||||
}
|
||||
}
|
||||
@@ -1151,13 +1179,20 @@ describe('default one-shot summarizer', () => {
|
||||
maxTokens: 321,
|
||||
})
|
||||
const session = conversation(1)
|
||||
adapter.usage = { inputTokens: 12, outputTokens: 3 }
|
||||
const output = await compact.runSummarize(promptInput('transcript'), agent(session, 'fallback'), SIGNAL)
|
||||
|
||||
expect(output).toEqual({
|
||||
summary: [{ type: 'text', text: 'public summary' }],
|
||||
rawOutput: [
|
||||
{ type: 'reasoning', text: 'private' },
|
||||
{ type: 'text', text: 'public summary' },
|
||||
{ type: 'tool-call', id: CallId('unexpected'), name: 'x', arguments: '{}' },
|
||||
],
|
||||
provider: MODEL,
|
||||
model: MODEL,
|
||||
maxTokens: 321,
|
||||
usage: adapter.usage,
|
||||
})
|
||||
expect(adapter.lastOptions).toMatchObject({
|
||||
provider: MODEL,
|
||||
|
||||
Reference in New Issue
Block a user