Compare commits

..

2 Commits

Author SHA1 Message Date
johnlanni
179a233ad6 refactor(ai-proxy): redesign streaming thinking promotion to buffer-and-flush
Instead of promoting reasoning to content inline per-chunk (which would
emit reasoning as content prematurely if real content arrives later),
the streaming path now buffers reasoning content and strips it from
chunks. On the last chunk, if no content was ever seen, the buffered
reasoning is flushed as a single content chunk.

Also moves tests into test/openai.go TestOpenAI suite and adds
MockHttpContext for provider-level streaming tests.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-20 00:05:17 +08:00
johnlanni
bdfe9950ce feat(ai-proxy): add promoteThinkingOnEmpty and hiclawMode config options
When some models (e.g. kimi-k2.5) put user-facing replies into
reasoning_content/thinking blocks without generating text content,
downstream clients receive empty responses. This adds a new
promoteThinkingOnEmpty option that promotes reasoning content to
text content when the response has no text block.

Also adds hiclawMode as a convenience flag that enables both
mergeConsecutiveMessages and promoteThinkingOnEmpty for multi-agent
collaboration scenarios.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-19 23:28:17 +08:00
4 changed files with 3 additions and 5 deletions

2
go.mod
View File

@@ -31,7 +31,7 @@ require (
github.com/hudl/fargo v1.4.0
github.com/mholt/acmez v1.2.0
github.com/nacos-group/nacos-sdk-go v1.0.8
github.com/nacos-group/nacos-sdk-go/v2 v2.3.5
github.com/nacos-group/nacos-sdk-go/v2 v2.3.2
github.com/spf13/cobra v1.9.1
github.com/spf13/pflag v1.0.7
github.com/stretchr/testify v1.11.1

4
go.sum
View File

@@ -3688,8 +3688,8 @@ github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f h1:y5//uYreIhSUg3J
github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f/go.mod h1:ZdcZmHo+o7JKHSa8/e818NopupXU1YMK5fe1lsApnBw=
github.com/nacos-group/nacos-sdk-go v1.0.8 h1:8pEm05Cdav9sQgJSv5kyvlgfz0SzFUUGI3pWX6SiSnM=
github.com/nacos-group/nacos-sdk-go v1.0.8/go.mod h1:hlAPn3UdzlxIlSILAyOXKxjFSvDJ9oLzTJ9hLAK1KzA=
github.com/nacos-group/nacos-sdk-go/v2 v2.3.5 h1:Hux7C4N4rWhwBF5Zm4yyYskrs9VTgrRTA8DZjoEhQTs=
github.com/nacos-group/nacos-sdk-go/v2 v2.3.5/go.mod h1:ygUBdt7eGeYBt6Lz2HO3wx7crKXk25Mp80568emGMWU=
github.com/nacos-group/nacos-sdk-go/v2 v2.3.2 h1:9QB2nCJzT5wkTVlxNYl3XL/7+G6p2USMi2gQh/ouQQo=
github.com/nacos-group/nacos-sdk-go/v2 v2.3.2/go.mod h1:9FKXl6FqOiVmm72i8kADtbeK71egyG9y3uRDBg41tpQ=
github.com/nats-io/jwt v0.3.0/go.mod h1:fRYCDE99xlTsqUzISS1Bi75UBJ6ljOJQOAAu5VglpSg=
github.com/nats-io/jwt v0.3.2/go.mod h1:/euKqTS1ZD+zzjYrY7pseZrTtWQSjujC7xjPc8wL6eU=
github.com/nats-io/nats-server/v2 v2.1.2/go.mod h1:Afk+wRZqkMQs/p45uXdrVLuab3gwv3Z8C4HTBu8GD/k=

View File

@@ -112,7 +112,6 @@ func parseConfig(json gjson.Result, config *Config) error {
"/video-synthesis",
"/rerank",
"/messages",
"/responses",
}
}

View File

@@ -80,7 +80,6 @@ func parseConfig(json gjson.Result, config *ModelRouterConfig) error {
"/video-synthesis",
"/rerank",
"/messages",
"/responses",
}
}