A2-A7 全部补齐到验收线;顺手把几处「门拦住却不给路」的坑填了
活动:A2 选型 / A3 寻源 / A4 定价 / A6 议价 / A7 归档五件各补成真活动包 —— 契约宽进(input.required 空,归一在活动内)、台账必填声明(含行级 requiredWhen)、 入场哨兵与 L1/L2 判据一律读基座数、两份件(在办可编辑 + 办结静态快照)、 三案例常备、包内自测。e2e 各三案例 released、行动被拒 0、发口正确、提交闸每单真拦。 基座(共享面,改一处影响所有活动,故每处都带回归): · 重发判断走在站上场之前 —— 人答完那步常已收掉,readyToWork 先抛「不能再往它上面挂活」, 于是「重发已答过的卡 = 无事发生」这条唯一活路在最需要时够不着,A1 基线当场熔断; · 决策卡补幂等兜底(与执行工单同一把尺):头两次无事发生,第三次起才算被拒; · 输出没成形先就地重问一次,原话进工作日志、不再摆上卡面; · 工具调用读数 tool_<名>_calls —— 「机检只读基座数」这条纪律第一次覆盖到工具; · 执行卡 steps/standard 补进出参 schema(从前能到卡面全靠厂商 JSON 模式宽松); · 件的就地更新改逐节点 morph,保存先把新值镜像进只读那份 —— 不闪、不等回声。 A1(基线,全程守住):措辞三档对齐(必填/建议/选填)、禁止拿历史价当客户目标价、 卡骨架从步骤剧本搬进说明书(压成一拍连做时剧本没摊开,会发出没有指导书的裸卡)。 契约两处**新增可选字段**(非破坏):FieldDeclaration.requiredWhen、工单 finalHtml; api-report 同批更新。docs/adr 与 docs/archive 的 13 份文件在工作树里不见了, 本次予以恢复而非提交删除。 门禁:typecheck / lint / depcruise / test(1366)全绿。 Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,108 @@
|
||||
/**
|
||||
* 输出不成形的就地重问(2026-08-03 用户实测送来的单逼出来的)。
|
||||
*
|
||||
* 病:关思考的模型偶发把一拍输出写坏(整串行动一个都不认识),从前一次没认出
|
||||
* 就直接发「需要你判断下一步」的兜底卡,还把 JSON 原话整段摆在卡面上 ——
|
||||
* 人打开工单看到的是一坨代码(用户原话:「卡片里又是乱七八糟的东西」)。
|
||||
*
|
||||
* 法:第一次没认出 → 原文经 `note` 存进工作日志(内部痕),附「只输出 JSON」
|
||||
* 就地再问一次;第二次仍不成形才交人,卡面只说人话、不摆原话。
|
||||
* 这里用假网关钉死三件事:重问只有一次、原文进痕、好输出不白重问。
|
||||
* (ModelGateway 是外界 —— LLM 厂商 —— 的缝,录制回放替身合规。)
|
||||
*/
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import type { EnabledSet } from '@modules/loop-engine';
|
||||
import type { ModelCall, ModelGateway, ModelResult } from '@modules/llm';
|
||||
import type { TaskId } from '@contracts';
|
||||
import { createAgentRunner } from '../agent-runner.ts';
|
||||
|
||||
const ENABLED: EnabledSet = {
|
||||
entries: [{ id: 'T1', name: '干活', type: 'humanTask', requiresManualStart: false, discretionary: false }],
|
||||
inProgress: [],
|
||||
judgements: [],
|
||||
gaps: ['缺记录'],
|
||||
activeStages: [],
|
||||
};
|
||||
|
||||
/** 按序回放给定出参的假网关 —— 超出名单就重复最后一个 */
|
||||
function gatewayOf(outputs: Array<{ object: unknown; text: string }>): { gateway: ModelGateway; calls: ModelCall[] } {
|
||||
const calls: ModelCall[] = [];
|
||||
const gateway: ModelGateway = {
|
||||
mode: 'replay',
|
||||
resolve: () => Promise.reject(new Error('测试里用不到 resolve')),
|
||||
generate: (call) => {
|
||||
calls.push(call);
|
||||
const next = outputs[Math.min(calls.length - 1, outputs.length - 1)];
|
||||
if (next === undefined) return Promise.reject(new Error('名单空着'));
|
||||
const result: ModelResult = {
|
||||
text: next.text,
|
||||
object: next.object,
|
||||
usage: { inputTokens: 10, outputTokens: 5, latencyMs: 1 },
|
||||
binding: { name: 'fake', provider: 'deepseek', model: 'fake' },
|
||||
mode: 'replay',
|
||||
};
|
||||
return Promise.resolve(result);
|
||||
},
|
||||
withMode: () => gateway,
|
||||
};
|
||||
return { gateway, calls };
|
||||
}
|
||||
|
||||
function runnerOf(outputs: Array<{ object: unknown; text: string }>) {
|
||||
const { gateway, calls } = gatewayOf(outputs);
|
||||
const notes: Array<{ title: string; raw: string }> = [];
|
||||
const runner = createAgentRunner({
|
||||
gateway,
|
||||
modelOf: () => Promise.resolve('fake'),
|
||||
onUsage: () => Promise.resolve(),
|
||||
note: (_taskId, title, raw) => {
|
||||
notes.push({ title, raw });
|
||||
return Promise.resolve();
|
||||
},
|
||||
});
|
||||
const decide = () =>
|
||||
runner.decide({
|
||||
taskId: 'task-1' as TaskId,
|
||||
narrative: '(空)',
|
||||
enabled: ENABLED,
|
||||
scope: {},
|
||||
writable: [],
|
||||
tools: [],
|
||||
});
|
||||
return { decide, calls, notes };
|
||||
}
|
||||
|
||||
const GOOD = { object: { say: '收工', actions: [{ kind: 'finish', itemId: 'T1' }] }, text: '{"say":"收工"}' };
|
||||
const BAD = { object: { say: '', actions: [{ kind: '胡编的' }] }, text: '再连贯的散文也不是行动串' };
|
||||
|
||||
describe('输出不成形先就地重问,别一抖就叫人', () => {
|
||||
it('第一拍坏、重问好 → 两次调用、原文进痕一条、返回的是好行动', async () => {
|
||||
const { decide, calls, notes } = runnerOf([BAD, GOOD]);
|
||||
const turn = await decide();
|
||||
expect(calls).toHaveLength(2);
|
||||
// 重问那一次要把「只输出 JSON」的硬提示带上 —— 不带等于原样再撞一次
|
||||
expect(calls[1]?.prompt).toContain('不是合法的行动 JSON');
|
||||
expect(notes).toHaveLength(1);
|
||||
expect(notes[0]?.raw).toContain('散文');
|
||||
expect(turn.actions[0]?.kind).toBe('finish');
|
||||
});
|
||||
|
||||
it('两拍都坏 → 就收手交人,不无限重问;卡面不摆模型原话', async () => {
|
||||
const { decide, calls } = runnerOf([BAD, BAD]);
|
||||
const turn = await decide();
|
||||
expect(calls).toHaveLength(2);
|
||||
const action = turn.actions[0];
|
||||
expect(action?.kind).toBe('human');
|
||||
if (action?.kind !== 'human') return;
|
||||
expect(action.card['modelReply']).toBeUndefined();
|
||||
expect(String(action.card['reason'])).toContain('工作日志');
|
||||
});
|
||||
|
||||
it('第一拍就是好的 → 只调一次,不白烧重问', async () => {
|
||||
const { decide, calls, notes } = runnerOf([GOOD]);
|
||||
const turn = await decide();
|
||||
expect(calls).toHaveLength(1);
|
||||
expect(notes).toHaveLength(0);
|
||||
expect(turn.actions[0]?.kind).toBe('finish');
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user