| 1 | package openai |
| 2 | |
| 3 | import "reasonix/internal/provider" |
| 4 | |
| 5 | // OutputBudget reports the default total output budget sent by this client. |
| 6 | func (c *client) OutputBudget() int { return c.maxOutputTokens } |
| 7 | |
| 8 | // SharesContextWindow is true only for the recognized DeepSeek protocol mode. |
| 9 | func (c *client) SharesContextWindow() bool { return c.deepseek } |
| 10 | |
| 11 | // SharedWindowInputPolicy mirrors the assistant replay rule in chat message |
| 12 | // conversion: these adapters send reasoning_content on every history turn that |
| 13 | // carries it, not only on tool-call turns, so admission must count it too. |
| 14 | func (c *client) SharedWindowInputPolicy() provider.SharedWindowInputPolicy { |
| 15 | if c == nil { |
| 16 | return provider.SharedWindowInputPolicy{} |
| 17 | } |
| 18 | return provider.SharedWindowInputPolicy{ |
| 19 | ReplaysOrdinaryReasoning: c.deepseek || c.kimiK3 || c.zhipu || c.RequiresToolCallReasoning(), |
| 20 | } |
| 21 | } |
| 22 | |
| 23 | func (c *client) ContextBudgetPolicy() provider.ContextBudgetPolicy { |
| 24 | if lim, ok := provider.LookupOfficialOpenCodeGo("openai", c.baseURL, c.model); ok { |
| 25 | return provider.ContextBudgetPolicy{ |
| 26 | WindowMode: provider.ContextWindowShared, |
| 27 | AutoOutputTokens: lim.MaxOutput, |
| 28 | MaxOutputTokens: lim.MaxOutput, |
| 29 | LimitMode: provider.OutputLimitAlways, |
| 30 | } |
| 31 | } |
| 32 | if IsDeepSeek(c.baseURL) { |
| 33 | return provider.ContextBudgetPolicy{ |
| 34 | WindowMode: provider.ContextWindowShared, |
| 35 | AutoOutputTokens: provider.DeepSeekMaxOutputTokens, |
| 36 | MaxOutputTokens: provider.DeepSeekMaxOutputTokens, |
| 37 | LimitMode: provider.OutputLimitOmitWhenSafe, |
| 38 | } |
| 39 | } |
| 40 | if c.kimiK3 && IsKimiAPI(c.baseURL) { |
| 41 | return provider.ContextBudgetPolicy{ |
| 42 | WindowMode: provider.ContextWindowShared, |
| 43 | AutoOutputTokens: 131_072, |
| 44 | MaxOutputTokens: 131_072, |
| 45 | LimitMode: provider.OutputLimitAlways, |
| 46 | } |
| 47 | } |
| 48 | return provider.ContextBudgetPolicy{WindowMode: provider.ContextWindowUnknown, LimitMode: provider.OutputLimitOmitWhenSafe} |
| 49 | } |
| 50 |