🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.
TypeScript agentagent-collaborationagent-harnessloop-engineeringmcppersonal-assistantproactive-agentskillssuper-agenttask-management
⚡️ perf(agent-signal,prompts): better prompts and explicit rules (#14882)
Nekoe50e6859e707
diff --git a/packages/prompts/src/prompts/agentSkillManager/authoring.test.ts b/packages/prompts/src/prompts/agentSkillManager/authoring.test.tsindex d830d2bd394..0580f119d54 100644--- a/packages/prompts/src/prompts/agentSkillManager/authoring.test.ts+++ b/packages/prompts/src/prompts/agentSkillManager/authoring.test.ts@@ -53,4 +53,17 @@ describe('agent skill authoring prompts', () => {expect(role).toContain('runtime will not infer');}});++ /**+ * @example+ * Create authoring keeps trigger/provenance context out of persisted skill body markdown.+ */+ it('keeps activation and provenance sections out of create bodyMarkdown', () => {+ expect(AGENT_SKILL_CREATE_SYSTEM_ROLE).toContain(+ 'Put activation conditions only in description',+ );+ expect(AGENT_SKILL_CREATE_SYSTEM_ROLE).toContain(+ 'Do not add bodyMarkdown sections named Trigger',+ );+ });});diff --git a/packages/prompts/src/prompts/agentSkillManager/create.ts b/packages/prompts/src/prompts/agentSkillManager/create.tsindex 00f93142b8d..7ee91d6ff8f 100644--- a/packages/prompts/src/prompts/agentSkillManager/create.ts+++ b/packages/prompts/src/prompts/agentSkillManager/create.ts@@ -57,6 +57,8 @@ Rules:- Prefer concise, future-facing procedural knowledge. The body should say what to do after activation, not why this skill was created.- Do not create auxiliary docs or resource files. v1 output is one SKILL.md body represented by bodyMarkdown.- If the source already resembles SKILL.md but is poorly organized, normalize it into a clear skill body instead of preserving the messy shape.+- Put activation conditions only in description, not in bodyMarkdown.+- Do not add bodyMarkdown sections named Trigger, When to use, Source Feedback, Evidence, Context, or Reason.Writing quality:- Start bodyMarkdown with a clear H1 title.diff --git a/packages/prompts/src/prompts/agentSkillManager/decision.test.ts b/packages/prompts/src/prompts/agentSkillManager/decision.test.tsindex 0133b84ce25..c605ffd9937 100644--- a/packages/prompts/src/prompts/agentSkillManager/decision.test.ts+++ b/packages/prompts/src/prompts/agentSkillManager/decision.test.ts@@ -20,6 +20,12 @@ describe('agentSkillManager decision prompt', () => {expect(AGENT_SKILL_MANAGER_DECISION_SYSTEM_ROLE).toContain('targetSkillRefs');expect(AGENT_SKILL_MANAGER_DECISION_SYSTEM_ROLE).toContain('agent document ids');expect(AGENT_SKILL_MANAGER_DECISION_SYSTEM_ROLE).toContain('not backing documents.id values');+ expect(AGENT_SKILL_MANAGER_DECISION_SYSTEM_ROLE).toContain(+ 'documentRefs may contain only agent document ids',+ );+ expect(AGENT_SKILL_MANAGER_DECISION_SYSTEM_ROLE).toContain(+ 'documentRefs must not contain messageId',+ );expect(AGENT_SKILL_MANAGER_DECISION_SYSTEM_ROLE).toContain('hintIsSkill:true as strong evidence, not automatic authorization',);diff --git a/packages/prompts/src/prompts/agentSkillManager/decision.ts b/packages/prompts/src/prompts/agentSkillManager/decision.tsindex fc9831563e8..ff49aeb7b00 100644--- a/packages/prompts/src/prompts/agentSkillManager/decision.ts+++ b/packages/prompts/src/prompts/agentSkillManager/decision.ts@@ -59,6 +59,9 @@ Rules:- When candidateSkills are provided, targetSkillRefs must be selected from candidateSkills[].id.- targetSkillRefs are agent document ids for managed skill bundle documents.- targetSkillRefs are not backing documents.id values, package names, filenames, or display names.+- documentRefs may contain only agent document ids returned by read-only document tools or same-turn document outcomes.+- documentRefs must not contain messageId, sourceId, topicId, operationId, filenames, titles, or package names.+- If there is no concrete agent document evidence, documentRefs must be [].- No-op for generic praise, style preferences, memory-like facts, or insufficient context.- Reject when the user asked for document-only behavior, forbids skill conversion, or same-turn document evidence makes skill mutation unsafe.- Use read-only tools to inspect same-turn document outcomes before guessing from document names or content shape.diff --git a/src/server/services/agentSignal/policies/analyzeIntent/actions/__tests__/skillManagement.test.ts b/src/server/services/agentSignal/policies/analyzeIntent/actions/__tests__/skillManagement.test.tsindex a5d17176a65..9e72275988e 100644--- a/src/server/services/agentSignal/policies/analyzeIntent/actions/__tests__/skillManagement.test.ts+++ b/src/server/services/agentSignal/policies/analyzeIntent/actions/__tests__/skillManagement.test.ts@@ -1273,6 +1273,70 @@ describe('defineSkillManagementActionHandler', () => {});});+ /**+ * @example+ * A create decision ignores message ids accidentally returned in documentRefs.+ */+ it('ignores non-agent-document ids in create decision documentRefs', async () => {+ // ROOT CAUSE:+ //+ // The skill decision model may confuse the eval/client messageId with source document ids+ // because both are present in the decision prompt. Querying agent_documents.id with that+ // messageId fails at Postgres UUID coercion before skill creation can run.+ //+ // We fixed this by only reading create source documents when documentRefs contains a real+ // agent_documents.id UUID. Create can still proceed from the feedback and turn context.+ skillDecisionRunner.mockResolvedValue({+ action: 'create',+ documentRefs: ['eval-agent-signal-message-feedback-should-create-skill-1'],+ reason: 'reusable workflow',+ });++ const handler = defineSkillManagementActionHandler({+ db: {} as never,+ selfIterationEnabled: true,+ skillCreateRunner,+ skillDecisionRunner,+ userId: 'user_1',+ });++ const result = await handler.handle(+ {+ actionId: 'act_skill_create_with_message_ref',+ actionType: 'action.skill-management.handle',+ chain: { chainId: 'chain_1', rootSourceId: 'source_1' },+ payload: {+ agentId: 'agent_1',+ idempotencyKey: 'source_1:skill:create_with_message_ref',+ message: 'Create a reusable PR review checklist.',+ },+ signal: {+ signalId: 'sig_1',+ signalType: 'signal.feedback.domain.skill',+ },+ source: { sourceId: 'source_1', sourceType: 'agent.user.message' },+ timestamp: 1,+ },+ context,+ );++ expect(skillCreateRunner).toHaveBeenCalledWith(+ expect.not.objectContaining({+ sourceAgentDocumentId: 'eval-agent-signal-message-feedback-should-create-skill-1',+ }),+ );+ expect(createSkill).toHaveBeenCalledWith(+ expect.objectContaining({+ agentId: 'agent_1',+ sourceAgentDocumentId: undefined,+ }),+ );+ expect(result).toMatchObject({+ output: { decision: { action: 'create' } },+ status: 'applied',+ });+ });+/*** @example* Duplicate skill creation is reported as skipped while preserving the create decision.diff --git a/src/server/services/agentSignal/policies/analyzeIntent/actions/skillManagement.ts b/src/server/services/agentSignal/policies/analyzeIntent/actions/skillManagement.tsindex 189f7e4a67c..92b08fd8781 100644--- a/src/server/services/agentSignal/policies/analyzeIntent/actions/skillManagement.ts+++ b/src/server/services/agentSignal/policies/analyzeIntent/actions/skillManagement.ts@@ -1405,6 +1405,11 @@ const isMaintainerDecision = (): decision is SkillManagementDecision & { action: 'consolidate' | 'refine' } =>decision.action === 'refine' || decision.action === 'consolidate';+/**+ * Checks whether a model-selected source document ref can be queried as agent_documents.id.+ */+const isAgentDocumentDatabaseId = (value: string) => z.string().uuid().safeParse(value).success;+const toSkillActionTarget = (skill: Pick<SkillSummary, 'bundle' | 'description' | 'index' | 'title'>,): SkillManagementActionTarget => ({@@ -1608,6 +1613,10 @@ const readCreateSourceDocument = async (return {};}+ if (!isAgentDocumentDatabaseId(sourceAgentDocumentId)) {+ return {};+ }+const snapshot = await new AgentDocumentsService(options.db,options.userId,@@ -1648,7 +1657,8 @@ const runCreateWorkflow = async (candidateSkills: input.candidateSkills,decision,signal: input,- ...source,+ sourceAgentDocumentId: source?.sourceAgentDocumentId,+ sourceDocumentContent: source?.sourceDocumentContent,}),),);diff --git a/src/server/services/agentSignal/policies/analyzeIntent/feedbackAction.ts b/src/server/services/agentSignal/policies/analyzeIntent/feedbackAction.tsindex cf7d1e451a7..32b2659a9de 100644--- a/src/server/services/agentSignal/policies/analyzeIntent/feedbackAction.ts+++ b/src/server/services/agentSignal/policies/analyzeIntent/feedbackAction.ts@@ -89,6 +89,10 @@ const isMemorySignal = (signal: FeedbackDomainSignal): signal is SignalFeedbackDreturn signal.payload.target === 'memory';};+const isPromptSignal = (signal: FeedbackDomainSignal) => {+ return signal.payload.target === 'prompt';+};+const isDirectSkillDecisionSignal = (signal: FeedbackDomainSignal,): signal is NonSatisfiedSkillActionServiceSignal => {@@ -427,6 +431,13 @@ export const createFeedbackActionPlannerSignalHandler = (};}+ if (isPromptSignal(signal)) {+ // TODO: Add a durable prompt/persona artifact path before this lane can mutate anything.+ // The classifier can recognize prompt-shaped feedback today, but there is no proposal+ // payload, apply/revert path, or UI projection that can prove a safe durable change yet.+ return;+ }+if (isDirectSkillDecisionSignal(signal)) {if (detectClientStartNeedsSkillIntentRecord(signal)) {await options.procedure?.procedureState?.skillIntentRecords?.write(diff --git a/src/server/services/agentSignal/policies/types.ts b/src/server/services/agentSignal/policies/types.tsindex ba48eea928c..71a6fef0b7d 100644--- a/src/server/services/agentSignal/policies/types.ts+++ b/src/server/services/agentSignal/policies/types.ts@@ -33,6 +33,9 @@ export const AGENT_SIGNAL_POLICY_SIGNAL_TYPES = {/** Server-owned built-in AgentSignal action type identifiers. */export const AGENT_SIGNAL_POLICY_ACTION_TYPES = {nudgeHandle: 'action.nudge.handle',+ // TODO: Keep persona actions reserved until Agent Signal has a durable prompt/persona artifact,+ // proposal payload, apply/revert path, and UI projection. The current analyze-intent path must+ // not silently mutate persona state from prompt-shaped feedback.personaHandle: 'action.persona.handle',skillManagementHandle: 'action.skill-management.handle',userMemoryHandle: 'action.user-memory.handle',