Skip to content

Commit 8eda9b8

Browse files
authored
refactor(agentic-models): align Gemini API and tool config (#852)
1 parent 846f52b commit 8eda9b8

35 files changed

Lines changed: 679 additions & 440 deletions

components/model/agenticark/README.md

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -158,14 +158,6 @@ type Config struct {
158158
// Optional.
159159
ParallelToolCalls *bool
160160

161-
// ServerTools specifies server-side tools available to the model.
162-
// Optional.
163-
ServerTools []*ServerToolConfig
164-
165-
// MCPTools specifies Model Context Protocol tools available to the model.
166-
// Optional.
167-
MCPTools []*responses.ToolMcp
168-
169161
// EnableAutoCache controls whether auto-caching for multi-turn conversations is active for the model.
170162
// When enabled, conversation turns are stored, and the model automatically maintains context
171163
// by locating the most recent cached message in the input (via Response ID in ResponseMeta).

components/model/agenticark/README.zh_CN.md

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -159,14 +159,6 @@ type Config struct {
159159
// 可选。
160160
ParallelToolCalls *bool
161161

162-
// ServerTools 指定模型可用的服务器端工具。
163-
// 可选。
164-
ServerTools []*ServerToolConfig
165-
166-
// MCPTools 指定模型可用的 MCP(模型上下文协议)工具。
167-
// 可选。
168-
MCPTools []*responses.ToolMcp
169-
170162
// EnableAutoCache 控制是否开启多轮对话自动缓存。
171163
// 启用后,对话轮次将被存储,模型通过定位输入中最近的缓存消息(通过 ResponseMeta 中的 Response ID)
172164
// 自动维护上下文。该缓存消息及其之前的所有输入将从请求中排除。

components/model/agenticark/model.go

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -127,14 +127,6 @@ type Config struct {
127127
// Optional.
128128
ParallelToolCalls *bool
129129

130-
// ServerTools specifies server-side tools available to the model.
131-
// Optional.
132-
ServerTools []*ServerToolConfig
133-
134-
// MCPTools specifies Model Context Protocol tools available to the model.
135-
// Optional.
136-
MCPTools []*responses.ToolMcp
137-
138130
// EnableAutoCache controls whether auto-caching for multi-turn conversations is active for the model.
139131
// When enabled, conversation turns are stored, and the model automatically maintains context
140132
// by locating the most recent cached message in the input (via Response ID in ResponseMeta).
@@ -219,8 +211,6 @@ func buildClient(config *Config) (*Model, error) {
219211
enablePassBackReasoning: config.EnablePassBackReasoning,
220212
maxToolCalls: config.MaxToolCalls,
221213
parallelToolCalls: config.ParallelToolCalls,
222-
serverTools: config.ServerTools,
223-
mcpTools: config.MCPTools,
224214
enableAutoCache: config.EnableAutoCache,
225215
expireAtSec: config.ExpireAtSec,
226216
contextManagement: config.ContextManagement,
@@ -246,8 +236,6 @@ type Model struct {
246236
reasoning *responses.ResponsesReasoning
247237
maxToolCalls *int64
248238
parallelToolCalls *bool
249-
serverTools []*ServerToolConfig
250-
mcpTools []*responses.ToolMcp
251239

252240
enableAutoCache bool
253241
expireAtSec *int64
@@ -611,8 +599,6 @@ func (m *Model) getOptions(opts []model.Option) (*model.Options, *arkOptions, er
611599
text: m.text,
612600
maxToolCalls: m.maxToolCalls,
613601
parallelToolCalls: m.parallelToolCalls,
614-
serverTools: m.serverTools,
615-
mcpTools: m.mcpTools,
616602
contextManagement: m.contextManagement,
617603
customHeaders: m.customHeaders,
618604
}, opts...)

components/model/agenticclaude/README.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -142,10 +142,6 @@ type Config struct {
142142
// Optional.
143143
Thinking *anthropic.ThinkingConfigParamUnion
144144

145-
// ServerTools specifies server-side tools available to the model.
146-
// Optional.
147-
ServerTools []*ServerToolConfig
148-
149145
// CustomHeaders specifies custom HTTP headers to include in API requests.
150146
// CustomHeaders allows passing additional metadata or authentication information.
151147
// Optional.

components/model/agenticclaude/README_zh.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -142,10 +142,6 @@ type Config struct {
142142
// 可选。
143143
Thinking *anthropic.ThinkingConfigParamUnion
144144

145-
// ServerTools 指定模型可用的服务器端工具。
146-
// 可选。
147-
ServerTools []*ServerToolConfig
148-
149145
// CustomHeaders 指定 API 请求中包含的自定义 HTTP 标头。
150146
// 可用于传递额外的元数据或认证信息。
151147
// 可选。

components/model/agenticclaude/model.go

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -88,10 +88,6 @@ type Config struct {
8888
// Optional.
8989
Thinking *anthropic.ThinkingConfigParamUnion
9090

91-
// ServerTools specifies server-side tools available to the model.
92-
// Optional.
93-
ServerTools []*ServerToolConfig
94-
9591
// CustomHeaders specifies custom HTTP headers to include in API requests.
9692
// CustomHeaders allows passing additional metadata or authentication information.
9793
// Optional.
@@ -158,7 +154,6 @@ type Model struct {
158154
maxTokens int
159155
stopSequences []string
160156
disableParallelToolUse *bool
161-
serverTools []*ServerToolConfig
162157
customHeaders map[string]string
163158
extraFields map[string]any
164159
thinking *anthropic.ThinkingConfigParamUnion
@@ -211,7 +206,6 @@ func New(ctx context.Context, cfg *Config) (*Model, error) {
211206
maxTokens: cfg.MaxTokens,
212207
stopSequences: cfg.StopSequences,
213208
disableParallelToolUse: cfg.DisableParallelToolUse,
214-
serverTools: cfg.ServerTools,
215209
customHeaders: cfg.CustomHeaders,
216210
extraFields: cfg.ExtraFields,
217211
thinking: cfg.Thinking,
@@ -514,7 +508,6 @@ func (m *Model) getOptions(opts []model.Option) (*model.Options, *claudeOptions,
514508
Stop: m.stopSequences,
515509
}, opts...)
516510
specOptions := model.GetImplSpecificOptions(&claudeOptions{
517-
serverTools: m.serverTools,
518511
customHeaders: m.customHeaders,
519512
extraFields: m.extraFields,
520513
}, opts...)

components/model/agenticclaude/model_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -420,15 +420,15 @@ func TestGetOptions(t *testing.T) {
420420
model: "claude-sonnet-4",
421421
maxTokens: 4096,
422422
stopSequences: []string{"done"},
423-
serverTools: []*ServerToolConfig{
424-
{WebSearch20260209: &anthropic.WebSearchTool20260209Param{}},
425-
},
426423
customHeaders: map[string]string{"x-default": "1"},
427424
extraFields: map[string]any{"foo": "bar"},
428425
}
429426

430427
options, specOptions, err := m.getOptions([]model.Option{
431428
model.WithTemperature(0.2),
429+
WithServerTools([]*ServerToolConfig{
430+
{WebSearch20260209: &anthropic.WebSearchTool20260209Param{}},
431+
}),
432432
WithCustomHeaders(map[string]string{"x-call": "2"}),
433433
})
434434
if err != nil {

components/model/agenticgemini/README.md

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ func main() {
5050
log.Fatalf("NewClient of gemini failed, err=%v", err)
5151
}
5252

53-
cm, err := agenticgemini.NewAgenticModel(ctx, &agenticgemini.Config{
53+
cm, err := agenticgemini.New(ctx, &agenticgemini.Config{
5454
Client: client,
5555
Model: modelName,
5656
ThinkingConfig: &genai.ThinkingConfig{
@@ -135,17 +135,13 @@ type Config struct {
135135

136136
// ResponseModalities specifies the modalities the model can return.
137137
// Optional.
138-
ResponseModalities []ResponseModality
138+
ResponseModalities []genai.Modality
139139

140140
MediaResolution genai.MediaResolution
141141

142-
// CacheTTL specifies how long prefix cache resources remain valid (now + TTL).
142+
// CacheExpiration configures the expiration policy for prefix cache resources.
143143
// Optional.
144-
CacheTTL time.Duration
145-
146-
// CacheExpireTime sets the absolute expiration timestamp for prefix cache resources.
147-
// Optional.
148-
CacheExpireTime time.Time
144+
CacheExpiration *CacheExpiration
149145
}
150146
```
151147

components/model/agenticgemini/README.zh_CN.md

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ func main() {
5050
log.Fatalf("NewClient of gemini failed, err=%v", err)
5151
}
5252

53-
cm, err := agenticgemini.NewAgenticModel(ctx, &agenticgemini.Config{
53+
cm, err := agenticgemini.New(ctx, &agenticgemini.Config{
5454
Client: client,
5555
Model: modelName,
5656
ThinkingConfig: &genai.ThinkingConfig{
@@ -135,17 +135,13 @@ type Config struct {
135135

136136
// ResponseModalities 指定模型可以返回的模态类型
137137
// 可选。
138-
ResponseModalities []ResponseModality
138+
ResponseModalities []genai.Modality
139139

140140
MediaResolution genai.MediaResolution
141141

142-
// CacheTTL 指定前缀缓存资源的有效时长(now + TTL)
142+
// CacheExpiration 配置前缀缓存资源的过期策略
143143
// 可选。
144-
CacheTTL time.Duration
145-
146-
// CacheExpireTime 设置前缀缓存资源的绝对过期时间戳。
147-
// 可选。
148-
CacheExpireTime time.Time
144+
CacheExpiration *CacheExpiration
149145
}
150146
```
151147

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/*
2+
* Copyright 2026 CloudWeGo Authors
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package agenticgemini
18+
19+
type ServerToolName string
20+
21+
const (
22+
ServerToolNameCodeExecution ServerToolName = "CodeExecution"
23+
)
24+
25+
type Language string
26+
27+
const (
28+
LanguageUnspecified Language = "LANGUAGE_UNSPECIFIED"
29+
LanguagePython Language = "PYTHON"
30+
)
31+
32+
type Outcome string
33+
34+
const (
35+
// OutcomeUnspecified specifies that unspecified status. This value should not be used.
36+
OutcomeUnspecified Outcome = "OUTCOME_UNSPECIFIED"
37+
// OutcomeOK specifies that code execution completed successfully.
38+
OutcomeOK Outcome = "OUTCOME_OK"
39+
// OutcomeFailed specifies that code execution finished but with a failure. `stderr` should contain the reason.
40+
OutcomeFailed Outcome = "OUTCOME_FAILED"
41+
// OutcomeDeadlineExceeded specifies that code execution ran for too long, and was cancelled. There may or may not be a partial
42+
// output present.
43+
OutcomeDeadlineExceeded Outcome = "OUTCOME_DEADLINE_EXCEEDED"
44+
)

0 commit comments

Comments
 (0)