feat(aihr): add grounded agent shadow runtime
This commit is contained in:
@@ -327,6 +327,8 @@ CREATE TABLE IF NOT EXISTS `aihr_knowledge_conversation` (
|
||||
`broadcast_message_id` bigint DEFAULT NULL COMMENT '绑定的公司消息ID;只存可信引用,不存消息正文',
|
||||
`version` bigint NOT NULL DEFAULT 0 COMMENT '乐观并发版本',
|
||||
`context_json` json DEFAULT NULL COMMENT '最近六轮脱敏短期上下文',
|
||||
`state_version` bigint NOT NULL DEFAULT 0 COMMENT '受约束Agent结构化状态乐观版本',
|
||||
`state_json` json DEFAULT NULL COMMENT '受控引用元数据和结构化槽位;不保存工具事实正文',
|
||||
`expires_time` datetime NOT NULL COMMENT '不活跃过期时间',
|
||||
`create_time` datetime NOT NULL COMMENT '创建时间',
|
||||
`update_time` datetime NOT NULL COMMENT '更新时间',
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
-- Grounded Agent structured conversation state. Additive and idempotent on MySQL 8.
|
||||
-- Legacy context_json remains the unchanged List<Turn> contract.
|
||||
|
||||
SET @aihr_agent_conversation_exists := (
|
||||
SELECT COUNT(*)
|
||||
FROM information_schema.tables
|
||||
WHERE table_schema = DATABASE()
|
||||
AND table_name = 'aihr_knowledge_conversation'
|
||||
);
|
||||
|
||||
SET @aihr_agent_state_version_exists := (
|
||||
SELECT COUNT(*)
|
||||
FROM information_schema.columns
|
||||
WHERE table_schema = DATABASE()
|
||||
AND table_name = 'aihr_knowledge_conversation'
|
||||
AND column_name = 'state_version'
|
||||
);
|
||||
SET @aihr_agent_state_ddl := IF(
|
||||
@aihr_agent_conversation_exists = 1 AND @aihr_agent_state_version_exists = 0,
|
||||
'ALTER TABLE `aihr_knowledge_conversation` ADD COLUMN `state_version` bigint NOT NULL DEFAULT 0 COMMENT ''受约束Agent结构化状态乐观版本'' AFTER `context_json`',
|
||||
'SELECT 1'
|
||||
);
|
||||
PREPARE aihr_agent_state_stmt FROM @aihr_agent_state_ddl;
|
||||
EXECUTE aihr_agent_state_stmt;
|
||||
DEALLOCATE PREPARE aihr_agent_state_stmt;
|
||||
|
||||
SET @aihr_agent_state_json_exists := (
|
||||
SELECT COUNT(*)
|
||||
FROM information_schema.columns
|
||||
WHERE table_schema = DATABASE()
|
||||
AND table_name = 'aihr_knowledge_conversation'
|
||||
AND column_name = 'state_json'
|
||||
);
|
||||
SET @aihr_agent_state_ddl := IF(
|
||||
@aihr_agent_conversation_exists = 1 AND @aihr_agent_state_json_exists = 0,
|
||||
'ALTER TABLE `aihr_knowledge_conversation` ADD COLUMN `state_json` json DEFAULT NULL COMMENT ''受控引用元数据和结构化槽位;不保存工具事实正文'' AFTER `state_version`',
|
||||
'SELECT 1'
|
||||
);
|
||||
PREPARE aihr_agent_state_stmt FROM @aihr_agent_state_ddl;
|
||||
EXECUTE aihr_agent_state_stmt;
|
||||
DEALLOCATE PREPARE aihr_agent_state_stmt;
|
||||
|
||||
SET @aihr_agent_conversation_exists := NULL;
|
||||
SET @aihr_agent_state_version_exists := NULL;
|
||||
SET @aihr_agent_state_json_exists := NULL;
|
||||
SET @aihr_agent_state_ddl := NULL;
|
||||
Reference in New Issue
Block a user