π€― 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.
TypeScript agentagent-collaborationagent-harnessloop-engineeringmcppersonal-assistantproactive-agentskillssuper-agenttask-management
π fix(acceptance): echo received evidence fields in submitEvidence rejections (#20541)
Arvin Xu67c6c6fc1cdf
diff --git a/apps/server/src/services/toolExecution/serverRuntimes/acceptanceEvidence.test.ts b/apps/server/src/services/toolExecution/serverRuntimes/acceptanceEvidence.test.tsindex 414f484ab36..dfc89d865c5 100644--- a/apps/server/src/services/toolExecution/serverRuntimes/acceptanceEvidence.test.ts+++ b/apps/server/src/services/toolExecution/serverRuntimes/acceptanceEvidence.test.ts@@ -460,4 +460,62 @@ describe('acceptanceEvidenceRuntime', () => {expect(result).toEqual(expect.objectContaining({ error: 'UNKNOWN_FILE', success: false }));expect(mocks.evidenceCreateMany).not.toHaveBeenCalled();});++ it('echoes received fields when rejecting an empty evidence item', async () => {+ // T-574: a live builder resubmitted {type}-only items six times because the+ // rejection never showed what had arrived. The echo makes the gap visible.+ const runtime = acceptanceEvidenceRuntime.factory({+ operationId: 'evidence-op',+ serverDB: {} as never,+ toolManifestMap: {},+ userId: 'user-1',+ });++ const result = await runtime.submitEvidence({+ checkItemId: 'criterion-1',+ evidence: [{ type: 'text' }],+ });++ expect(result).toEqual(expect.objectContaining({ error: 'INVALID_EVIDENCE', success: false }));+ expect(result.content).toContain('The server received only [type] for the rejected item');+ expect(result.content).toContain('{"type":"text","content":"..."}');+ expect(mocks.evidenceCreateMany).not.toHaveBeenCalled();+ });++ it('echoes "no fields" when an item arrives with nothing recognizable', async () => {+ const runtime = acceptanceEvidenceRuntime.factory({+ operationId: 'evidence-op',+ serverDB: {} as never,+ toolManifestMap: {},+ userId: 'user-1',+ });++ const result = await runtime.submitEvidence({+ checkItemId: 'criterion-1',+ evidence: [{}] as never,+ });++ expect(result).toEqual(expect.objectContaining({ error: 'INVALID_EVIDENCE', success: false }));+ expect(result.content).toContain('The server received only [no fields]');+ });++ it('echoes received fields when rejecting an unbacked visual item', async () => {+ mocks.operationFindById.mockResolvedValue({ id: 'task-op', parentOperationId: null });+ const runtime = acceptanceEvidenceRuntime.factory({+ operationId: 'task-op',+ serverDB: {} as never,+ toolManifestMap: {},+ userId: 'user-1',+ });++ const result = await runtime.submitEvidence({+ checkItemId: 'criterion-1',+ evidence: [{ content: 'I opened the page and captured it', type: 'screenshot' }],+ });++ expect(result).toEqual(+ expect.objectContaining({ error: 'UNBACKED_VISUAL_EVIDENCE', success: false }),+ );+ expect(result.content).toContain('The server received only [content, type] for the rejected item');+ });});diff --git a/apps/server/src/services/toolExecution/serverRuntimes/acceptanceEvidence.ts b/apps/server/src/services/toolExecution/serverRuntimes/acceptanceEvidence.tsindex 712c8552b78..734cf0c1eb1 100644--- a/apps/server/src/services/toolExecution/serverRuntimes/acceptanceEvidence.ts+++ b/apps/server/src/services/toolExecution/serverRuntimes/acceptanceEvidence.ts@@ -19,6 +19,24 @@ import type { ServerRuntimeRegistration } from './types';const PLAN_WAIT_ATTEMPTS = 6;const PLAN_WAIT_INTERVAL_MS = 500;+/**+ * Mirror back the fields the server actually received for an evidence item.+ * Models routinely "remember" writing a payload they never emitted in the+ * arguments JSON (T-574: a builder resubmitted `{type}`-only items six times+ * because the rejection never showed what had arrived, so it could not tell a+ * transport problem from its own output). The echo turns each rejection into a+ * self-diagnosable signal instead of a blind retry loop.+ */+const describeEvidenceFields = (item: SubmitAcceptanceEvidenceParams['evidence'][number]) => {+ const present = (['content', 'description', 'documentId', 'fileId', 'type'] as const).filter(+ (key) => {+ const value = item[key];+ return typeof value === 'string' && value.trim().length > 0;+ },+ );+ return present.length > 0 ? present.join(', ') : 'no fields';+};+class AcceptanceEvidenceExecutionRuntime {constructor(private readonly db: LobeChatDatabase,@@ -151,7 +169,11 @@ class AcceptanceEvidenceExecutionRuntime {const empty = params.evidence.find((item) => !item.content && !item.documentId && !item.fileId);if (empty) {return {- content: 'Every evidence item needs content, a documentId, or a fileId.',+ content:+ 'Every evidence item needs content, a documentId, or a fileId. ' ++ `The server received only [${describeEvidenceFields(empty)}] for the rejected item β ` ++ 'if you intended a payload, write it as literal item fields inside the `evidence` ' ++ 'array of the tool arguments, e.g. {"type":"text","content":"..."}, and resend.',error: 'INVALID_EVIDENCE',success: false,};@@ -183,7 +205,8 @@ class AcceptanceEvidenceExecutionRuntime {`Evidence of type "${unbacked.type}" must reference a real artifact through fileId β ` +'inline content cannot stand in for one. Capture the artifact with a tool that ' +'returns a files.id, then cite that id. If you cannot produce one, submit what you ' +- 'actually observed as type "text" instead of claiming a visual artifact.',+ 'actually observed as type "text" instead of claiming a visual artifact. ' ++ `The server received only [${describeEvidenceFields(unbacked)}] for the rejected item.`,error: 'UNBACKED_VISUAL_EVIDENCE',success: false,};diff --git a/packages/builtin-tool-acceptance-evidence/src/systemRole.ts b/packages/builtin-tool-acceptance-evidence/src/systemRole.tsindex baa46cb6269..4ddfdb07b7c 100644--- a/packages/builtin-tool-acceptance-evidence/src/systemRole.ts+++ b/packages/builtin-tool-acceptance-evidence/src/systemRole.ts@@ -7,5 +7,6 @@ Call listCriteria to read the criteria of the current run, then submit evidence- If you only know an agent document binding id, call listDocuments and use the returned documentId field.- Use fileId only for an id from files.id, such as an uploaded screenshot, video, or file artifact.- Every file artifact submitted with fileId MUST have a non-empty description: explain what the file contains and what it demonstrates for this criterion, so the reviewer knows why to open it. A filename, path, id, or generic label such as "JSON" or "evidence" is insufficient. Apply the same rule to file contents submitted inline. Base the description on the actual artifact; do not invent findings.+- Payload fields (content, description, documentId, fileId) must be written as literal item fields inside the evidence array of the arguments JSON; writing them anywhere else, or only stating the intent in prose, means the server never receives them.- Do not decide whether a criterion passes and do not invent evidence.- If evidence is missing, state that plainly in a note for that criterion.`;