mirror of
https://github.com/memohai/Memoh.git
synced 2026-04-25 07:00:48 +09:00
fix(agent): skip tool injection for models without tool-call capability
Models that lack the "tool-call" compatibility flag now run without tools, preventing provider errors when the model does not support function calling.
This commit is contained in:
+15
-7
@@ -63,10 +63,14 @@ func (a *Agent) Generate(ctx context.Context, cfg RunConfig) (*GenerateResult, e
|
||||
}
|
||||
|
||||
func (a *Agent) runStream(ctx context.Context, cfg RunConfig, ch chan<- StreamEvent) {
|
||||
tools, err := a.assembleTools(ctx, cfg)
|
||||
if err != nil {
|
||||
ch <- StreamEvent{Type: EventError, Error: fmt.Sprintf("assemble tools: %v", err)}
|
||||
return
|
||||
var tools []sdk.Tool
|
||||
if cfg.SupportsToolCall {
|
||||
var err error
|
||||
tools, err = a.assembleTools(ctx, cfg)
|
||||
if err != nil {
|
||||
ch <- StreamEvent{Type: EventError, Error: fmt.Sprintf("assemble tools: %v", err)}
|
||||
return
|
||||
}
|
||||
}
|
||||
tools, readMediaState := decorateReadMediaTools(cfg.Model, tools)
|
||||
|
||||
@@ -312,9 +316,13 @@ func (a *Agent) runStream(ctx context.Context, cfg RunConfig, ch chan<- StreamEv
|
||||
}
|
||||
|
||||
func (a *Agent) runGenerate(ctx context.Context, cfg RunConfig) (*GenerateResult, error) {
|
||||
tools, err := a.assembleTools(ctx, cfg)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("assemble tools: %w", err)
|
||||
var tools []sdk.Tool
|
||||
if cfg.SupportsToolCall {
|
||||
var err error
|
||||
tools, err = a.assembleTools(ctx, cfg)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("assemble tools: %w", err)
|
||||
}
|
||||
}
|
||||
tools, readMediaState := decorateReadMediaTools(cfg.Model, tools)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user