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