GeezerVison is showing github.com — fix[plugins](soc-ai): changed toolcall usage policy and temperature · utmstack/UTMStack@e933c87
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: plugins/soc-ai/internal/agent/anthropic.go +3Lines changed: 3 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -61,6 +61,9 @@ func (c *anthropicClient) Complete(ctx context.Context, req CompletionRequest) ( | 61 | 61 | if req.System != "" { | 62 | 62 | payload["system"] = req.System | 63 | 63 | } | | 64 | + if req.Temperature > 0 { | | 65 | + payload["temperature"] = req.Temperature | | 66 | + } | 64 | 67 | if len(tools) > 0 { | 65 | 68 | payload["tools"] = tools | 66 | 69 | } | |
Collapse file Copy file name to clipboardExpand all lines: plugins/soc-ai/internal/agent/llm.go +6-5Lines changed: 6 additions & 5 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -44,11 +44,12 @@ type Message struct { | 44 | 44 | } | 45 | 45 |
| 46 | 46 | type CompletionRequest struct { | 47 | | - System string | 48 | | - Messages []Message | 49 | | - Tools []ToolSpec | 50 | | - Model string | 51 | | - MaxTokens int | | 47 | + System string | | 48 | + Messages []Message | | 49 | + Tools []ToolSpec | | 50 | + Model string | | 51 | + MaxTokens int | | 52 | + Temperature float64 // 0 = provider default; ops path sets it low to curb exploratory tool use | 52 | 53 | } | 53 | 54 |
| 54 | 55 | type CompletionResponse struct { | |
Collapse file Copy file name to clipboardExpand all lines: plugins/soc-ai/internal/agent/loop.go +13-10Lines changed: 13 additions & 10 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -85,6 +85,7 @@ type RunTask struct { | 85 | 85 | EnabledGroups []string | 86 | 86 | AlwaysAllow []string | 87 | 87 | MaxIters int | | 88 | + Temperature float64 // 0 = provider default | 88 | 89 | } | 89 | 90 |
| 90 | 91 | type RunResult struct { | @@ -190,11 +191,12 @@ func (a *Agent) Run(ctx context.Context, task RunTask, sink EventSink) (RunResul | 190 | 191 | } | 191 | 192 |
| 192 | 193 | resp, err := a.llm.Complete(ctx, CompletionRequest{ | 193 | | - System: task.System, | 194 | | - Messages: msgs, | 195 | | - Tools: stepTools, | 196 | | - Model: a.model, | 197 | | - MaxTokens: a.maxTokens, | | 194 | + System: task.System, | | 195 | + Messages: msgs, | | 196 | + Tools: stepTools, | | 197 | + Model: a.model, | | 198 | + MaxTokens: a.maxTokens, | | 199 | + Temperature: task.Temperature, | 198 | 200 | }) | 199 | 201 | if err != nil { | 200 | 202 | _ = catcher.Error("llm completion failed", err, map[string]any{ | @@ -291,11 +293,12 @@ func (a *Agent) Run(ctx context.Context, task RunTask, sink EventSink) (RunResul | 291 | 293 | func (a *Agent) finalizeGracefully(ctx context.Context, task RunTask, msgs []Message, result RunResult, sink EventSink, prompt, fallbackMsg string) (RunResult, error) { | 292 | 294 | msgs = append(msgs, Message{Role: RoleUser, Content: prompt}) | 293 | 295 | finalResp, ferr := a.llm.Complete(ctx, CompletionRequest{ | 294 | | - System: task.System, | 295 | | - Messages: msgs, | 296 | | - Model: a.model, | 297 | | - MaxTokens: a.maxTokens, | 298 | | - }) | | 296 | + System: task.System, | | 297 | + Messages: msgs, | | 298 | + Model: a.model, | | 299 | + MaxTokens: a.maxTokens, | | 300 | + Temperature: task.Temperature, | | 301 | + }) | 299 | 302 | if ferr != nil { | 300 | 303 | _ = catcher.Error("finalization llm call failed", ferr, map[string]any{ | 301 | 304 | "process": "plugin_com.utmstack.soc-ai", | |
Collapse file Copy file name to clipboardExpand all lines: plugins/soc-ai/internal/agent/openai.go +7-1Lines changed: 7 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -55,6 +55,7 @@ type oaRequest struct { | 55 | 55 | Messages []oaMessage `json:"messages"` | 56 | 56 | Tools []oaTool `json:"tools,omitempty"` | 57 | 57 | MaxTokens int `json:"max_tokens,omitempty"` | | 58 | + Temperature *float64 `json:"temperature,omitempty"` | 58 | 59 | } | 59 | 60 |
| 60 | 61 | type oaResponse struct { | @@ -112,7 +113,12 @@ func (c *openaiClient) Complete(ctx context.Context, req CompletionRequest) (Com | 112 | 113 | tools = append(tools, oaTool{Type: "function", Function: oaToolDef{Name: t.Name, Description: t.Description, Parameters: params}}) | 113 | 114 | } | 114 | 115 |
| 115 | | - body, err := json.Marshal(oaRequest{Model: req.Model, Messages: msgs, Tools: tools, MaxTokens: req.MaxTokens}) | | 116 | + oreq := oaRequest{Model: req.Model, Messages: msgs, Tools: tools, MaxTokens: req.MaxTokens} | | 117 | + if req.Temperature > 0 { | | 118 | + t := req.Temperature | | 119 | + oreq.Temperature = &t | | 120 | + } | | 121 | + body, err := json.Marshal(oreq) | 116 | 122 | if err != nil { | 117 | 123 | return CompletionResponse{}, fmt.Errorf("marshal request: %w", err) | 118 | 124 | } | |
Collapse file Copy file name to clipboardExpand all lines: plugins/soc-ai/internal/agent/prompt.go +4-3Lines changed: 4 additions & 3 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -96,9 +96,10 @@ Use this to choose the most relevant tools and to craft navigation. For example, | 96 | 96 | ` + permissionsBlock(enabledGroups) + ` | 97 | 97 |
| 98 | 98 | ## How to work | 99 | | -- Carry the task end to end. | 100 | | -- Use tools ONLY when you need data or actions you don't already have. Many messages need few or no tools — do not over-call; prefer the smallest set of tools that answers the question. | 101 | | -- Prefer read-only tools to investigate before any mutating or response action. Mutating/response actions (changing status, creating incidents, running SOAR jobs, etc.) take effect immediately — only perform them when the task clearly asks for them. | | 99 | +- Answer directly first. If you can answer from your own knowledge or from what the user already said, do not call any tool. Tools are for data you lack, not for confirmation or extra context. | | 100 | +- When tools are needed, carry the task end to end and act autonomously — do not ask the user anything. | | 101 | +- Use read-only tools to investigate before any mutating or response action. Mutating/response actions (changing status, creating incidents, running SOAR jobs, etc.) take effect immediately — only perform them when the task clearly asks for them. | | 102 | +- Prefer the smallest set of tools that answers the question; do not over-call. | 102 | 103 | - Never invent data; rely on tool results. If a tool fails, adapt or report it plainly. | 103 | 104 | - Batch independent tool calls into the SAME turn instead of one per turn. If a task involves N similar items (several widgets, several filter fields, several lookups), each tool call for one item never depends on another item's result — issue all of them together, not one-then-wait-then-next. Only go one at a time when a call genuinely needs the previous call's output (e.g. you need a dashboard's id before adding a widget to it). A task that takes 15 round trips done one item at a time usually takes 3-4 done this way. | 104 | 105 |
| |
Collapse file Copy file name to clipboardExpand all lines: plugins/soc-ai/internal/api/server.go +1Lines changed: 1 addition & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -227,6 +227,7 @@ func handleAgentTask(w http.ResponseWriter, r *http.Request) { | 227 | 227 | History: toHistory(req.History), | 228 | 228 | EnabledGroups: capabilities, | 229 | 229 | MaxIters: maxIters, | | 230 | + Temperature: 0.3, | 230 | 231 | }, sink) | 231 | 232 | } | 232 | 233 |
| |
|