refactor(instruction): remove default governance instruction and update related tests
This commit is contained in:
+1
-1
Submodule docs updated: 16c8145f78...de9b3d336b
@@ -2,18 +2,7 @@ package instruction
|
|||||||
|
|
||||||
import "strings"
|
import "strings"
|
||||||
|
|
||||||
const defaultGovernanceInstruction = `
|
type Assembler struct{}
|
||||||
你正在一个有明确工程约束的客服系统中工作。
|
|
||||||
执行时必须严格遵守当前注入的项目规则、Agent 规则和技能规则。
|
|
||||||
如果存在工具白名单限制,只能调用当前允许的工具;信息不足时优先追问,不要伪造事实或跳过必要确认。
|
|
||||||
禁止承诺未经系统确认的处理时效、完成时间、回访时间或联系时间。
|
|
||||||
禁止代表人工团队、技术团队、售后团队承诺后续动作,除非当前上下文已有明确的工具结果、人工确认或知识库事实支持。
|
|
||||||
当用户只表示已发送资料、邮件、截图或附件时,只能确认已收到当前消息或建议等待人工确认,不能自行补充内部处理流程、SLA 或跟进安排。
|
|
||||||
`
|
|
||||||
|
|
||||||
type Assembler struct {
|
|
||||||
governanceInstruction string
|
|
||||||
}
|
|
||||||
|
|
||||||
type AssemblerInput struct {
|
type AssemblerInput struct {
|
||||||
AgentInstruction string
|
AgentInstruction string
|
||||||
@@ -36,7 +25,7 @@ type AssemblyResult struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func NewAssembler() *Assembler {
|
func NewAssembler() *Assembler {
|
||||||
return &Assembler{governanceInstruction: strings.TrimSpace(defaultGovernanceInstruction)}
|
return &Assembler{}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *Assembler) Build(input AssemblerInput) string {
|
func (a *Assembler) Build(input AssemblerInput) string {
|
||||||
@@ -47,9 +36,6 @@ func (a *Assembler) Assemble(input AssemblerInput) AssemblyResult {
|
|||||||
parts := make([]string, 0, 4)
|
parts := make([]string, 0, 4)
|
||||||
summary := AssemblySummary{SectionTitles: make([]string, 0, 4)}
|
summary := AssemblySummary{SectionTitles: make([]string, 0, 4)}
|
||||||
governanceInstruction := strings.TrimSpace(input.GovernanceInstruction)
|
governanceInstruction := strings.TrimSpace(input.GovernanceInstruction)
|
||||||
if governanceInstruction == "" && a != nil {
|
|
||||||
governanceInstruction = strings.TrimSpace(a.governanceInstruction)
|
|
||||||
}
|
|
||||||
if governanceInstruction != "" {
|
if governanceInstruction != "" {
|
||||||
parts = append(parts, buildInstructionSection("系统治理规则", governanceInstruction))
|
parts = append(parts, buildInstructionSection("系统治理规则", governanceInstruction))
|
||||||
summary.HasGovernanceRule = true
|
summary.HasGovernanceRule = true
|
||||||
|
|||||||
@@ -26,19 +26,12 @@ func TestAssemblerRespectsProvidedSources(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestAssemblerUsesDefaultGovernanceInstruction(t *testing.T) {
|
func TestAssemblerDoesNotInjectGovernanceInstructionWhenInputIsEmpty(t *testing.T) {
|
||||||
result := NewAssembler().Assemble(AssemblerInput{})
|
result := NewAssembler().Assemble(AssemblerInput{})
|
||||||
expectedSnippets := []string{
|
if result.Text != "" {
|
||||||
"禁止承诺未经系统确认的处理时效、完成时间、回访时间或联系时间。",
|
t.Fatalf("expected empty assembled text, got: %s", result.Text)
|
||||||
"禁止代表人工团队、技术团队、售后团队承诺后续动作",
|
|
||||||
"不能自行补充内部处理流程、SLA 或跟进安排。",
|
|
||||||
}
|
}
|
||||||
for _, snippet := range expectedSnippets {
|
if result.Summary.HasGovernanceRule {
|
||||||
if !strings.Contains(result.Text, snippet) {
|
t.Fatalf("expected no governance rule summary, got %#v", result.Summary)
|
||||||
t.Fatalf("missing governance snippet %q in assembled text: %s", snippet, result.Text)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if !result.Summary.HasGovernanceRule {
|
|
||||||
t.Fatalf("expected governance rule summary, got %#v", result.Summary)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,6 +8,15 @@ import (
|
|||||||
"cs-agent/internal/pkg/toolx"
|
"cs-agent/internal/pkg/toolx"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const defaultGovernanceInstruction = `
|
||||||
|
你正在一个有明确工程约束的客服系统中工作。
|
||||||
|
执行时必须严格遵守当前注入的 Agent 规则和技能规则。
|
||||||
|
如果存在工具白名单限制,只能调用当前允许的工具;信息不足时优先追问,不要伪造事实或跳过必要确认。
|
||||||
|
禁止承诺未经系统确认的处理时效、完成时间、回访时间或联系时间。
|
||||||
|
禁止代表人工团队、技术团队、售后团队承诺后续动作,除非当前上下文已有明确的工具结果、人工确认或知识库事实支持。
|
||||||
|
当用户只表示已发送资料、邮件、截图或附件时,只能确认已收到当前消息或建议等待人工确认,不能自行补充内部处理流程、SLA 或跟进安排。
|
||||||
|
`
|
||||||
|
|
||||||
type ToolAppendixProvider struct{}
|
type ToolAppendixProvider struct{}
|
||||||
|
|
||||||
func NewToolAppendixProvider() *ToolAppendixProvider {
|
func NewToolAppendixProvider() *ToolAppendixProvider {
|
||||||
|
|||||||
Reference in New Issue
Block a user