first commit
This commit is contained in:
33
async-agent-lab/live/scenarios/sync.ts
Normal file
33
async-agent-lab/live/scenarios/sync.ts
Normal file
@@ -0,0 +1,33 @@
|
||||
import type { Runtime } from '../runtime.ts';
|
||||
import { aiwork } from '../evidence.ts';
|
||||
import { baseTools } from '../tools.ts';
|
||||
import type { ScenarioInfo } from '../types.ts';
|
||||
|
||||
export const sync: ScenarioInfo = {
|
||||
id: 'sync',
|
||||
task: '查 AiWork 本周的 Git 提交,归纳几项研发进展。',
|
||||
system: `你是周报 Agent。先调用 bash,参数为 {"command":"git log","cwd":${JSON.stringify(aiwork)}}。
|
||||
command 逐字使用 git log。工具会核对本周时间范围、作者和 Git。
|
||||
收到结果后立即停止调用工具,按成果合并,用中文简短总结。只依据实际提交,勿声称合并或上线。无需写文件。`,
|
||||
tools: baseTools(),
|
||||
};
|
||||
|
||||
// stage:start
|
||||
export async function runSync(loop: Runtime) {
|
||||
const { history } = loop;
|
||||
let choice = 'bash';
|
||||
for (let step = 0; step < 6; step++) {
|
||||
const reply = await loop.callModel(history, choice);
|
||||
history.push(reply);
|
||||
if (!reply.tool_calls?.length && choice === 'none')
|
||||
return reply.content;
|
||||
|
||||
for (const call of reply.tool_calls ?? []) {
|
||||
const { result } = await loop.runTool(call);
|
||||
if (result.startsWith('{"exit_code":0,')) choice = 'none';
|
||||
history.push({ role: 'tool', tool_call_id: call.id, content: result });
|
||||
}
|
||||
}
|
||||
throw new Error('超过演示步数');
|
||||
}
|
||||
// stage:end
|
||||
Reference in New Issue
Block a user