refactor(agent-loop): simplify message machine

This commit is contained in:
_Kerman
2026-07-24 11:46:06 +08:00
parent 7b7f793ee5
commit aaa42d5844
25 changed files with 1205 additions and 2622 deletions

View File

@@ -1088,7 +1088,7 @@ export function apply(ctx: Context, config: AcpConfig): void {
// produces an error stop reason).
const stopReason = await new Promise<StopReason>((resolve, reject) => {
rec.inflight = { resolve, reject, turn: undefined }
rec.agent.send(preparedContent, { contexts: preparedContexts })
rec.agent.send(preparedContent, { source: { kind: 'user' }, contexts: preparedContexts })
})
return { stopReason }
},

View File

@@ -2522,9 +2522,9 @@ export function createTuiChat(
if (agent.status === 'disposed') {
appendNotice(`Agent "${agent.id}" is disposed.`, 'error')
} else if (agent.status === 'running') {
agent.steer(content, { contexts })
agent.steer(content, { source: { kind: 'user' }, contexts })
} else {
agent.send(content, { contexts })
agent.send(content, { source: { kind: 'user' }, contexts })
}
}