-
Notifications
You must be signed in to change notification settings - Fork 728
Expand file tree
/
Copy pathtypes.go
More file actions
697 lines (629 loc) · 21.9 KB
/
Copy pathtypes.go
File metadata and controls
697 lines (629 loc) · 21.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
package adk
import (
"database/sql"
"database/sql/driver"
"encoding/json"
"fmt"
"github.com/kagent-dev/kagent/go/api/agentplugin"
)
type StreamableHTTPConnectionParams struct {
Url string `json:"url"`
Headers map[string]string `json:"headers"`
Timeout *float64 `json:"timeout,omitempty"`
SseReadTimeout *float64 `json:"sse_read_timeout,omitempty"`
TerminateOnClose *bool `json:"terminate_on_close,omitempty"`
// TLS configuration for self-signed certificates
TLSInsecureSkipVerify *bool `json:"tls_insecure_skip_verify,omitempty"`
TLSCACertPath *string `json:"tls_ca_cert_path,omitempty"`
TLSDisableSystemCAs *bool `json:"tls_disable_system_cas,omitempty"`
}
type HttpMcpServerConfig struct {
Params StreamableHTTPConnectionParams `json:"params"`
Tools []string `json:"tools,omitempty"`
AllowedHeaders []string `json:"allowed_headers,omitempty"`
RequireApproval []string `json:"require_approval,omitempty"`
}
type SseConnectionParams struct {
Url string `json:"url"`
Headers map[string]string `json:"headers"`
Timeout *float64 `json:"timeout,omitempty"`
SseReadTimeout *float64 `json:"sse_read_timeout,omitempty"`
// TLS configuration for self-signed certificates
TLSInsecureSkipVerify *bool `json:"tls_insecure_skip_verify,omitempty"`
TLSCACertPath *string `json:"tls_ca_cert_path,omitempty"`
TLSDisableSystemCAs *bool `json:"tls_disable_system_cas,omitempty"`
}
type SseMcpServerConfig struct {
Params SseConnectionParams `json:"params"`
Tools []string `json:"tools,omitempty"`
AllowedHeaders []string `json:"allowed_headers,omitempty"`
RequireApproval []string `json:"require_approval,omitempty"`
}
// StdioMcpServerConfig starts one local MCP server without invoking a shell.
type StdioMcpServerConfig struct {
Command string `json:"command"`
Args []string `json:"args,omitempty"`
Env map[string]string `json:"env,omitempty"`
Dir string `json:"dir,omitempty"`
}
type Model interface {
GetType() string
}
type BaseModel struct {
Type string `json:"type"`
Model string `json:"model"`
Headers map[string]string `json:"headers,omitempty"`
// TLS/SSL configuration (applies to all model types)
TLSInsecureSkipVerify *bool `json:"tls_insecure_skip_verify,omitempty"`
TLSCACertPath *string `json:"tls_ca_cert_path,omitempty"`
TLSDisableSystemCAs *bool `json:"tls_disable_system_cas,omitempty"`
// APIKeyPassthrough enables forwarding the Bearer token from incoming requests
// as the LLM API key instead of using a static secret.
APIKeyPassthrough bool `json:"api_key_passthrough,omitempty"`
}
// GDCHTokenExchangeConfig holds the GDCH-specific token exchange fields
// serialised into the agent config JSON consumed by the Python runtime.
type GDCHTokenExchangeConfig struct {
ServiceAccountPath string `json:"service_account_path"`
Audience string `json:"audience"`
}
// TokenExchangeConfig is the discriminated union serialised into the agent
// config JSON. Type is always "GDCHServiceAccount" for now.
type TokenExchangeConfig struct {
Type string `json:"type"`
GDCHServiceAccount *GDCHTokenExchangeConfig `json:"gdch_service_account,omitempty"`
}
type OpenAI struct {
BaseModel
BaseUrl string `json:"base_url"`
FrequencyPenalty *float64 `json:"frequency_penalty,omitempty"`
MaxTokens *int `json:"max_tokens,omitempty"`
MaxCompletionTokens *int `json:"max_completion_tokens,omitempty"`
N *int `json:"n,omitempty"`
PresencePenalty *float64 `json:"presence_penalty,omitempty"`
ReasoningEffort *string `json:"reasoning_effort,omitempty"`
Seed *int `json:"seed,omitempty"`
Temperature *float64 `json:"temperature,omitempty"`
Timeout *int `json:"timeout,omitempty"`
TopP *float64 `json:"top_p,omitempty"`
// APIFormat selects chatCompletions (default) or responses.
APIFormat string `json:"api_format,omitempty"`
// TokenExchange configures dynamic bearer token acquisition
TokenExchange *TokenExchangeConfig `json:"token_exchange,omitempty"`
}
const (
ModelTypeOpenAI = "openai"
ModelTypeAzureOpenAI = "azure_openai"
ModelTypeAnthropic = "anthropic"
ModelTypeGeminiVertexAI = "gemini_vertex_ai"
ModelTypeGeminiAnthropic = "gemini_anthropic"
ModelTypeOllama = "ollama"
ModelTypeGemini = "gemini"
ModelTypeBedrock = "bedrock"
ModelTypeSAPAICore = "sap_ai_core"
ModelTypeFoundry = "foundry"
)
func (o *OpenAI) MarshalJSON() ([]byte, error) {
type Alias OpenAI
return json.Marshal(&struct {
Type string `json:"type"`
*Alias
}{
Type: ModelTypeOpenAI,
Alias: (*Alias)(o),
})
}
func (o *OpenAI) GetType() string {
return ModelTypeOpenAI
}
type AzureOpenAI struct {
BaseModel
Endpoint string `json:"endpoint,omitempty"`
Deployment string `json:"deployment,omitempty"`
APIVersion string `json:"api_version,omitempty"`
MaxTokens *int `json:"max_tokens,omitempty"`
Temperature *float64 `json:"temperature,omitempty"`
TopP *float64 `json:"top_p,omitempty"`
}
func (a *AzureOpenAI) GetType() string {
return ModelTypeAzureOpenAI
}
func (a *AzureOpenAI) MarshalJSON() ([]byte, error) {
type Alias AzureOpenAI
return json.Marshal(&struct {
Type string `json:"type"`
*Alias
}{
Type: ModelTypeAzureOpenAI,
Alias: (*Alias)(a),
})
}
type Anthropic struct {
BaseModel
BaseUrl string `json:"base_url,omitempty"`
MaxTokens *int `json:"max_tokens,omitempty"`
Temperature *float64 `json:"temperature,omitempty"`
TopP *float64 `json:"top_p,omitempty"`
TopK *int `json:"top_k,omitempty"`
Timeout *int `json:"timeout,omitempty"`
}
func (a *Anthropic) MarshalJSON() ([]byte, error) {
type Alias Anthropic
return json.Marshal(&struct {
Type string `json:"type"`
*Alias
}{
Type: ModelTypeAnthropic,
Alias: (*Alias)(a),
})
}
func (a *Anthropic) GetType() string {
return ModelTypeAnthropic
}
type GeminiVertexAI struct {
BaseModel
MaxOutputTokens *int `json:"max_output_tokens,omitempty"`
}
func (g *GeminiVertexAI) MarshalJSON() ([]byte, error) {
type Alias GeminiVertexAI
return json.Marshal(&struct {
Type string `json:"type"`
*Alias
}{
Type: ModelTypeGeminiVertexAI,
Alias: (*Alias)(g),
})
}
func (g *GeminiVertexAI) GetType() string {
return ModelTypeGeminiVertexAI
}
type GeminiAnthropic struct {
BaseModel
}
func (g *GeminiAnthropic) MarshalJSON() ([]byte, error) {
type Alias GeminiAnthropic
return json.Marshal(&struct {
Type string `json:"type"`
*Alias
}{
Type: ModelTypeGeminiAnthropic,
Alias: (*Alias)(g),
})
}
func (g *GeminiAnthropic) GetType() string {
return ModelTypeGeminiAnthropic
}
type Ollama struct {
BaseModel
Options map[string]string `json:"options,omitempty"`
}
func (o *Ollama) MarshalJSON() ([]byte, error) {
type Alias Ollama
return json.Marshal(&struct {
Type string `json:"type"`
*Alias
}{
Type: ModelTypeOllama,
Alias: (*Alias)(o),
})
}
func (o *Ollama) GetType() string {
return ModelTypeOllama
}
type Gemini struct {
BaseModel
MaxOutputTokens *int `json:"max_output_tokens,omitempty"`
}
func (g *Gemini) MarshalJSON() ([]byte, error) {
type Alias Gemini
return json.Marshal(&struct {
Type string `json:"type"`
*Alias
}{
Type: ModelTypeGemini,
Alias: (*Alias)(g),
})
}
func (g *Gemini) GetType() string {
return ModelTypeGemini
}
type Bedrock struct {
BaseModel
// Region is the AWS region where the model is available
Region string `json:"region,omitempty"`
// AdditionalModelRequestFields passes model-specific parameters to Bedrock's
// additionalModelRequestFields in the Converse API. Use this for provider-specific
// options outside the standard InferenceConfiguration block.
AdditionalModelRequestFields map[string]any `json:"additional_model_request_fields,omitempty"`
// PromptCaching enables Bedrock prompt caching by appending a CachePoint
// block to the end of the system content array and the end of the
// toolConfig.tools array in the Converse request. See the
// v1alpha3.BedrockConfig CRD doc for context.
PromptCaching bool `json:"prompt_caching,omitempty"`
// CacheTTL selects the cache retention window when PromptCaching is on:
// "5m" (default) or "1h". See the v1alpha3.BedrockConfig CRD doc for the
// cost/compatibility trade-offs of "1h".
CacheTTL string `json:"cache_ttl,omitempty"`
Guardrail *BedrockGuardrail `json:"guardrail,omitempty"`
// ReadTimeout is the Bedrock HTTP client read timeout in seconds. Nil keeps
// each runtime's default. Python ADK: overrides botocore's ~60s read timeout,
// which otherwise aborts long completions with a ReadTimeoutError. Go ADK:
// bounds the whole Converse request (overall HTTP client timeout, default 30m).
ReadTimeout *int `json:"read_timeout,omitempty"`
// ConnectTimeout is the Bedrock HTTP client connection-establishment timeout
// in seconds. Nil keeps each runtime's default (Python ADK: botocore; Go ADK:
// net dialer). Bounds connection setup only, not the response read.
ConnectTimeout *int `json:"connect_timeout,omitempty"`
}
type BedrockGuardrail struct {
Identifier string `json:"identifier"`
Version string `json:"version"`
Trace string `json:"trace,omitempty"`
}
func (b *Bedrock) MarshalJSON() ([]byte, error) {
type Alias Bedrock
return json.Marshal(&struct {
Type string `json:"type"`
*Alias
}{
Type: ModelTypeBedrock,
Alias: (*Alias)(b),
})
}
func (b *Bedrock) GetType() string {
return ModelTypeBedrock
}
type SAPAICore struct {
BaseModel
BaseUrl string `json:"base_url"`
ResourceGroup string `json:"resource_group,omitempty"`
AuthUrl string `json:"auth_url,omitempty"`
}
func (s *SAPAICore) MarshalJSON() ([]byte, error) {
type Alias SAPAICore
return json.Marshal(&struct {
Type string `json:"type"`
*Alias
}{
Type: ModelTypeSAPAICore,
Alias: (*Alias)(s),
})
}
func (s *SAPAICore) GetType() string {
return ModelTypeSAPAICore
}
// Foundry is the Azure AI Foundry model type. Authentication is implicit: the
// runtime uses FOUNDRY_API_KEY when set, otherwise DefaultAzureCredential.
type Foundry struct {
BaseModel
Endpoint string `json:"endpoint"`
Deployment string `json:"deployment"`
APIVersion string `json:"api_version"`
}
func (f *Foundry) MarshalJSON() ([]byte, error) {
type Alias Foundry
return json.Marshal(&struct {
Type string `json:"type"`
*Alias
}{
Type: ModelTypeFoundry,
Alias: (*Alias)(f),
})
}
func (f *Foundry) GetType() string {
return ModelTypeFoundry
}
// GenericModel is a catch-all model type used by the Go ADK when the model
// type doesn't match any known constant.
type GenericModel struct {
BaseModel
}
func (g *GenericModel) GetType() string { return g.Type }
func ParseModel(bytes []byte) (Model, error) {
var model BaseModel
if err := json.Unmarshal(bytes, &model); err != nil {
return nil, err
}
switch model.Type {
case ModelTypeGemini:
var gemini Gemini
if err := json.Unmarshal(bytes, &gemini); err != nil {
return nil, err
}
return &gemini, nil
case ModelTypeAzureOpenAI:
var azureOpenAI AzureOpenAI
if err := json.Unmarshal(bytes, &azureOpenAI); err != nil {
return nil, err
}
return &azureOpenAI, nil
case ModelTypeOpenAI:
var openai OpenAI
if err := json.Unmarshal(bytes, &openai); err != nil {
return nil, err
}
return &openai, nil
case ModelTypeAnthropic:
var anthropic Anthropic
if err := json.Unmarshal(bytes, &anthropic); err != nil {
return nil, err
}
return &anthropic, nil
case ModelTypeGeminiVertexAI:
var geminiVertexAI GeminiVertexAI
if err := json.Unmarshal(bytes, &geminiVertexAI); err != nil {
return nil, err
}
return &geminiVertexAI, nil
case ModelTypeGeminiAnthropic:
var geminiAnthropic GeminiAnthropic
if err := json.Unmarshal(bytes, &geminiAnthropic); err != nil {
return nil, err
}
return &geminiAnthropic, nil
case ModelTypeOllama:
var ollama Ollama
if err := json.Unmarshal(bytes, &ollama); err != nil {
return nil, err
}
return &ollama, nil
case ModelTypeBedrock:
var bedrock Bedrock
if err := json.Unmarshal(bytes, &bedrock); err != nil {
return nil, err
}
return &bedrock, nil
case ModelTypeSAPAICore:
var sapAICore SAPAICore
if err := json.Unmarshal(bytes, &sapAICore); err != nil {
return nil, err
}
return &sapAICore, nil
case ModelTypeFoundry:
var foundry Foundry
if err := json.Unmarshal(bytes, &foundry); err != nil {
return nil, err
}
return &foundry, nil
}
return nil, fmt.Errorf("unknown model type: %s", model.Type)
}
type RemoteAgentConfig struct {
Name string `json:"name"`
Url string `json:"url"`
Headers map[string]string `json:"headers,omitempty"`
Description string `json:"description,omitempty"`
// IsolateSessions requests a fresh A2A context_id (and therefore a fresh
// sub-agent session) on every call to this remote agent, instead of the
// default single shared session per tool lifetime. Honored by the Go
// declarative runtime (go/adk/pkg/tools/remote_a2a_tool.go); accepted by
// the Python config model for schema parity only (python/packages/kagent-adk).
IsolateSessions bool `json:"isolate_sessions,omitempty"`
}
// EmbeddingConfig is the embedding model config for memory tools.
// JSON uses "provider" to match Python EmbeddingConfig; unmarshaling accepts "type" for backward compat.
type EmbeddingConfig struct {
Provider string `json:"provider"`
Model string `json:"model"`
BaseUrl string `json:"base_url,omitempty"`
APIKeyPassthrough bool `json:"api_key_passthrough,omitempty"`
// Endpoint, Deployment, and APIVersion are the Azure data-plane settings,
// populated for the providers that use the shared azureai client.
Endpoint string `json:"endpoint,omitempty"`
Deployment string `json:"deployment,omitempty"`
APIVersion string `json:"api_version,omitempty"`
}
func (e *EmbeddingConfig) UnmarshalJSON(data []byte) error {
var tmp struct {
Type string `json:"type"`
Provider string `json:"provider"`
Model string `json:"model"`
BaseUrl string `json:"base_url"`
APIKeyPassthrough bool `json:"api_key_passthrough"`
Endpoint string `json:"endpoint"`
Deployment string `json:"deployment"`
APIVersion string `json:"api_version"`
}
if err := json.Unmarshal(data, &tmp); err != nil {
return err
}
e.Model = tmp.Model
e.BaseUrl = tmp.BaseUrl
e.APIKeyPassthrough = tmp.APIKeyPassthrough
e.Endpoint = tmp.Endpoint
e.Deployment = tmp.Deployment
e.APIVersion = tmp.APIVersion
if tmp.Provider != "" {
e.Provider = tmp.Provider
} else {
e.Provider = tmp.Type
}
return nil
}
// ModelToEmbeddingConfig converts a Model (e.g. from translateModel) to EmbeddingConfig
// so serialized AgentConfig has embedding.provider for Python EmbeddingConfig validation.
func ModelToEmbeddingConfig(m Model) *EmbeddingConfig {
if m == nil {
return nil
}
e := &EmbeddingConfig{Provider: m.GetType()}
switch v := m.(type) {
case *OpenAI:
e.Model = v.Model
e.BaseUrl = v.BaseUrl
e.APIKeyPassthrough = v.APIKeyPassthrough
case *AzureOpenAI:
e.Model = v.Model
e.APIKeyPassthrough = v.APIKeyPassthrough
e.Endpoint = v.Endpoint
e.Deployment = v.Deployment
e.APIVersion = v.APIVersion
case *Anthropic:
e.Model = v.Model
e.BaseUrl = v.BaseUrl
case *GeminiVertexAI:
e.Model = v.Model
case *GeminiAnthropic:
e.Model = v.Model
case *Ollama:
e.Model = v.Model
case *Gemini:
e.Model = v.Model
case *Bedrock:
e.Model = v.Model
case *SAPAICore:
e.Model = v.Model
e.BaseUrl = v.BaseUrl
case *Foundry:
e.Model = v.Model
e.APIKeyPassthrough = v.APIKeyPassthrough
e.Endpoint = v.Endpoint
e.Deployment = v.Deployment
e.APIVersion = v.APIVersion
default:
e.Model = ""
}
return e
}
// MemoryConfig groups all memory-related configuration.
type MemoryConfig struct {
TTLDays int `json:"ttl_days,omitempty"`
Embedding *EmbeddingConfig `json:"embedding,omitempty"`
}
type NetworkConfig struct {
AllowedDomains []string `json:"allowed_domains,omitempty"`
}
// AgentContextConfig is the context management configuration that flows through config.json to the Python runtime.
type AgentContextConfig struct {
Compaction *AgentCompressionConfig `json:"compaction,omitempty"`
}
// AgentCompressionConfig maps to Python's ContextCompressionSettings.
type AgentCompressionConfig struct {
CompactionInterval *int `json:"compaction_interval,omitempty"`
OverlapSize *int `json:"overlap_size,omitempty"`
SummarizerModel Model `json:"summarizer_model,omitempty"`
PromptTemplate string `json:"prompt_template,omitempty"`
TokenThreshold *int `json:"token_threshold,omitempty"`
EventRetentionSize *int `json:"event_retention_size,omitempty"`
}
func (c *AgentCompressionConfig) UnmarshalJSON(data []byte) error {
var tmp struct {
CompactionInterval *int `json:"compaction_interval,omitempty"`
OverlapSize *int `json:"overlap_size,omitempty"`
SummarizerModel json.RawMessage `json:"summarizer_model,omitempty"`
PromptTemplate string `json:"prompt_template,omitempty"`
TokenThreshold *int `json:"token_threshold,omitempty"`
EventRetentionSize *int `json:"event_retention_size,omitempty"`
}
if err := json.Unmarshal(data, &tmp); err != nil {
return err
}
c.CompactionInterval = tmp.CompactionInterval
c.OverlapSize = tmp.OverlapSize
c.PromptTemplate = tmp.PromptTemplate
c.TokenThreshold = tmp.TokenThreshold
c.EventRetentionSize = tmp.EventRetentionSize
if len(tmp.SummarizerModel) > 0 && string(tmp.SummarizerModel) != "null" {
model, err := ParseModel(tmp.SummarizerModel)
if err != nil {
return fmt.Errorf("failed to parse summarizer model: %w", err)
}
c.SummarizerModel = model
}
return nil
}
// See `python/packages/kagent-adk/src/kagent/adk/types.py` for the python version of this
type AgentConfig struct {
Name string `json:"name,omitempty"`
Model Model `json:"model"`
Description string `json:"description"`
Instruction string `json:"instruction"`
HttpTools []HttpMcpServerConfig `json:"http_tools,omitempty"`
SseTools []SseMcpServerConfig `json:"sse_tools,omitempty"`
StdioTools []StdioMcpServerConfig `json:"stdio_tools,omitempty"`
RemoteAgents []RemoteAgentConfig `json:"remote_agents,omitempty"`
Stream *bool `json:"stream,omitempty"`
Memory *MemoryConfig `json:"memory,omitempty"`
Network *NetworkConfig `json:"network,omitempty"`
AgentPlugins *agentplugin.Resources `json:"agent_plugins,omitempty"`
ContextConfig *AgentContextConfig `json:"context_config,omitempty"`
ShareTools *bool `json:"share_tools,omitempty"`
SessionDBURL string `json:"session_db_url,omitempty"`
SkillsDirectory string `json:"skills_directory,omitempty"`
SubAgents []*AgentConfig `json:"sub_agents,omitempty"`
}
// GetStream returns the stream value or default if not set
func (a *AgentConfig) GetStream() bool {
if a.Stream != nil {
return *a.Stream
}
return false
}
func (a *AgentConfig) UnmarshalJSON(data []byte) error {
var tmp struct {
Name string `json:"name,omitempty"`
Model json.RawMessage `json:"model"`
Description string `json:"description"`
Instruction string `json:"instruction"`
HttpTools []HttpMcpServerConfig `json:"http_tools,omitempty"`
SseTools []SseMcpServerConfig `json:"sse_tools,omitempty"`
StdioTools []StdioMcpServerConfig `json:"stdio_tools,omitempty"`
RemoteAgents []RemoteAgentConfig `json:"remote_agents,omitempty"`
Stream *bool `json:"stream,omitempty"`
Memory json.RawMessage `json:"memory"`
Network *NetworkConfig `json:"network,omitempty"`
AgentPlugins *agentplugin.Resources `json:"agent_plugins,omitempty"`
ContextConfig *AgentContextConfig `json:"context_config,omitempty"`
ShareTools *bool `json:"share_tools,omitempty"`
SessionDBURL string `json:"session_db_url,omitempty"`
SkillsDirectory string `json:"skills_directory,omitempty"`
SubAgents []*AgentConfig `json:"sub_agents,omitempty"`
}
if err := json.Unmarshal(data, &tmp); err != nil {
return err
}
// BYO agents carry a minimal config with no model (it marshals as "model":null); a config
// without a model is legal and must round-trip — ParseModel would reject it.
var model Model
if len(tmp.Model) > 0 && string(tmp.Model) != "null" {
var err error
model, err = ParseModel(tmp.Model)
if err != nil {
return err
}
}
var memory *MemoryConfig
if len(tmp.Memory) > 0 && string(tmp.Memory) != "null" {
var m MemoryConfig
if err := json.Unmarshal(tmp.Memory, &m); err != nil {
return err
}
memory = &m
}
a.Name = tmp.Name
a.Model = model
a.Description = tmp.Description
a.Instruction = tmp.Instruction
a.HttpTools = tmp.HttpTools
a.SseTools = tmp.SseTools
a.StdioTools = tmp.StdioTools
a.RemoteAgents = tmp.RemoteAgents
a.Stream = tmp.Stream
a.Memory = memory
a.Network = tmp.Network
a.AgentPlugins = tmp.AgentPlugins
a.ContextConfig = tmp.ContextConfig
a.ShareTools = tmp.ShareTools
a.SessionDBURL = tmp.SessionDBURL
a.SkillsDirectory = tmp.SkillsDirectory
a.SubAgents = tmp.SubAgents
return nil
}
var _ sql.Scanner = &AgentConfig{}
func (a *AgentConfig) Scan(value any) error {
return json.Unmarshal(value.([]byte), a)
}
var _ driver.Valuer = &AgentConfig{}
func (a AgentConfig) Value() (driver.Value, error) {
return json.Marshal(a)
}