mirror of
https://github.com/stablyai/orca.git
synced 2026-11-18 11:54:46 +00:00
fix(claude): ask for the summary context report so a resumed chat makes no token-count API calls (#43441)
The CLI's default 'full' report calls count_tokens once per category on a fresh process, so resuming several chats at once burst 20-31 calls each. 'summary' answers from the last response's usage and local estimates. Tracked in #43104. Co-authored-by: 김윤진 <yunjin.kim@merakiplace.kr>
This commit is contained in:
@@ -268,7 +268,12 @@ export function createClaudeControlSurface(query: Query): ClaudeControlSurface {
|
||||
initializationResult: () =>
|
||||
runClaudeControl('initialize', () => query.initializationResult(), null),
|
||||
getContextUsage: (options) =>
|
||||
runClaudeControl('get_context_usage', () => query.getContextUsage(), options?.timeoutMs),
|
||||
runClaudeControl(
|
||||
'get_context_usage',
|
||||
// 'full' makes one token-count API call per category on each fresh CLI; CLIs before 2.1.257 ignore detail.
|
||||
() => query.getContextUsage({ detail: 'summary' }),
|
||||
options?.timeoutMs
|
||||
),
|
||||
renameSession: (title, sessionId, options) => {
|
||||
const rename = claudeQuerySessionRenamer(query)
|
||||
return rename
|
||||
|
||||
@@ -161,6 +161,18 @@ describe('Claude stream-json connection', () => {
|
||||
}
|
||||
)
|
||||
|
||||
it('asks for the context report without per-category token-count API calls', async () => {
|
||||
const scenario = scriptScenario([HOLD_OPEN])
|
||||
const connection = await open(launchFor(scenario))
|
||||
await connection.initializationResult()
|
||||
await connection.getContextUsage()
|
||||
expect(scenario.readReport().controlRequests).toContainEqual(
|
||||
expect.objectContaining({
|
||||
request: { subtype: 'get_context_usage', detail: 'summary' }
|
||||
})
|
||||
)
|
||||
})
|
||||
|
||||
it('completes task Stop through the real SDK while semantic reading is paused', async () => {
|
||||
const scenario = scriptScenario([HOLD_OPEN])
|
||||
const connection = await open(launchFor(scenario))
|
||||
|
||||
Reference in New Issue
Block a user