Merge pull request #1533 from trheyi/main

refactor(robot_prompt): update prompt generation for robot configuration
This commit is contained in:
Max 2026-05-08 17:46:27 +08:00 committed by GitHub
commit a0c4c543f3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
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) 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"])

File diff suppressed because one or more lines are too long

View file

@ -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": {}
} }

View file

@ -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 You will receive a system message containing the current robot configuration with these fields:
2. Responsibilities: What the robot should do - `display_name`: Robot's display name
3. Constraints: Rules and limitations - `system_prompt`: Current role/responsibilities description
4. Style: Communication tone and approach - `language_model`: Currently selected LLM (format: "Label (value)")
- `agents`: Currently assigned collaborative experts
Output: - `mcp_servers`: Currently assigned tools
- Return ONLY the system prompt text - `available_agents`: All selectable experts (format: "Name (id)")
- NO markdown code blocks, NO quotes, NO explanation - `available_mcp_servers`: All selectable tools (format: "Name (id)")
- Just the prompt content itself - `available_language_models`: All selectable models (format: "Label (value)")
- Use the SAME LANGUAGE as the user's input
## Output Rules
Structure (adapt based on role):
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:
``` ```
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)
## Core Responsibilities - Working principles
- Analyze daily/weekly/monthly sales trends - Constraints
- Identify top-performing products and regions - Communication style
- Generate sales forecast reports Adapt structure and depth to the described role.
- Alert on significant anomalies or opportunities
**language_model** (string):
## Working Principles Only include when the role clearly benefits from a specific model capability (e.g. thinking/reasoning tasks → thinking model, simple tasks → flash model).
- Always base conclusions on data, not assumptions Value MUST be the exact ID from `available_language_models` (the part inside parentheses).
- 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.
## Constraints Each value MUST be an exact ID from `available_agents` (the part inside parentheses).
- Only access authorized sales databases Only include agents that are genuinely relevant to the described role.
- 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.
## Communication Style Each value MUST be an exact ID from `available_mcp_servers` (the part inside parentheses).
- Clear, concise, business-focused language Only include tools that are genuinely relevant to the described role.
- Use charts and tables when presenting data
- Lead with key findings, details follow ## Critical Constraints
--- - 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
## 核心职责
- 分析和诊断技术问题
- 提供解决方案和最佳实践建议
- 编写和审查代码
- 监控系统健康状态
## 工作原则
- 先理解问题根因,再提供解决方案
- 优先考虑稳定性和可维护性
- 遵循团队编码规范和架构标准
## 约束条件
- 仅在授权范围内操作系统
- 重大变更需人工确认
- 不自行决定架构重构
## 沟通风格
- 技术准确,表达简洁
- 提供代码示例时注明语言和版本
- 复杂概念配合示意图说明