From 9aa237eccab5be6f07c4d33be5def8a211d363f2 Mon Sep 17 00:00:00 2001 From: Lakshman Patel Date: Thu, 30 Jul 2026 04:34:37 +0530 Subject: [PATCH 1/4] feat: add Concentrate Responses API extended parameters Add support for all Concentrate API fields: - include: extra output (web search results, logprobs) - routing: auto model selection (cost/latency/quality) - max_tool_calls: limit tool call rounds - context_management: conversation compaction - safety_identifier: user safety tracking - background: async response - truncation: truncation strategy - conversation: conversation grouping Per: https://concentrate.ai/docs/api-reference/endpoint/request-parameters --- llm/types.go | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/llm/types.go b/llm/types.go index cac9387..e745a19 100644 --- a/llm/types.go +++ b/llm/types.go @@ -128,6 +128,27 @@ type ChatOptions struct { AudioConfig string `json:"audio_config,omitempty"` Prediction string `json:"prediction,omitempty"` WebSearchOptions string `json:"web_search_options,omitempty"` + + // Responses API extensions (Concentrate) + PreviousResponseID string `json:"previous_response_id,omitempty"` + Include []string `json:"include,omitempty"` + Routing *RoutingConfig `json:"routing,omitempty"` + MaxToolCalls *int `json:"max_tool_calls,omitempty"` + ContextManagement []ContextManagement `json:"context_management,omitempty"` + SafetyIdentifier *string `json:"safety_identifier,omitempty"` + Background *bool `json:"background,omitempty"` + Truncation *string `json:"truncation,omitempty"` + Conversation interface{} `json:"conversation,omitempty"` +} + +type RoutingConfig struct { + Model interface{} `json:"model,omitempty"` + Strategy string `json:"strategy,omitempty"` // "min" or "max" + Metric string `json:"metric,omitempty"` // "cost", "latency", "quality" +} + +type ContextManagement struct { + Type string `json:"type"` // "compact_20260112", "clear_thinking_20251015", etc. } // ContinuationConfig controls output continuation behavior. From f6527e6e58e7ef5e920c296d5527cf9710a4c39b Mon Sep 17 00:00:00 2001 From: Lakshman Patel Date: Thu, 30 Jul 2026 04:39:10 +0530 Subject: [PATCH 2/4] feat: add PromptCacheOptions and CacheControl types Add prompt caching and cache control options for Concentrate API. --- llm/types.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/llm/types.go b/llm/types.go index e745a19..4ef1b70 100644 --- a/llm/types.go +++ b/llm/types.go @@ -128,6 +128,18 @@ type ChatOptions struct { AudioConfig string `json:"audio_config,omitempty"` Prediction string `json:"prediction,omitempty"` WebSearchOptions string `json:"web_search_options,omitempty"` + PromptCacheOptions *PromptCacheOpts `json:"prompt_cache_options,omitempty"` + CacheControl *CacheControl `json:"cache_control,omitempty"` +} + +type PromptCacheOpts struct { + Mode string `json:"mode,omitempty"` + TTL string `json:"ttl,omitempty"` +} + +type CacheControl struct { + Type string `json:"type"` + TTL string `json:"ttl,omitempty"` // Responses API extensions (Concentrate) PreviousResponseID string `json:"previous_response_id,omitempty"` From 4824afce2c4a820cc2981f0b9749f2796f1c592e Mon Sep 17 00:00:00 2001 From: Lakshman Patel Date: Thu, 30 Jul 2026 04:54:52 +0530 Subject: [PATCH 3/4] fix: move Concentrate API fields to ChatOptions struct PreviousResponseID, Include, Routing, MaxToolCalls, ContextManagement, SafetyIdentifier, Background, Truncation, Conversation fields were accidentally added to CacheControl struct. Moved to ChatOptions. --- llm/types.go | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/llm/types.go b/llm/types.go index 4ef1b70..88e8338 100644 --- a/llm/types.go +++ b/llm/types.go @@ -130,6 +130,16 @@ type ChatOptions struct { WebSearchOptions string `json:"web_search_options,omitempty"` PromptCacheOptions *PromptCacheOpts `json:"prompt_cache_options,omitempty"` CacheControl *CacheControl `json:"cache_control,omitempty"` + // Responses API extensions (Concentrate) + PreviousResponseID string `json:"previous_response_id,omitempty"` + Include []string `json:"include,omitempty"` + Routing *RoutingConfig `json:"routing,omitempty"` + MaxToolCalls *int `json:"max_tool_calls,omitempty"` + ContextManagement []ContextManagement `json:"context_management,omitempty"` + SafetyIdentifier *string `json:"safety_identifier,omitempty"` + Background *bool `json:"background,omitempty"` + Truncation *string `json:"truncation,omitempty"` + Conversation interface{} `json:"conversation,omitempty"` } type PromptCacheOpts struct { @@ -140,17 +150,6 @@ type PromptCacheOpts struct { type CacheControl struct { Type string `json:"type"` TTL string `json:"ttl,omitempty"` - - // Responses API extensions (Concentrate) - PreviousResponseID string `json:"previous_response_id,omitempty"` - Include []string `json:"include,omitempty"` - Routing *RoutingConfig `json:"routing,omitempty"` - MaxToolCalls *int `json:"max_tool_calls,omitempty"` - ContextManagement []ContextManagement `json:"context_management,omitempty"` - SafetyIdentifier *string `json:"safety_identifier,omitempty"` - Background *bool `json:"background,omitempty"` - Truncation *string `json:"truncation,omitempty"` - Conversation interface{} `json:"conversation,omitempty"` } type RoutingConfig struct { From 4ecff3ca2412e88036d32dd5ffc9e87e073c4567 Mon Sep 17 00:00:00 2001 From: Lakshman Patel Date: Thu, 30 Jul 2026 19:13:17 +0530 Subject: [PATCH 4/4] fix: finalize Concentrate API field updates --- llm/provider.go | 6 +----- llm/types.go | 33 ++++++++++++++++----------------- 2 files changed, 17 insertions(+), 22 deletions(-) diff --git a/llm/provider.go b/llm/provider.go index 1031ad8..70c84a7 100644 --- a/llm/provider.go +++ b/llm/provider.go @@ -109,11 +109,7 @@ type GenerationOptions struct { ThinkingMode string ThinkingDisplay string ThinkingEnabled *bool - // GLMThinkingEnabled toggles GLM/Z.ai extended reasoning via the provider's - // non-OpenAI thinking={"type":"enabled"|"disabled"} request parameter. Only - // applied for OpenAI-compatible providers whose compat config sets - // ThinkingFormat to "zai". When nil the parameter is omitted and the model - // uses its default (GLM defaults to enabled). + // GLMThinkingEnabled is a deprecated alias of ThinkingEnabled (Z.AI-era). GLMThinkingEnabled *bool VirtualKeyID string KimiContextCacheID string diff --git a/llm/types.go b/llm/types.go index 88e8338..5447020 100644 --- a/llm/types.go +++ b/llm/types.go @@ -99,11 +99,10 @@ type ChatOptions struct { ThinkingMode string `json:"thinking_mode,omitempty"` ThinkingDisplay string `json:"thinking_display,omitempty"` ThinkingEnabled *bool `json:"thinking_enabled,omitempty"` - // GLMThinkingEnabled toggles GLM/Z.ai extended reasoning via the provider's - // non-OpenAI thinking={"type":"enabled"|"disabled"} request parameter. Only - // applied for OpenAI-compatible providers whose compat config sets - // ThinkingFormat to "zai". When nil the parameter is omitted and the model - // uses its default (GLM defaults to enabled). + // GLMThinkingEnabled is a deprecated alias of ThinkingEnabled kept for + // older Z.AI call sites. New code should set ThinkingEnabled. Adapters + // accept either field; wire encoding is selected per provider via + // OpenAICompatConfig.ThinkingFormat ("zai", "longcat", "agnes", …). GLMThinkingEnabled *bool `json:"glm_thinking_enabled,omitempty"` VirtualKeyID string `json:"virtual_key_id,omitempty"` KimiContextCacheID string `json:"kimi_context_cache_id,omitempty"` @@ -131,15 +130,15 @@ type ChatOptions struct { PromptCacheOptions *PromptCacheOpts `json:"prompt_cache_options,omitempty"` CacheControl *CacheControl `json:"cache_control,omitempty"` // Responses API extensions (Concentrate) - PreviousResponseID string `json:"previous_response_id,omitempty"` - Include []string `json:"include,omitempty"` - Routing *RoutingConfig `json:"routing,omitempty"` - MaxToolCalls *int `json:"max_tool_calls,omitempty"` - ContextManagement []ContextManagement `json:"context_management,omitempty"` - SafetyIdentifier *string `json:"safety_identifier,omitempty"` - Background *bool `json:"background,omitempty"` - Truncation *string `json:"truncation,omitempty"` - Conversation interface{} `json:"conversation,omitempty"` + PreviousResponseID string `json:"previous_response_id,omitempty"` + Include []string `json:"include,omitempty"` + Routing *RoutingConfig `json:"routing,omitempty"` + MaxToolCalls *int `json:"max_tool_calls,omitempty"` + ContextManagement []ContextManagement `json:"context_management,omitempty"` + SafetyIdentifier *string `json:"safety_identifier,omitempty"` + Background *bool `json:"background,omitempty"` + Truncation *string `json:"truncation,omitempty"` + Conversation interface{} `json:"conversation,omitempty"` } type PromptCacheOpts struct { @@ -154,12 +153,12 @@ type CacheControl struct { type RoutingConfig struct { Model interface{} `json:"model,omitempty"` - Strategy string `json:"strategy,omitempty"` // "min" or "max" - Metric string `json:"metric,omitempty"` // "cost", "latency", "quality" + Strategy string `json:"strategy,omitempty"` // "min" or "max" + Metric string `json:"metric,omitempty"` // "cost", "latency", "quality" } type ContextManagement struct { - Type string `json:"type"` // "compact_20260112", "clear_thinking_20251015", etc. + Type string `json:"type"` // "compact_20260112", "clear_thinking_20251015", etc. } // ContinuationConfig controls output continuation behavior.