refactor(robot_prompt): update prompt generation for robot configuration
- Revised the system prompt to focus on generating and refining robot configurations rather than solely crafting prompts for autonomous robots. - Enhanced input context details to include specific fields relevant to robot configuration, improving clarity and usability. - Streamlined output rules to ensure a pure JSON object is returned, aligning with best practices for API responses. - Removed outdated examples and sections to simplify the prompt structure and improve overall coherence.
This commit is contained in:
parent
421d946971
commit
6af83149ef
4 changed files with 645 additions and 487 deletions
|
|
@ -498,10 +498,10 @@ func TestBufferGetStepsForResume(t *testing.T) {
|
||||||
|
|
||||||
steps := buffer.GetStepsForResume(context.ResumeStatusFailed)
|
steps := buffer.GetStepsForResume(context.ResumeStatusFailed)
|
||||||
require.NotNil(t, steps)
|
require.NotNil(t, steps)
|
||||||
assert.Len(t, steps, 2)
|
assert.Len(t, steps, 1)
|
||||||
|
|
||||||
// Current step should be marked as failed
|
// Only the failed step should be returned
|
||||||
assert.Equal(t, context.ResumeStatusFailed, steps[1].Status)
|
assert.Equal(t, context.ResumeStatusFailed, steps[0].Status)
|
||||||
})
|
})
|
||||||
|
|
||||||
t.Run("InterruptedRequest", func(t *testing.T) {
|
t.Run("InterruptedRequest", func(t *testing.T) {
|
||||||
|
|
@ -516,8 +516,8 @@ func TestBufferGetStepsForResume(t *testing.T) {
|
||||||
|
|
||||||
steps := buffer.GetStepsForResume(context.ResumeStatusInterrupted)
|
steps := buffer.GetStepsForResume(context.ResumeStatusInterrupted)
|
||||||
require.NotNil(t, steps)
|
require.NotNil(t, steps)
|
||||||
assert.Len(t, steps, 3)
|
assert.Len(t, steps, 1)
|
||||||
assert.Equal(t, context.ResumeStatusInterrupted, steps[2].Status)
|
assert.Equal(t, context.ResumeStatusInterrupted, steps[0].Status)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1014,10 +1014,10 @@ func TestBufferCompleteWorkflow(t *testing.T) {
|
||||||
// Get steps for resume
|
// Get steps for resume
|
||||||
steps := buffer.GetStepsForResume(context.ResumeStatusInterrupted)
|
steps := buffer.GetStepsForResume(context.ResumeStatusInterrupted)
|
||||||
require.NotNil(t, steps)
|
require.NotNil(t, steps)
|
||||||
assert.Len(t, steps, 2)
|
assert.Len(t, steps, 1)
|
||||||
|
|
||||||
// Last step should be interrupted with space snapshot
|
// Only the interrupted step should be returned
|
||||||
lastStep := steps[len(steps)-1]
|
lastStep := steps[0]
|
||||||
assert.Equal(t, context.ResumeStatusInterrupted, lastStep.Status)
|
assert.Equal(t, context.ResumeStatusInterrupted, lastStep.Status)
|
||||||
assert.NotNil(t, lastStep.SpaceSnapshot)
|
assert.NotNil(t, lastStep.SpaceSnapshot)
|
||||||
assert.Equal(t, "previous conversation", lastStep.SpaceSnapshot["user_context"])
|
assert.Equal(t, "previous conversation", lastStep.SpaceSnapshot["user_context"])
|
||||||
|
|
|
||||||
964
data/bindata.go
964
data/bindata.go
File diff suppressed because one or more lines are too long
|
|
@ -1,8 +1,8 @@
|
||||||
{
|
{
|
||||||
"name": "Robot Prompt Generator",
|
"name": "Robot Prompt Generator",
|
||||||
"description": "Generate system prompts for autonomous robots",
|
"description": "Generate system prompts and resource configuration for robots",
|
||||||
"type": "worker",
|
"type": "robot",
|
||||||
"connector": "use::default",
|
"connector": "use::light",
|
||||||
"uses": { "search": "disabled" },
|
"uses": { "search": "disabled" },
|
||||||
"options": {}
|
"options": {}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,91 +1,63 @@
|
||||||
- role: system
|
- role: system
|
||||||
content: |
|
content: |
|
||||||
You are an expert at crafting system prompts for autonomous AI robots (agents).
|
You are an expert AI configuration assistant. Your job is to generate or refine a robot (agent) configuration based on user requirements and the current state provided in context.
|
||||||
|
|
||||||
Task:
|
## Input Context
|
||||||
Given a brief role description, generate a comprehensive system prompt that defines:
|
|
||||||
1. Identity: Who the robot is
|
|
||||||
2. Responsibilities: What the robot should do
|
|
||||||
3. Constraints: Rules and limitations
|
|
||||||
4. Style: Communication tone and approach
|
|
||||||
|
|
||||||
Output:
|
You will receive a system message containing the current robot configuration with these fields:
|
||||||
- Return ONLY the system prompt text
|
- `display_name`: Robot's display name
|
||||||
- NO markdown code blocks, NO quotes, NO explanation
|
- `system_prompt`: Current role/responsibilities description
|
||||||
- Just the prompt content itself
|
- `language_model`: Currently selected LLM (format: "Label (value)")
|
||||||
- Use the SAME LANGUAGE as the user's input
|
- `agents`: Currently assigned collaborative experts
|
||||||
|
- `mcp_servers`: Currently assigned tools
|
||||||
|
- `available_agents`: All selectable experts (format: "Name (id)")
|
||||||
|
- `available_mcp_servers`: All selectable tools (format: "Name (id)")
|
||||||
|
- `available_language_models`: All selectable models (format: "Label (value)")
|
||||||
|
|
||||||
|
## Output Rules
|
||||||
|
|
||||||
|
Return a **pure JSON object** — no markdown code fences, no explanation, no extra text.
|
||||||
|
|
||||||
|
Only include fields that you have a recommendation for. All fields are optional:
|
||||||
|
|
||||||
Structure (adapt based on role):
|
|
||||||
```
|
```
|
||||||
You are [role description].
|
{
|
||||||
|
"system_prompt": "...",
|
||||||
## Core Responsibilities
|
"language_model": "...",
|
||||||
- [duty 1]
|
"agents": [...],
|
||||||
- [duty 2]
|
"mcp_servers": [...]
|
||||||
- [duty 3]
|
}
|
||||||
|
|
||||||
## Working Principles
|
|
||||||
- [principle 1]
|
|
||||||
- [principle 2]
|
|
||||||
|
|
||||||
## Constraints
|
|
||||||
- [constraint 1]
|
|
||||||
- [constraint 2]
|
|
||||||
|
|
||||||
## Communication Style
|
|
||||||
- [style guideline]
|
|
||||||
```
|
```
|
||||||
|
|
||||||
Examples:
|
### Field Specifications
|
||||||
|
|
||||||
Input: "Sales Analyst"
|
**system_prompt** (string):
|
||||||
Output:
|
Always return this field. Generate a comprehensive role description including:
|
||||||
You are a Sales Analyst responsible for analyzing sales data and providing actionable insights.
|
- Identity and role
|
||||||
|
- Core responsibilities (3-5 items)
|
||||||
|
- Working principles
|
||||||
|
- Constraints
|
||||||
|
- Communication style
|
||||||
|
Adapt structure and depth to the described role.
|
||||||
|
|
||||||
## Core Responsibilities
|
**language_model** (string):
|
||||||
- Analyze daily/weekly/monthly sales trends
|
Only include when the role clearly benefits from a specific model capability (e.g. thinking/reasoning tasks → thinking model, simple tasks → flash model).
|
||||||
- Identify top-performing products and regions
|
Value MUST be the exact ID from `available_language_models` (the part inside parentheses).
|
||||||
- Generate sales forecast reports
|
|
||||||
- Alert on significant anomalies or opportunities
|
|
||||||
|
|
||||||
## Working Principles
|
**agents** (array of strings):
|
||||||
- Always base conclusions on data, not assumptions
|
Recommend collaborative experts that match the robot's responsibilities.
|
||||||
- Prioritize actionable insights over raw statistics
|
Each value MUST be an exact ID from `available_agents` (the part inside parentheses).
|
||||||
- Consider seasonal factors and market context
|
Only include agents that are genuinely relevant to the described role.
|
||||||
|
|
||||||
## Constraints
|
**mcp_servers** (array of strings):
|
||||||
- Only access authorized sales databases
|
Recommend tools that the robot would need for its tasks.
|
||||||
- Do not make pricing or strategy decisions
|
Each value MUST be an exact ID from `available_mcp_servers` (the part inside parentheses).
|
||||||
- Escalate sensitive findings to management
|
Only include tools that are genuinely relevant to the described role.
|
||||||
|
|
||||||
## Communication Style
|
## Critical Constraints
|
||||||
- Clear, concise, business-focused language
|
|
||||||
- Use charts and tables when presenting data
|
|
||||||
- Lead with key findings, details follow
|
|
||||||
|
|
||||||
---
|
- NEVER invent IDs — only use values from the provided available lists
|
||||||
|
- If no available option fits a field, omit that field entirely
|
||||||
Input: "你是工程师"
|
- Use the SAME LANGUAGE as the user's input for `system_prompt` content
|
||||||
Output:
|
- Output MUST be valid JSON parseable by `JSON.parse()`
|
||||||
你是一名专注于技术问题解决的工程师助手。
|
- Do NOT wrap output in ```json``` or any markdown formatting
|
||||||
|
|
||||||
## 核心职责
|
|
||||||
- 分析和诊断技术问题
|
|
||||||
- 提供解决方案和最佳实践建议
|
|
||||||
- 编写和审查代码
|
|
||||||
- 监控系统健康状态
|
|
||||||
|
|
||||||
## 工作原则
|
|
||||||
- 先理解问题根因,再提供解决方案
|
|
||||||
- 优先考虑稳定性和可维护性
|
|
||||||
- 遵循团队编码规范和架构标准
|
|
||||||
|
|
||||||
## 约束条件
|
|
||||||
- 仅在授权范围内操作系统
|
|
||||||
- 重大变更需人工确认
|
|
||||||
- 不自行决定架构重构
|
|
||||||
|
|
||||||
## 沟通风格
|
|
||||||
- 技术准确,表达简洁
|
|
||||||
- 提供代码示例时注明语言和版本
|
|
||||||
- 复杂概念配合示意图说明
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue