spine-framework 0.3.109 → 0.3.111
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -175,7 +175,8 @@ export async function runAgent(
|
|
|
175
175
|
)
|
|
176
176
|
|
|
177
177
|
// 4. Check confidence and escalate if needed
|
|
178
|
-
|
|
178
|
+
const isEscalated = agentResponse.confidence < (promptConfig.confidence_threshold || 0)
|
|
179
|
+
if (isEscalated) {
|
|
179
180
|
await handleEscalation(
|
|
180
181
|
threadId,
|
|
181
182
|
agentResponse.confidence,
|
|
@@ -204,6 +205,7 @@ export async function runAgent(
|
|
|
204
205
|
agent_id: agent.id,
|
|
205
206
|
prompt_config_id: promptConfig.id,
|
|
206
207
|
sender_type: 'agent',
|
|
208
|
+
escalated: isEscalated,
|
|
207
209
|
},
|
|
208
210
|
ctx,
|
|
209
211
|
replyTypeSlug
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
-- Migration 028: Add AI metadata fields to support_reply/community_reply design_schema
|
|
2
|
+
--
|
|
3
|
+
-- Existing message rows were stamped with the old design_schema, which did not
|
|
4
|
+
-- declare permissions for AI metadata fields (message_type, confidence, retrieved_sources,
|
|
5
|
+
-- feedback, etc.). The permission sanitizer therefore stripped those fields from API
|
|
6
|
+
-- responses, hiding the AI label, confidence badge, sources, and feedback UI.
|
|
7
|
+
--
|
|
8
|
+
-- This migration updates both the type definitions and the stamped design_schema on
|
|
9
|
+
-- every existing message record so the new fields are readable (and feedback writable
|
|
10
|
+
-- by members) without loosening the permission model.
|
|
11
|
+
|
|
12
|
+
DO $$
|
|
13
|
+
DECLARE
|
|
14
|
+
ai_fields jsonb := '{
|
|
15
|
+
"message_type": { "data_type": "text", "label": "Message Type", "system": true, "permissions": { "system_admin": ["read"], "support_admin": ["read"], "support": ["read"], "member_admin": ["read"], "member": ["read"] } },
|
|
16
|
+
"confidence": { "data_type": "number", "label": "AI Confidence", "system": true, "permissions": { "system_admin": ["read"], "support_admin": ["read"], "support": ["read"], "member_admin": ["read"], "member": ["read"] } },
|
|
17
|
+
"retrieval_confidence": { "data_type": "number", "label": "Retrieval Confidence", "system": true, "permissions": { "system_admin": ["read"], "support_admin": ["read"], "support": ["read"], "member_admin": ["read"], "member": ["read"] } },
|
|
18
|
+
"retrieved_sources": { "data_type": "json", "label": "Retrieved Sources", "system": true, "permissions": { "system_admin": ["read"], "support_admin": ["read"], "support": ["read"], "member_admin": ["read"], "member": ["read"] } },
|
|
19
|
+
"agent_id": { "data_type": "text", "label": "Agent ID", "system": true, "permissions": { "system_admin": ["read"], "support_admin": ["read"], "support": ["read"], "member_admin": ["read"], "member": ["read"] } },
|
|
20
|
+
"prompt_config_id": { "data_type": "text", "label": "Prompt Config ID", "system": true, "permissions": { "system_admin": ["read"], "support_admin": ["read"], "support": ["read"], "member_admin": ["read"], "member": ["read"] } },
|
|
21
|
+
"sender_type": { "data_type": "text", "label": "Sender Type", "system": true, "permissions": { "system_admin": ["read"], "support_admin": ["read"], "support": ["read"], "member_admin": ["read"], "member": ["read"] } },
|
|
22
|
+
"feedback": { "data_type": "text", "label": "Feedback", "system": true, "permissions": { "system_admin": ["read", "write"], "support_admin": ["read"], "support": ["read"], "member_admin": ["read", "write"], "member": ["read", "write"] } },
|
|
23
|
+
"feedback_at": { "data_type": "datetime", "label": "Feedback At", "system": true, "permissions": { "system_admin": ["read", "write"], "support_admin": ["read"], "support": ["read"], "member_admin": ["read", "write"], "member": ["read", "write"] } },
|
|
24
|
+
"escalated": { "data_type": "boolean", "label": "Escalated", "system": true, "permissions": { "system_admin": ["read"], "support_admin": ["read"], "support": ["read"], "member_admin": ["read"], "member": ["read"] } },
|
|
25
|
+
"suggested_title": { "data_type": "text", "label": "Suggested Title", "system": true, "permissions": { "system_admin": ["read"], "support_admin": ["read"], "support": ["read"], "member_admin": ["read"], "member": ["read"] } },
|
|
26
|
+
"tool_calls": { "data_type": "json", "label": "Tool Calls", "system": true, "permissions": { "system_admin": ["read"], "support_admin": ["read"], "support": ["read"], "member_admin": ["read"], "member": ["read"] } }
|
|
27
|
+
}'::jsonb;
|
|
28
|
+
BEGIN
|
|
29
|
+
-- Update type definitions
|
|
30
|
+
UPDATE types
|
|
31
|
+
SET design_schema = jsonb_set(
|
|
32
|
+
design_schema,
|
|
33
|
+
'{fields}',
|
|
34
|
+
COALESCE(design_schema->'fields', '{}'::jsonb) || ai_fields
|
|
35
|
+
)
|
|
36
|
+
WHERE slug IN ('support_reply', 'community_reply')
|
|
37
|
+
AND kind = 'message';
|
|
38
|
+
|
|
39
|
+
-- Update stamped design_schema on existing messages
|
|
40
|
+
UPDATE messages
|
|
41
|
+
SET design_schema = jsonb_set(
|
|
42
|
+
design_schema,
|
|
43
|
+
'{fields}',
|
|
44
|
+
COALESCE(design_schema->'fields', '{}'::jsonb) || ai_fields
|
|
45
|
+
)
|
|
46
|
+
WHERE type_id IN (
|
|
47
|
+
SELECT id FROM types WHERE slug IN ('support_reply', 'community_reply') AND kind = 'message'
|
|
48
|
+
);
|
|
49
|
+
END $$;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
-- Migration 029: Tighten the support_triage prompt so the AI escalates when no relevant knowledge is retrieved.
|
|
2
|
+
--
|
|
3
|
+
-- The previous prompt told the agent to "respond helpfully and accurately" without
|
|
4
|
+
-- explicitly forbidding general-knowledge answers or clarifying questions. This led to
|
|
5
|
+
-- the AI asking questions even when the knowledge base was empty. This migration
|
|
6
|
+
-- updates both the prompt_config and the agent's system_prompt to enforce:
|
|
7
|
+
-- 1. answer only from retrieved knowledge
|
|
8
|
+
-- 2. escalate immediately when no relevant knowledge is retrieved
|
|
9
|
+
-- 3. never ask the customer clarifying questions
|
|
10
|
+
|
|
11
|
+
UPDATE prompt_configs
|
|
12
|
+
SET context_template = 'A customer has submitted the following support request:
|
|
13
|
+
|
|
14
|
+
{{user_message}}
|
|
15
|
+
|
|
16
|
+
You may only answer using the relevant information provided in this prompt under ''## Relevant Information''.
|
|
17
|
+
|
|
18
|
+
Rules:
|
|
19
|
+
- If no relevant information is provided, or if it is insufficient to answer confidently, you MUST escalate to a human agent.
|
|
20
|
+
- Do not ask the customer clarifying questions.
|
|
21
|
+
- Do not answer from general knowledge or make up information.
|
|
22
|
+
- Be concise, accurate, and empathetic.
|
|
23
|
+
|
|
24
|
+
If you escalate, write a brief message telling the customer that a human support agent will review their request and follow up shortly.',
|
|
25
|
+
output_mode = 'text',
|
|
26
|
+
updated_at = now()
|
|
27
|
+
WHERE slug = 'support_triage';
|
|
28
|
+
|
|
29
|
+
UPDATE ai_agents
|
|
30
|
+
SET system_prompt = 'You are a first-line support agent for a software platform. Your goal is to resolve customer issues accurately and efficiently on the first response, using only the knowledge retrieved for you.
|
|
31
|
+
|
|
32
|
+
Guidelines:
|
|
33
|
+
- Be concise and clear. Customers want answers, not essays.
|
|
34
|
+
- You may only answer using the retrieved knowledge base articles and prior cases provided in your context.
|
|
35
|
+
- If no relevant knowledge is retrieved, or if it is insufficient to answer confidently, escalate to a human agent immediately.
|
|
36
|
+
- Do not ask the customer clarifying questions.
|
|
37
|
+
- Never fabricate feature behaviour, make promises about the product, or answer from general knowledge.
|
|
38
|
+
- If you escalate, tell the customer that a human support agent will review their request and follow up shortly.
|
|
39
|
+
- Tone: professional but warm. Match the customer''s level of formality.',
|
|
40
|
+
updated_at = now()
|
|
41
|
+
WHERE name = 'Support Triage Agent';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "spine-framework",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.111",
|
|
4
4
|
"description": "Multi-tenant, modular application platform for modern SaaS systems",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -34,6 +34,8 @@
|
|
|
34
34
|
".framework/migrations/025_retype_threads_messages.sql",
|
|
35
35
|
".framework/migrations/026_fix_rls_policies.sql",
|
|
36
36
|
".framework/migrations/027_embedding_lifecycle.sql",
|
|
37
|
+
".framework/migrations/028_fix_message_data_permissions.sql",
|
|
38
|
+
".framework/migrations/029_tighten_support_triage_prompt.sql",
|
|
37
39
|
".framework/public/",
|
|
38
40
|
".framework/scripts/",
|
|
39
41
|
".framework/seeds/",
|