Skip to content

🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.

🐛 fix: align goal task instructions with implementation outcomes (#19210)

Arvin Xu31401e9eceb0
diff --git a/apps/server/src/services/goal/criteriaGenerator.test.ts b/apps/server/src/services/goal/criteriaGenerator.test.ts
index a5845ddf72b..0e8e3608b0b 100644
--- a/apps/server/src/services/goal/criteriaGenerator.test.ts
+++ b/apps/server/src/services/goal/criteriaGenerator.test.ts
@@ -46,6 +46,35 @@ describe('GoalCriteriaGeneratorService', () => {
);
});
+ it('traces executable decomposition with its updated prompt cohort and validates the output', async () => {
+ const service = new GoalCriteriaGeneratorService({} as never, 'user-1');
+ const draft = {
+ problemStatement: 'Deliver editable office documents.',
+ tasks: [
+ { dependsOn: [], instruction: 'Document current gaps.', title: 'Investigate' },
+ { dependsOn: [0], instruction: 'Implement editing and persistence.', title: 'Implement' },
+ ],
+ };
+ generateObject.mockResolvedValueOnce(draft);
+ await expect(service.decompose({ requirement: 'Upgrade office editing' })).resolves.toEqual(
+ draft,
+ );
+ expect(generateObject).toHaveBeenLastCalledWith(
+ expect.objectContaining({ schema: expect.objectContaining({ name: 'goal_decomposition' }) }),
+ expect.objectContaining({
+ tracing: {
+ promptVersion: 'v4',
+ scenario: 'goal_decompose',
+ schemaName: 'goal_decomposition',
+ },
+ }),
+ );
+ generateObject.mockResolvedValueOnce({ ...draft, tasks: [{ title: 'Missing instruction' }] });
+ await expect(
+ service.decompose({ requirement: 'Upgrade office editing' }),
+ ).resolves.toBeUndefined();
+ });
+
it('rejects criteria containing evidence values outside the supported enums', async () => {
generateObject.mockResolvedValue({
criteria: [
diff --git a/apps/server/src/services/goal/index.test.ts b/apps/server/src/services/goal/index.test.ts
index f659a91a458..a1260c9cda4 100644
--- a/apps/server/src/services/goal/index.test.ts
+++ b/apps/server/src/services/goal/index.test.ts
@@ -840,6 +840,16 @@ describe('GoalService', () => {
'Current Task contract (authoritative execution scope): Generate training data',
);
expect(task?.instruction).toContain('Do not implement, validate, or pre-empt any sibling');
+ expect(task?.instruction).toContain(
+ 'missing or broken capabilities within its scope are work to implement or repair',
+ );
+ expect(task?.instruction).toContain(
+ 'resolve the prerequisite before repeating the same checks',
+ );
+ expect(task?.instruction).toContain(
+ 'For an investigation-only Task, deliver supported findings',
+ );
+ expect(task?.instruction).toContain('do not silently expand into implementation');
expect(task?.instruction).toContain('run it inside this Task');
expect(task?.instruction).toContain(
'Include the relevant artifact contents or exact excerpts and the raw outputs of decisive verification commands',
diff --git a/apps/server/src/services/goal/index.ts b/apps/server/src/services/goal/index.ts
index b28767fae6c..32d6567d79f 100644
--- a/apps/server/src/services/goal/index.ts
+++ b/apps/server/src/services/goal/index.ts
@@ -1616,6 +1616,8 @@ export class GoalService {
description,
'Execute only the Current Task contract. Do not implement, validate, or pre-empt any sibling or downstream Task node, even when the overall goal context describes it.',
'The complete requirements for this Task are included here. Do not inspect unrelated agent documents to recover requirements. This Task carries its own Acceptance: run it inside this Task — drive the real product surface, capture the evidence, and submit it against your own criteria while you work. Submit evidence only; an independent verifier judges whether this Task is complete.',
+ 'For a Task that owns implementation, missing or broken capabilities within its scope are work to implement or repair, not a reason to stop at a capability report or ask the user for a finished implementation. Establish the runnable environment needed to exercise your changes, within the authorized scope. After failed verification, use the feedback to change the implementation or resolve the prerequisite before repeating the same checks; report a blocker only when progress requires unavailable external access, a user decision, or work outside this Task.',
+ 'For an investigation-only Task, deliver supported findings, gaps, and actionable next steps; do not silently expand into implementation. For a verification-only Task, report missing behavior honestly and identify the prerequisite or implementation work needed. Never claim a working product from a report or weaken the Current Task pass conditions to make it pass.',
'Create implementation-level subtasks when useful. Finish the operation once the Current Task deliverable and its concrete evidence are ready; Acceptance verification will decide whether this Task is complete.',
'Make the final delivery self-contained for an independent verifier that may not have workspace access. Include the relevant artifact contents or exact excerpts and the raw outputs of decisive verification commands; file paths and claims that checks passed are not sufficient evidence by themselves.',
// A path on the machine that happened to run the task is not a
diff --git a/packages/prompts/src/chains/goal.test.ts b/packages/prompts/src/chains/goal.test.ts
index 57830227546..287975d5eef 100644
--- a/packages/prompts/src/chains/goal.test.ts
+++ b/packages/prompts/src/chains/goal.test.ts
@@ -2,8 +2,10 @@ import { describe, expect, it } from 'vitest';
import {
chainGoalCriteriaDraft,
+ chainGoalDecompose,
GOAL_CRITERIA_DRAFT_JSON_SCHEMA,
GOAL_CRITERIA_DRAFT_PROMPT_VERSION,
+ GOAL_DECOMPOSE_PROMPT_VERSION,
} from './goal';
describe('chainGoalCriteriaDraft', () => {
@@ -34,3 +36,22 @@ describe('chainGoalCriteriaDraft', () => {
expect(chain.messages[1].content).toContain('Ship a polished v1');
});
});
+
+describe('chainGoalDecompose', () => {
+ it('aligns investigation and implementation responsibilities with their own pass conditions', () => {
+ const requirement = '升级 PPT、Word、Excel 编辑体验,支持编辑、保存和重开。';
+ const { messages } = chainGoalDecompose({ requirement });
+ const prompt = messages[0].content;
+
+ expect(GOAL_DECOMPOSE_PROMPT_VERSION).toBe('v4');
+ expect(messages[1].content).toContain(requirement);
+ expect(prompt).toContain('a request to build, fix, or upgrade requires implementation');
+ expect(prompt).toContain('It may pass when it proves a capability is missing');
+ expect(prompt).toContain(
+ 'assign explicit implementation ownership for every requested capability',
+ );
+ expect(prompt).toContain('include dependent implementation tasks that consume its findings');
+ expect(prompt).toContain('discovering a read-only viewer triggers implementation');
+ expect(prompt).toContain('an investigation-only goal must not become an implementation task');
+ });
+});
diff --git a/packages/prompts/src/chains/goal.ts b/packages/prompts/src/chains/goal.ts
index cb45739e12f..ee0877d0617 100644
--- a/packages/prompts/src/chains/goal.ts
+++ b/packages/prompts/src/chains/goal.ts
@@ -65,7 +65,7 @@ export const GOAL_CRITERIA_DRAFT_JSON_SCHEMA = {
};
/** Bump when the goal decomposition planning prompt meaningfully changes. */
-export const GOAL_DECOMPOSE_PROMPT_VERSION = 'v3';
+export const GOAL_DECOMPOSE_PROMPT_VERSION = 'v4';
export const GOAL_DECOMPOSE_JSON_SCHEMA = {
name: 'goal_decomposition',
@@ -111,13 +111,19 @@ export const chainGoalDecompose = ({
messages: [
{
content: [
- 'You plan the opening exploration structure for a persistent autonomous goal.',
- 'Decompose the goal into the core question it must answer and the independent task directions that together answer it.',
+ 'You plan executable tasks for a persistent autonomous goal.',
+ 'Decompose the goal into the outcome it must achieve and the tasks that together deliver it. Preserve the requested action: a request to build, fix, or upgrade requires implementation, not just investigation or verification.',
'Guidelines:',
'- problemStatement is 1–2 sentences naming the core question or outcome of the goal, in your own words. Never copy the acceptance-criteria list into it.',
'- Return 1–5 tasks. A complex goal (analysis, research, multi-stage delivery) must be split into several directions that can be explored independently or in sequence — e.g. gather the raw material, analyze it from distinct angles, then synthesize. A genuinely small single-step goal may stay as one task.',
'- Each task.title names its direction concisely; titles must be distinct from each other and from the goal name.',
'- Each task.instruction is a complete, self-contained brief for an autonomous agent working on that direction only: what to do, the concrete deliverable, and how that deliverable will be judged. Include only the requirements relevant to this direction — never paste the full goal acceptance list into every task.',
+ '- Align each task\'s actions, deliverable, and pass conditions. Explicitly state whether its responsibility is investigation, implementation, or verification; avoid ambiguous briefs such as "establish a baseline" without naming the expected deliverable.',
+ '- An investigation task delivers evidence-backed current state, gaps, and actionable recommendations. It may pass when it proves a capability is missing; never require an investigation-only task to prove that the missing capability already works.',
+ '- For build, fix, or upgrade goals, assign explicit implementation ownership for every requested capability. Implementation tasks must inspect what exists, implement or repair missing behavior within their scope, establish a runnable environment, and demonstrate the resulting behavior. A capability matrix, blocker report, or repeated checks of an unchanged product cannot substitute for working changes.',
+ '- A verification task consumes an implemented deliverable and judges its behavior. Put successful product behavior criteria on the implementation and verification tasks that own them, not on preliminary investigation. If investigation is needed first, include dependent implementation tasks that consume its findings; do not produce an investigation-and-verification-only plan for a delivery goal.',
+ '- Describe known prerequisite outputs and genuine external dependencies. Do not assume the user will supply an already implemented feature that the goal asks the agent to build. Preserve explicit read-only or other authorization constraints; an investigation-only goal must not become an implementation task.',
+ "- Before returning, check that executing the listed actions can satisfy each task's pass conditions and that the tasks collectively deliver the requested outcome. For example, an editor upgrade may start with a gap report, then implement editing and persistence, then verify save/reopen; the gap report does not require successful editing, and discovering a read-only viewer triggers implementation rather than repeated inspection.",
'- Preserve every concrete URL, scope, constraint, and numeric threshold from the goal in whichever task it belongs to.',
'- Order tasks so that earlier ones produce what later ones consume.',
'- For each task, set dependsOn to the 0-based indices of the earlier tasks whose outputs it consumes; use [] for a task that can start immediately. A pipeline-shaped goal (gather → analyze → synthesize) must express those edges — do not mark every task independent — but never invent a dependency the task does not actually need.',