fix(agent): restore active-task routing and active-mode validation observation
Memind CI / Test, build, and release guards (push) Successful in 5m23s
Memind CI / Test, build, and release guards (push) Successful in 5m23s
Keep correction follow-ups on Agent using session transcript and active task context, and let Page Data validation reach Orchestrator when mode is active instead of requiring shadowEngine. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -9,9 +9,66 @@ import {
|
||||
assertRequiredImageGenerationCompleted,
|
||||
createAgentRunGateway,
|
||||
normalizeAgentRunWorkerIdentity,
|
||||
resolveActiveTaskContext,
|
||||
resolveRouterTranscript,
|
||||
resolveRequiredCodeExecutor,
|
||||
} from './agent-run-gateway.mjs';
|
||||
|
||||
test('resolveActiveTaskContext returns failed agent task metadata for same session', async () => {
|
||||
const now = Date.now();
|
||||
const pool = {
|
||||
async query() {
|
||||
return [[{
|
||||
id: 'run-failed-1',
|
||||
status: 'failed',
|
||||
error_message: 'delivery failed',
|
||||
created_at: now - 60_000,
|
||||
updated_at: now - 30_000,
|
||||
intent_json: {
|
||||
route: 'agent_orchestration',
|
||||
suggestedSkill: 'page-data-collect',
|
||||
reason: '页面需要数据交互与持久化',
|
||||
},
|
||||
}]];
|
||||
},
|
||||
};
|
||||
const context = await resolveActiveTaskContext(pool, {
|
||||
userId: 'user-1',
|
||||
sessionId: '20260827_3',
|
||||
excludeRunId: 'run-current',
|
||||
nowMs: () => now,
|
||||
});
|
||||
assert.equal(context?.hasRecentAgentTask, true);
|
||||
assert.equal(context?.lastRunFailed, true);
|
||||
assert.equal(context?.lastSuggestedSkill, 'page-data-collect');
|
||||
});
|
||||
|
||||
test('resolveRouterTranscript formats recent portal snapshot messages', async () => {
|
||||
const transcript = await resolveRouterTranscript({
|
||||
async get(sessionId) {
|
||||
assert.equal(sessionId, '20260827_3');
|
||||
return {
|
||||
messages: [
|
||||
{
|
||||
role: 'user',
|
||||
metadata: { displayText: '帮我做台账' },
|
||||
content: [{ type: 'text', text: '帮我做台账' }],
|
||||
},
|
||||
{
|
||||
role: 'assistant',
|
||||
content: [{ type: 'text', text: '正在创建页面。' }],
|
||||
},
|
||||
],
|
||||
};
|
||||
},
|
||||
}, {
|
||||
sessionId: '20260827_3',
|
||||
excludeLatestUserText: '继续完善',
|
||||
});
|
||||
assert.match(transcript, /用户:帮我做台账/);
|
||||
assert.match(transcript, /助手:正在创建页面/);
|
||||
});
|
||||
|
||||
test('required code executor is read from run metadata', () => {
|
||||
assert.equal(resolveRequiredCodeExecutor({
|
||||
metadata: { memindRun: { executor: 'AIDER' } },
|
||||
|
||||
Reference in New Issue
Block a user