refactor agent pre-step inbox lifecycle
This commit is contained in:
@@ -8,7 +8,7 @@ import type { Context } from 'cordis'
|
||||
import type { Session } from '@deepseek-ai/dsh-session'
|
||||
import type { StreamChunk } from '@deepseek-ai/dsh-llm'
|
||||
import { TOOL_ABORTED_BEFORE_DISPATCH, type ToolExecutionResult } from '@deepseek-ai/dsh-tools'
|
||||
import type {} from '@deepseek-ai/dsh-agent'
|
||||
import type { PreStepDecision } from '@deepseek-ai/dsh-agent'
|
||||
import type {} from '@deepseek-ai/dsh-session-persistence'
|
||||
|
||||
/** Cordis plugin name used by Loader diagnostics. */
|
||||
@@ -76,5 +76,8 @@ export function apply(ctx: Context): void {
|
||||
|
||||
// Before each request, persist everything committed by the preceding step;
|
||||
// the first step's call is an intentional no-op beyond any prompt intake.
|
||||
ctx.on('agent/step', (agent): Promise<void> => ctx.sessions.flush(agent.session))
|
||||
ctx.on('agent/pre-step', async (agent, _messages, _context, next): Promise<PreStepDecision> => {
|
||||
await ctx.sessions.flush(agent.session)
|
||||
return next()
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user