(body []byte, config thinking.ThinkingConfig)
| 85 | } |
| 86 | |
| 87 | func applyCompatibleCodex(body []byte, config thinking.ThinkingConfig) ([]byte, error) { |
| 88 | if len(body) == 0 || !gjson.ValidBytes(body) { |
| 89 | body = []byte(`{}`) |
| 90 | } |
| 91 | |
| 92 | var effort string |
| 93 | switch config.Mode { |
| 94 | case thinking.ModeLevel: |
| 95 | if config.Level == "" { |
| 96 | return body, nil |
| 97 | } |
| 98 | effort = string(config.Level) |
| 99 | case thinking.ModeNone: |
| 100 | effort = string(thinking.LevelNone) |
| 101 | if config.Level != "" { |
| 102 | effort = string(config.Level) |
| 103 | } |
| 104 | case thinking.ModeAuto: |
| 105 | // Auto mode for user-defined models: pass through as "auto" |
| 106 | effort = string(thinking.LevelAuto) |
| 107 | case thinking.ModeBudget: |
| 108 | // Budget mode: convert budget to level using threshold mapping |
| 109 | level, ok := thinking.ConvertBudgetToLevel(config.Budget) |
| 110 | if !ok { |
| 111 | return body, nil |
| 112 | } |
| 113 | effort = level |
| 114 | default: |
| 115 | return body, nil |
| 116 | } |
| 117 | |
| 118 | result, _ := sjson.SetBytes(body, "reasoning.effort", effort) |
| 119 | return result, nil |
| 120 | } |
no test coverage detected