mirror of
https://github.com/memohai/Memoh.git
synced 2026-04-27 07:16:19 +09:00
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
This commit is contained in:
@@ -13,7 +13,10 @@ import (
|
||||
|
||||
const getTokenUsageByDayAndType = `-- name: GetTokenUsageByDayAndType :many
|
||||
SELECT
|
||||
COALESCE(s.type, 'chat')::text AS session_type,
|
||||
COALESCE(
|
||||
CASE WHEN s.type = 'subagent' THEN COALESCE(ps.type, 'chat') ELSE s.type END,
|
||||
'chat'
|
||||
)::text AS session_type,
|
||||
date_trunc('day', m.created_at)::date AS day,
|
||||
COALESCE(SUM((m.usage->>'inputTokens')::bigint), 0)::bigint AS input_tokens,
|
||||
COALESCE(SUM((m.usage->>'outputTokens')::bigint), 0)::bigint AS output_tokens,
|
||||
@@ -22,6 +25,7 @@ SELECT
|
||||
COALESCE(SUM((m.usage->'outputTokenDetails'->>'reasoningTokens')::bigint), 0)::bigint AS reasoning_tokens
|
||||
FROM bot_history_messages m
|
||||
LEFT JOIN bot_sessions s ON s.id = m.session_id
|
||||
LEFT JOIN bot_sessions ps ON ps.id = s.parent_session_id
|
||||
WHERE m.bot_id = $1
|
||||
AND m.usage IS NOT NULL
|
||||
AND m.created_at >= $2
|
||||
|
||||
Reference in New Issue
Block a user