feat: agent session protocol — sessionId, continue, frontmatter retry #385
Reference in New Issue
Block a user
Delete Branch "feat/384-agent-session-protocol"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
What
Agent adapter 协议升级:所有 agent 必须返回 sessionId,支持 continue 追加消息,engine 层 frontmatter 校验失败自动重试。
Why
Changes
workflow-agent-kit (types + run loop)
AgentRunResult新增sessionId: string(必填)AgentOptions新增continue: AgentContinueFnAgentContinueFn(sessionId, message, store) → AgentRunResultcreateAgent输出 JSON{stepHash, sessionId}而非纯 CAS hashagent.continue()重试(最多 2 次)workflow-agent-hermes
runHermes返回 sessionId,session 解析失败直接 throw(不再 fallback raw text)continueHermes— 用hermes chat --resume <sessionId>继续 sessionspawnHermes公共函数,复用 spawn 逻辑cli-workflow (engine)
spawnAgent解析 JSON 输出(向后兼容纯 CAS hash)StepOutput新增sessionId?: stringworkflow-protocol
StepOutput.sessionId?: stringBreaking Changes
AgentOptions新增必填continue方法Closes #384
Breaking changes: - AgentRunResult now requires sessionId field - AgentOptions now requires continue function - Agent CLI outputs JSON {stepHash, sessionId} instead of plain CAS hash - Engine parses JSON output (with legacy CAS hash fallback) New features: - Frontmatter validation retry: if agent output lacks valid frontmatter, engine calls agent.continue() up to 2 times with correction message - Session tracking: sessionId flows from agent → engine → StepOutput - Hermes agent: session parse failure is now a hard error (no raw text fallback) - Hermes agent: supports --resume for continue sessions Closes #384一处需要改:
packages/workflow-protocol/src/types.ts—StepOutput.sessionId?: string违反项目 no-optional-properties 规范,应改为sessionId: string | null。同步更新 engine 侧thread.ts中 legacy fallback 的sessionId: ""→sessionId: null。其余设计 OK:retry 循环逻辑清晰,spawnHermes 提取复用干净,JSON 输出向后兼容。
— 小墨 🖊️
LGTM ✅ optional property 已修正。
— 小墨 🖊️