feat(agent): form pipeline + collection prompt workflow@20261021

- merge main: workflow/20261021 (collection prompt adds step-5 mandatory
  time readback-confirm before routing; non-motor/0003 branch rework;
  accident_cause unified schema), updated eval suites (photo_skip/
  button_guidance rewritten, no_false trimmed to asr, new
  non_motor_vehicle + time_confirmation with form/reply assertions),
  runner gains form/formMatches/replyMatches expectations
- prompts/collection.md regenerated from 20261021; extraction prompt
  archived (contentExtract description, 6-key whitelist)
- collect: extraction call per turn (extraction.md + current time/form
  injected), merge follows 更新表单 semantics (meaningful values only,
  number/string equality, diff -> turn_patch); accident_fields now uses
  external form keys
- backend: form_update flows to ChatResult and SSE formUpdate event
  (stream emits prefix, FormUpdate, body)
- fields: FORM_FIELDS whitelist with strict type validation
- verified: 155 unit tests; golden evals on real model - photo_skip 4/4,
  no_false 2/2, photo_button_guidance 12/12, non_motor_vehicle 14/14,
  collection_skip 10/12, time_confirmation 1/2; remaining 3 failures are
  model sequence/literal-template adherence, recorded in plan appendix
This commit is contained in:
Eric Wang
2026-10-21 17:10:33 +08:00
parent 4ead44ef3f
commit 74db6be385
9 changed files with 291 additions and 109 deletions
+15 -3
View File
@@ -15,7 +15,14 @@
from collections.abc import AsyncIterator
from ..agent.graph import GraphDeps, build_graph, workflow_fake_llm
from .chat import ChatInput, ChatResult, ChatStreamEvent, ChatBackend, TextDelta
from .chat import (
ChatBackend,
ChatInput,
ChatResult,
ChatStreamEvent,
FormUpdate,
TextDelta,
)
class LangGraphBackend(ChatBackend):
@@ -54,7 +61,7 @@ class LangGraphBackend(ChatBackend):
return ChatResult(
content = result["response_text"],
status_code = None,
form_update = {}
form_update = result.get("turn_patch") or {}
)
async def stream(self, chat_input: ChatInput) -> AsyncIterator[ChatStreamEvent]:
@@ -67,7 +74,12 @@ class LangGraphBackend(ChatBackend):
“尚未接入模型增量输出”(作业 8 改为真实增量)。
"""
result = await self.complete(chat_input)
prefix, _, body = result.content.partition("</state>")
prefix, sep, body = result.content.partition("</state>")
if not sep:
yield TextDelta(result.content)
return
yield TextDelta(prefix + "</state>")
if result.form_update:
yield FormUpdate(result.form_update)
if body:
yield TextDelta(body)