Skip to content

feat(loop): prompt cue guidance for structured/stepwise output - #223

Open
raymondginger2018-sudo wants to merge 1 commit into
HKUDS:mainfrom
raymondginger2018-sudo:feat/prompt-cue
Open

feat(loop): prompt cue guidance for structured/stepwise output#223
raymondginger2018-sudo wants to merge 1 commit into
HKUDS:mainfrom
raymondginger2018-sudo:feat/prompt-cue

Conversation

@raymondginger2018-sudo

Copy link
Copy Markdown
Contributor

设计说明

问题:agent 输出经常包含 free-form filler(复述任务、无关客套),多步任务容易脱轨。系统 prompt 已经很重,不适合再往里面堆指令。

解法:一条简短的 prompt cue——在 routed request 上附加 transient context 消息,提示模型 stepwise 工作、先验证再断言、引用工具结果时带标签。

关键设计决策

  • 通过 transient_context_messages 注入,不会出现在 compaction summarizer 的 prefix 中,避免破坏 prefix/KV cache 对齐
  • 是 advisory prose 而非硬 schema——永远不会与调用方提供的 JSON schema 或 structured-output 模式冲突
  • 环境变量 DEEPCODE_PROMPT_CUE 开关(默认开,设 0/false/off 关闭)

边界情况

  • 关闭时返回空 tuple,完全不改变现有行为
  • 只有一条 user-role 消息,确保被放在 canonical user request 之前

测试建议:验证 build_cue_context() 开关逻辑 + 返回结构;prompt_cue_enabled() 的环境变量解析

@raymondginger2018-sudo

Copy link
Copy Markdown
Contributor Author

关键设计决策补充

  • 为什么用 transient context 而非改 system prompt? 避免破坏 compaction prefix 对齐。runner 在压缩时复用 routed request 的 prefix/KV cache,如果 system prompt 每次都变,缓存失效,成本升高。
  • 为什么是 user role 而不是 system role? 这样 runner 的 _with_transient_context 会把它放在 canonical user request 之前(user-priority),确保 cue 信息紧邻用户实际请求。
  • 什么场景关掉? 如果是结构化输出模式(JSON schema / tool_use),cue 的 prose 表述可能与 schema 矛盾——此时设 DEEPCODE_PROMPT_CUE=off

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant