feat: add immediate context compaction API, UI button, and /compact slash command

- Add POST /bots/:bot_id/sessions/:session_id/compact endpoint for
  synchronous context compaction with fallback to chat model when no
  dedicated compaction model is configured
- Add "Compact Now" button to session info panel in the web UI
- Add /compact slash command for triggering compaction from chat
- Regenerate OpenAPI spec and TypeScript SDK
This commit is contained in:
Acbox
2026-04-14 21:30:05 +08:00
parent 6328281fc2
commit 27d2b99301
15 changed files with 529 additions and 40 deletions
+39 -4
View File
@@ -1780,6 +1780,15 @@ definitions:
$ref: '#/definitions/handlers.DailyTokenUsage'
type: array
type: object
handlers.TriggerCompactResponse:
properties:
message_count:
type: integer
status:
type: string
summary:
type: string
type: object
handlers.createSessionRequest:
properties:
channel_type:
@@ -2659,8 +2668,6 @@ definitions:
type: integer
compaction_threshold:
type: integer
context_token_budget:
type: integer
discuss_probe_model_id:
type: string
heartbeat_enabled:
@@ -2706,8 +2713,6 @@ definitions:
type: integer
compaction_threshold:
type: integer
context_token_budget:
type: integer
discuss_probe_model_id:
type: string
heartbeat_enabled:
@@ -5766,6 +5771,36 @@ paths:
summary: Update a session
tags:
- sessions
/bots/{bot_id}/sessions/{session_id}/compact:
post:
description: Run context compaction synchronously for a session
parameters:
- description: Bot ID
in: path
name: bot_id
required: true
type: string
- description: Session ID
in: path
name: session_id
required: true
type: string
responses:
"200":
description: OK
schema:
$ref: '#/definitions/handlers.TriggerCompactResponse'
"400":
description: Bad Request
schema:
$ref: '#/definitions/handlers.ErrorResponse'
"500":
description: Internal Server Error
schema:
$ref: '#/definitions/handlers.ErrorResponse'
summary: Trigger immediate context compaction
tags:
- compaction
/bots/{bot_id}/sessions/{session_id}/status:
get:
description: Get aggregated info for a chat session including message count,