Files
CLIProxyAPI/internal/client/codex/models/apply_patch.go
Luis Pater 3ebee06516 fix(interactions): bridge apply_patch tool calls in responses translation
- Handle apply_patch custom tool call streaming deltas and snapshots for Responses API translation
- Track and resolve step indexes, function call identities, and error states across stream events
- Propagate apply_patch tool input errors and upstream failure states in stream and non-stream responses
2026-10-02 03:49:51 +08:00

51 lines
1.5 KiB
Go

package models
import "strings"
// ApplyPatchCapabilityForModelFunc requires support from every actual routing
// candidate for the exact public model ID. false also represents unknown support.
type ApplyPatchCapabilityForModelFunc func(string) bool
func applyCodexClientApplyPatchCapability(entry map[string]any, id string, capability ApplyPatchCapabilityForModelFunc) {
entry["apply_patch_tool_type"] = nil
if capability == nil {
return
}
// Built-in image/video IDs can inherit a generic text template in Home.
// This classification is a model restriction, not routing capability evidence.
baseID := strings.ToLower(strings.TrimSpace(id))
if index := strings.LastIndex(baseID, "/"); index != -1 {
baseID = strings.TrimSpace(baseID[index+1:])
}
if isCodexClientImageOrVideoModel(baseID) {
return
}
// Hidden text models remain usable, but non-text catalog entries must not
// advertise a conversation tool even when their executor supports it.
supportsText := false
hasModalities := false
switch modalities := entry["input_modalities"].(type) {
case []any:
hasModalities = len(modalities) > 0
for _, modality := range modalities {
if modality == "text" {
supportsText = true
}
}
case []string:
hasModalities = len(modalities) > 0
for _, modality := range modalities {
if modality == "text" {
supportsText = true
}
}
}
if !supportsText && (hasModalities || entry["visibility"] == "hide") {
return
}
if capability(strings.TrimSpace(id)) {
entry["apply_patch_tool_type"] = "freeform"
}
}