Skip to content

Streaming Gate: 字数强约束 (soft/hard limit) #18

@DankerMu

Description

@DankerMu

Part of #8

Dependencies: #5 (AI Scene Generation), #16 (Workflow Engine)

Description

实现流式生成时的字数强约束——soft limit 发送提示、hard limit 在中文句号边界截断,支持多轮续写。

OpenSpec Spec: `streaming-gate`

Tasks

  • 3.1 Implement soft_limit / hard_limit calculation
  • 3.2 Implement Chinese sentence boundary detection (regex: [。?!…」』)\n])
  • 3.3 Implement multi-round continuation (max 3 rounds)
  • 3.4 Persist streaming state to workflow_runs table
  • 3.5 Write tests for boundary detection, continuation, state recovery

Acceptance Criteria

  • soft limit 触发后 LLM 收到收尾提示
  • hard limit 在最近中文句号边界截断
  • 字数不足时自动续写(最多 3 轮)
  • 流式状态可持久化和恢复

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions