feat(runtime\provider):初步重构多模态机制#315
Conversation
|
/code 修复报错 |
|
已完成“修复报错”,并已推送到当前工作分支。 处理结果
测试
提交与推送
未完成项:未处理本次触发范围之外的改动请求。 |
@xgopilot 这版方案尝试兼容旧字段,不允许,重改 |
结果已按你的要求重改:不引入旧字段兼容,仅保留并修复运行链路问题,提交已推送到当前 PR 的 head 分支 本次改动
关键文件
验证
提交
未执行项
|
…sion flow Generated with [codeagent](https://github.com/qbox/codeagent) Co-authored-by: phantom5099 <245659304+phantom5099@users.noreply.github.com>
|
/review |
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
| @@ -36,7 +36,7 @@ func TestDefaultBuilderBuild(t *testing.T) { | |||
| builder := NewBuilder() | |||
There was a problem hiding this comment.
Reviewed this change set and the surrounding migration to Message.Parts; no issues identified at this location.
|
|
||
| // ToOpenAIMessage 将通用 Message 转换为 OpenAI 协议消息格式。 | ||
| func ToOpenAIMessage(message providertypes.Message) Message { | ||
| func ToOpenAIMessage(message providertypes.Message) (Message, error) { |
There was a problem hiding this comment.
ToOpenAIMessage does not validate message.Parts up front, so malformed payloads can slip through (for example, image parts with empty URL, or mixed unknown kinds) and fail only after hitting the upstream API. Please call providertypes.ValidateParts(message.Parts) here and return a wrapped error early to keep failures deterministic and local.
| var text string | ||
| for _, part := range message.Parts { | ||
| if part.Kind == providertypes.ContentPartText { | ||
| text += part.Text |
There was a problem hiding this comment.
This loop builds text via repeated text += part.Text, which is O(n^2) as the message grows. Please switch to strings.Builder (or pre-sized byte buffer) to avoid avoidable allocations/copies on long multi-part prompts.
| contentParts = append(contentParts, MessageContentPart{ | ||
| Type: "image_url", | ||
| ImageURL: &ImageURL{ | ||
| URL: part.Image.URL, |
There was a problem hiding this comment.
ToOpenAIMessage appends image_url.url without validating that it is non-empty (or otherwise well-formed). Because this function can be reached with persisted/history messages that were not validated at runtime input boundaries, an empty URL can propagate into the OpenAI payload and fail later as a remote 400.
Please add a local guard here (or call shared parts validation in this conversion path) so malformed image parts are rejected deterministically before request emission.
|
|
||
| // ToOpenAIMessage 将通用 Message 转换为 OpenAI 协议消息格式。 | ||
| func ToOpenAIMessage(message providertypes.Message) Message { | ||
| func ToOpenAIMessage(message providertypes.Message) (Message, error) { |
There was a problem hiding this comment.
ToOpenAIMessage does not validate message.Parts before conversion. For invalid/unknown part kinds in non-image messages, this function can silently produce an empty/partial content payload instead of failing fast, which can hide corrupted history and surface as hard-to-debug downstream API errors. Consider calling providertypes.ValidateParts(message.Parts) at the top and returning a wrapped error when invalid.
|
|
||
| // ToOpenAIMessage 将通用 Message 转换为 OpenAI 协议消息格式。 | ||
| func ToOpenAIMessage(message providertypes.Message) Message { | ||
| func ToOpenAIMessage(message providertypes.Message) (Message, error) { |
There was a problem hiding this comment.
ToOpenAIMessage 在转换 message.Parts 前没有做统一校验。当前实现对未知/非法 part 可能出现“静默忽略并继续构造请求”的情况,导致上下文内容丢失或错误延后到远端 API 才暴露。建议在函数入口先调用 providertypes.ValidateParts(message.Parts),并在失败时直接返回本地错误,保持失败可诊断且行为一致。
|
/simplify |
处理结果已按要求先检查历史评论中的未闭环 review 建议,并修复值得修复项;随后调用 code-simplifier 子代理完成简化复核并吸收可行改动。 已处理的 review 问题
测试与简化
提交与推送
未执行项
|
Generated with [codeagent](https://github.com/qbox/codeagent) Co-authored-by: phantom5099 <245659304+phantom5099@users.noreply.github.com>
fix(provider): validate parts and simplify message conversion
|
/code 修复编译错误 |
处理结果已按“修复编译错误”执行复现与校验,但在当前 PR 分支未能复现编译失败,因此本次无需代码修改。 已执行检查
未执行项
如果你本地仍有编译报错,请贴出完整命令和首个错误栈,我会按该错误点精准修复。 |
|
/code 修复编译错误:Error: internal/runtime/todo_runtime_integration_test.go:39:6: unknown field Content in struct literal of type types.Message |
处理结果已修复你指出的编译错误来源,并将修复推送到当前 PR 分支。 本次修复针对合并视角下的
验证
提交与推送
未执行项
|
Generated with [codeagent](https://github.com/qbox/codeagent) Co-authored-by: phantom5099 <245659304+phantom5099@users.noreply.github.com>
fix(runtime): align todo integration test with parts input
|
/code 给我解决冲突 |
处理结果已完成冲突解决,并把结果推送到当前 PR 分支。 已解决冲突
验证
提交与推送
未执行项
|
…/todo integration Generated with [codeagent](https://github.com/qbox/codeagent) Co-authored-by: phantom5099 <245659304+phantom5099@users.noreply.github.com>
merge: resolve conflicts for PR 1024XEngineer#315
本次已完成内容
1) 类型模型统一
internal/provider/types/content_part.go,落地:ContentPartKindContentPartImagePartAssetRefValidatePartsClonePartsinternal/provider/types/message.go:Message移除旧Content,统一为PartsMessage.Validate()仅校验Parts2) Runtime 输入与执行链路收敛
UserInput已统一为Parts输入语义Run()入口已按Parts做输入校验sessionTitleFromParts()生成3) Session 持久化收敛
Parts24) Provider 请求编码收敛
image_url多模态内容session_asset图片返回显式错误,避免静默降级验证结果
go test ./internal/runtime -run TestServiceRunErrorPaths -count=1go test ./internal/runtime -run TestRepeatCycleStreakCountsFailedToolCalls -count=1 -vgo test ./internal/memo -run 'TestLLMExtractorExtractKeepsProjectedToolCallSpan|TestLLMExtractorExtractKeepsMetadataOnlyToolCallSpan|TestCloneProviderMessageHandlesEmptyCollections' -count=1go test ./... -run TestDoesNotExist -count=1影响与收益