feat(aihr): add grounded agent shadow runtime
This commit is contained in:
@@ -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