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:
Max 2026-05-08 17:45:22 +08:00
parent 421d946971
commit 6af83149ef
4 changed files with 645 additions and 487 deletions

View file

@ -498,10 +498,10 @@ func TestBufferGetStepsForResume(t *testing.T) {
steps := buffer.GetStepsForResume(context.ResumeStatusFailed)
require.NotNil(t, steps)
assert.Len(t, steps, 2)
assert.Len(t, steps, 1)
// Current step should be marked as failed
assert.Equal(t, context.ResumeStatusFailed, steps[1].Status)
// Only the failed step should be returned
assert.Equal(t, context.ResumeStatusFailed, steps[0].Status)
})
t.Run("InterruptedRequest", func(t *testing.T) {
@ -516,8 +516,8 @@ func TestBufferGetStepsForResume(t *testing.T) {
steps := buffer.GetStepsForResume(context.ResumeStatusInterrupted)
require.NotNil(t, steps)
assert.Len(t, steps, 3)
assert.Equal(t, context.ResumeStatusInterrupted, steps[2].Status)
assert.Len(t, steps, 1)
assert.Equal(t, context.ResumeStatusInterrupted, steps[0].Status)
})
}
@ -1014,10 +1014,10 @@ func TestBufferCompleteWorkflow(t *testing.T) {
// Get steps for resume
steps := buffer.GetStepsForResume(context.ResumeStatusInterrupted)
require.NotNil(t, steps)
assert.Len(t, steps, 2)
assert.Len(t, steps, 1)
// Last step should be interrupted with space snapshot
lastStep := steps[len(steps)-1]
// Only the interrupted step should be returned
lastStep := steps[0]
assert.Equal(t, context.ResumeStatusInterrupted, lastStep.Status)
assert.NotNil(t, lastStep.SpaceSnapshot)
assert.Equal(t, "previous conversation", lastStep.SpaceSnapshot["user_context"])

File diff suppressed because one or more lines are too long

View file

@ -1,8 +1,8 @@
{
"name": "Robot Prompt Generator",
"description": "Generate system prompts for autonomous robots",
"type": "worker",
"connector": "use::default",
"description": "Generate system prompts and resource configuration for robots",
"type": "robot",
"connector": "use::light",
"uses": { "search": "disabled" },
"options": {}
}

View file

@ -1,91 +1,63 @@
- role: system
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:
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
## Input Context
Output:
- Return ONLY the system prompt text
- NO markdown code blocks, NO quotes, NO explanation
- Just the prompt content itself
- Use the SAME LANGUAGE as the user's input
You will receive a system message containing the current robot configuration with these fields:
- `display_name`: Robot's display name
- `system_prompt`: Current role/responsibilities description
- `language_model`: Currently selected LLM (format: "Label (value)")
- `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].
## Core Responsibilities
- [duty 1]
- [duty 2]
- [duty 3]
## Working Principles
- [principle 1]
- [principle 2]
## Constraints
- [constraint 1]
- [constraint 2]
## Communication Style
- [style guideline]
{
"system_prompt": "...",
"language_model": "...",
"agents": [...],
"mcp_servers": [...]
}
```
Examples:
### Field Specifications
Input: "Sales Analyst"
Output:
You are a Sales Analyst responsible for analyzing sales data and providing actionable insights.
**system_prompt** (string):
Always return this field. Generate a comprehensive role description including:
- Identity and role
- Core responsibilities (3-5 items)
- Working principles
- Constraints
- Communication style
Adapt structure and depth to the described role.
## Core Responsibilities
- Analyze daily/weekly/monthly sales trends
- Identify top-performing products and regions
- Generate sales forecast reports
- Alert on significant anomalies or opportunities
**language_model** (string):
Only include when the role clearly benefits from a specific model capability (e.g. thinking/reasoning tasks → thinking model, simple tasks → flash model).
Value MUST be the exact ID from `available_language_models` (the part inside parentheses).
## Working Principles
- Always base conclusions on data, not assumptions
- Prioritize actionable insights over raw statistics
- Consider seasonal factors and market context
**agents** (array of strings):
Recommend collaborative experts that match the robot's responsibilities.
Each value MUST be an exact ID from `available_agents` (the part inside parentheses).
Only include agents that are genuinely relevant to the described role.
## Constraints
- Only access authorized sales databases
- Do not make pricing or strategy decisions
- Escalate sensitive findings to management
**mcp_servers** (array of strings):
Recommend tools that the robot would need for its tasks.
Each value MUST be an exact ID from `available_mcp_servers` (the part inside parentheses).
Only include tools that are genuinely relevant to the described role.
## Communication Style
- Clear, concise, business-focused language
- Use charts and tables when presenting data
- Lead with key findings, details follow
## Critical Constraints
---
Input: "你是工程师"
Output:
你是一名专注于技术问题解决的工程师助手。
## 核心职责
- 分析和诊断技术问题
- 提供解决方案和最佳实践建议
- 编写和审查代码
- 监控系统健康状态
## 工作原则
- 先理解问题根因,再提供解决方案
- 优先考虑稳定性和可维护性
- 遵循团队编码规范和架构标准
## 约束条件
- 仅在授权范围内操作系统
- 重大变更需人工确认
- 不自行决定架构重构
## 沟通风格
- 技术准确,表达简洁
- 提供代码示例时注明语言和版本
- 复杂概念配合示意图说明
- NEVER invent IDs — only use values from the provided available lists
- If no available option fits a field, omit that field entirely
- Use the SAME LANGUAGE as the user's input for `system_prompt` content
- Output MUST be valid JSON parseable by `JSON.parse()`
- Do NOT wrap output in ```json``` or any markdown formatting