()
| 139 | } |
| 140 | |
| 141 | func (i *interceptionBase) injectTools() { |
| 142 | if i.req == nil || i.mcpProxy == nil || !i.hasInjectableTools() { |
| 143 | return |
| 144 | } |
| 145 | |
| 146 | // Disable parallel tool calls when injectable tools are present to simplify the inner agentic loop. |
| 147 | i.req.ParallelToolCalls = openai.Bool(false) |
| 148 | |
| 149 | // Inject tools. |
| 150 | for _, tool := range i.mcpProxy.ListTools() { |
| 151 | fn := openai.ChatCompletionToolUnionParam{ |
| 152 | OfFunction: &openai.ChatCompletionFunctionToolParam{ |
| 153 | Function: openai.FunctionDefinitionParam{ |
| 154 | Name: tool.ID, |
| 155 | Strict: openai.Bool(false), // TODO: configurable. |
| 156 | Description: openai.String(tool.Description), |
| 157 | Parameters: openai.FunctionParameters{ |
| 158 | "type": "object", |
| 159 | "properties": tool.Params, |
| 160 | // "additionalProperties": false, // Only relevant when strict=true. |
| 161 | }, |
| 162 | }, |
| 163 | }, |
| 164 | } |
| 165 | |
| 166 | // Otherwise the request fails with "None is not of type 'array'" if a nil slice is given. |
| 167 | if len(tool.Required) > 0 { |
| 168 | // Must list ALL properties when strict=true. |
| 169 | fn.OfFunction.Function.Parameters["required"] = tool.Required |
| 170 | } |
| 171 | |
| 172 | i.req.Tools = append(i.req.Tools, fn) |
| 173 | } |
| 174 | } |
| 175 | |
| 176 | func (i *interceptionBase) unmarshalArgs(in string) (args recorder.ToolArgs) { |
| 177 | if len(strings.TrimSpace(in)) == 0 { |
no test coverage detected