MoonshotAI / MoonshotAI/kimi-code
feat: 支持 prompt/SDK 的结构化最终输出 schema
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 7.5k
- Forks
- 1.2k
- Avg merge
- 11h 53m
- Merged PRs (30d)
- 350
Description
What feature would you like to see?
希望 Kimi Code 在非交互 prompt 模式和 SDK 中支持“结构化最终输出 schema”。
当前 kimi -p 已有 --output-format text|stream-json,适合读取文本结果或消费事件流,但它不能约束最终 assistant response 的结构。对于 CI、自动化脚本、评审机器人、批量代码分析等场景,用户通常希望得到可验证的 JSON 对象,而不是再从自然语言里解析。
一个可能的接口方向:
- CLI:支持类似
kimi -p "..." --output-schema schema.json的参数,要求最终回答符合 JSON Schema。 - SDK:在 prompt/turn 选项里支持
outputSchema,让调用方直接传入 JSON Schema 对象。 - 运行行为:如果模型输出不符合 schema,可以重试、返回结构化 validation error,或在
stream-json中额外发出验证失败事件。 - 输出行为:继续保留现有
stream-json事件流;schema 只约束最终 answer,不影响工具调用事件本身。
Additional information
我基于当前最新 upstream/main 做了代码和 issue/PR 去重检查:
- 当前 CLI 只暴露
--output-format <format>,可选值为text/stream-json。 PromptOutputFormat类型目前也是text | stream-json。runPromptTurn直接收集 assistant delta 并输出,没有最终输出 schema 校验层。- 搜索过
structured output、output schema、response_format、final output schema,没有找到同主题 issue 或未合并 PR。
这个能力和 Codex SDK/CLI 的 outputSchema / --output-schema 使用场景类似:让 headless agent 更适合作为可靠的程序化组件,而不只是文本生成器。
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing the CLI's --output-format option, the PromptOutputFormat type, and runPromptTurn, then inspect the SDK prompt/turn options. Define the CLI and SDK contract for schema input, final-answer validation, retry or error behavior, and stream-json events; done means these decisions are implemented consistently.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- api, cli
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100