Files
Memoh/db/migrations/0043_drop_subagents_add_parent_session.down.sql
Acbox Liu b3a39ad93d refactor: replace persistent subagents with ephemeral spawn tool (#280)
* refactor: replace persistent subagents with ephemeral spawn tool (#subagent)

- Drop subagents table, remove all persistent subagent infrastructure
- Add 'subagent' session type with parent_session_id on bot_sessions
- Rewrite subagent tool as single 'spawn' tool with parallel execution
- Create system_subagent.md prompt, add _subagent.md include for chat
- Limit subagent tools to file, exec, web_search, web_fetch only
- Merge subagent token usage into parent chat session in reporting
- Remove frontend subagent management page, update chat UI for spawn
- Fix UTF-8 truncation in session title, fix query not passed to agent

* refactor: remove history message page
2026-03-22 19:03:28 +08:00

33 lines
1.2 KiB
SQL

-- 0043_drop_subagents_add_parent_session (rollback)
-- Re-create the subagents table and remove parent_session_id from bot_sessions.
DROP INDEX IF EXISTS idx_bot_sessions_parent;
ALTER TABLE bot_sessions
DROP COLUMN IF EXISTS parent_session_id;
ALTER TABLE bot_sessions
DROP CONSTRAINT IF EXISTS bot_sessions_type_check;
ALTER TABLE bot_sessions
ADD CONSTRAINT bot_sessions_type_check CHECK (type IN ('chat', 'heartbeat', 'schedule'));
CREATE TABLE IF NOT EXISTS subagents (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
name TEXT NOT NULL,
description TEXT NOT NULL,
created_at TIMESTAMPTZ NOT NULL DEFAULT now(),
updated_at TIMESTAMPTZ NOT NULL DEFAULT now(),
deleted BOOLEAN NOT NULL DEFAULT false,
deleted_at TIMESTAMPTZ,
bot_id UUID NOT NULL REFERENCES bots(id) ON DELETE CASCADE,
messages JSONB NOT NULL DEFAULT '[]'::jsonb,
metadata JSONB NOT NULL DEFAULT '{}'::jsonb,
skills JSONB NOT NULL DEFAULT '[]'::jsonb,
usage JSONB NOT NULL DEFAULT '{}'::jsonb,
CONSTRAINT subagents_name_unique UNIQUE (bot_id, name)
);
CREATE INDEX IF NOT EXISTS idx_subagents_bot_id ON subagents(bot_id);
CREATE INDEX IF NOT EXISTS idx_subagents_deleted ON subagents(deleted);