Skip to content

Commit d3f67ba

Browse files
committed
chore: unifying logic, removing HasInjectableTools from interface
Signed-off-by: Danny Kopping <danny@coder.com>
1 parent 116f02f commit d3f67ba

5 files changed

Lines changed: 7 additions & 12 deletions

File tree

intercept/chatcompletions/base.go

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -103,14 +103,12 @@ func (i *interceptionBase) newErrorResponse(err error) map[string]any {
103103
}
104104

105105
func (i *interceptionBase) injectTools() {
106-
if i.req == nil || i.mcpProxy == nil {
106+
if i.req == nil || i.mcpProxy == nil || !i.hasInjectableTools() {
107107
return
108108
}
109109

110110
// Disable parallel tool calls when injectable tools are present to simplify the inner agentic loop.
111-
if i.HasInjectableTools() {
112-
i.req.ParallelToolCalls = openai.Bool(false)
113-
}
111+
i.req.ParallelToolCalls = openai.Bool(false)
114112

115113
// Inject tools.
116114
for _, tool := range i.mcpProxy.ListTools() {
@@ -176,7 +174,7 @@ func (i *interceptionBase) writeUpstreamError(w http.ResponseWriter, oaiErr *err
176174
}
177175
}
178176

179-
func (i *interceptionBase) HasInjectableTools() bool {
177+
func (i *interceptionBase) hasInjectableTools() bool {
180178
return i.mcpProxy != nil && len(i.mcpProxy.ListTools()) > 0
181179
}
182180

intercept/interceptor.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,4 @@ type Interceptor interface {
3434
// by the model, so any single tool call ID is sufficient to identify the
3535
// parent interception.
3636
CorrelatingToolCallID() *string
37-
// HasInjectableTools returns true if an [mcp.ServerProxier] has been provided
38-
// and contains tools which must be injected into requests.
39-
HasInjectableTools() bool
4037
}

intercept/messages/base.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ func (s *interceptionBase) baseTraceAttributes(r *http.Request, streaming bool)
101101
}
102102

103103
func (i *interceptionBase) injectTools() {
104-
if i.req == nil || i.mcpProxy == nil || !i.HasInjectableTools() {
104+
if i.req == nil || i.mcpProxy == nil || !i.hasInjectableTools() {
105105
return
106106
}
107107

@@ -314,7 +314,7 @@ func (i *interceptionBase) writeUpstreamError(w http.ResponseWriter, antErr *Err
314314
}
315315
}
316316

317-
func (i *interceptionBase) HasInjectableTools() bool {
317+
func (i *interceptionBase) hasInjectableTools() bool {
318318
return i.mcpProxy != nil && len(i.mcpProxy.ListTools()) > 0
319319
}
320320

intercept/responses/base.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,7 @@ func (i *responsesInterceptionBase) recordTokenUsage(ctx context.Context, respon
326326
}
327327
}
328328

329-
func (i *responsesInterceptionBase) HasInjectableTools() bool {
329+
func (i *responsesInterceptionBase) hasInjectableTools() bool {
330330
return i.mcpProxy != nil && len(i.mcpProxy.ListTools()) > 0
331331
}
332332

intercept/responses/injected_tools.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import (
1616
)
1717

1818
func (i *responsesInterceptionBase) injectTools() {
19-
if i.req == nil || i.mcpProxy == nil || !i.HasInjectableTools() {
19+
if i.req == nil || i.mcpProxy == nil || !i.hasInjectableTools() {
2020
return
2121
}
2222

0 commit comments

Comments
 (0)