fix(agent-loop): preserve unified send contracts

This commit is contained in:
_Kerman
2026-07-24 13:18:57 +08:00
parent aaa42d5844
commit 7d5c8b12c0
19 changed files with 476 additions and 223 deletions
+1 -5
View File
@@ -106,7 +106,7 @@ export function apply(ctx: Context): void {
/** Read only when the exact Agent remains live. */
function currentGoal(state: DriverState): GoalView | undefined {
if (ctx.agents.get(state.agent.id) !== state.agent || state.agent.status === 'disposed') return undefined
if (ctx.agents.get(state.agent.id) !== state.agent) return undefined
return ctx.goals.get(state.agent)
}
@@ -297,10 +297,6 @@ export function apply(ctx: Context): void {
})
ctx.on('agent/status', (agent, status) => {
const state = stateFor(agent)
if (status === 'disposed') {
state.stopping = true
return
}
if (status === 'idle') {
state.competingQueued = false
requestDrive(state)
+1 -1
View File
@@ -346,7 +346,7 @@ export class GoalService extends Service {
/** Enforce exact live-agent identity rather than trusting a matching id. */
private assertLive(agent: Agent): void {
if (this.ctx.agents.get(agent.id) !== agent || agent.status === 'disposed') {
if (this.ctx.agents.get(agent.id) !== agent) {
throw new GoalError(`agent "${agent.id}" is not live in this registry`, 'GOAL_AGENT_NOT_LIVE')
}
}