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
+59 -6
View File
@@ -4386,6 +4386,51 @@
}
}
},
"/bots/{bot_id}/sessions/{session_id}/compact": {
"post": {
"description": "Run context compaction synchronously for a session",
"tags": [
"compaction"
],
"summary": "Trigger immediate context compaction",
"parameters": [
{
"type": "string",
"description": "Bot ID",
"name": "bot_id",
"in": "path",
"required": true
},
{
"type": "string",
"description": "Session ID",
"name": "session_id",
"in": "path",
"required": true
}
],
"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"
}
}
}
}
},
"/bots/{bot_id}/sessions/{session_id}/status": {
"get": {
"description": "Get aggregated info for a chat session including message count, context usage, cache stats, and used skills",
@@ -11348,6 +11393,20 @@
}
}
},
"handlers.TriggerCompactResponse": {
"type": "object",
"properties": {
"message_count": {
"type": "integer"
},
"status": {
"type": "string"
},
"summary": {
"type": "string"
}
}
},
"handlers.createSessionRequest": {
"type": "object",
"properties": {
@@ -12669,9 +12728,6 @@
"compaction_threshold": {
"type": "integer"
},
"context_token_budget": {
"type": "integer"
},
"discuss_probe_model_id": {
"type": "string"
},
@@ -12740,9 +12796,6 @@
"compaction_threshold": {
"type": "integer"
},
"context_token_budget": {
"type": "integer"
},
"discuss_probe_model_id": {
"type": "string"
},