Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
437 changes: 144 additions & 293 deletions core/bifrost.go

Large diffs are not rendered by default.

27 changes: 0 additions & 27 deletions core/internal/mcptests/agent_adapter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,6 @@ func TestAgent_Adapter_ResponsesFormat_BasicLoop(t *testing.T) {

result, bifrostErr := manager.CheckAndExecuteAgentForResponsesRequest(
ctx, req, initialResponse, mocker.MakeResponsesRequest,
func(ctx *schemas.BifrostContext, request *schemas.BifrostMCPRequest) (*schemas.BifrostMCPResponse, error) {
return manager.ExecuteToolCall(ctx, request)
},
)

// Assertions
Expand Down Expand Up @@ -113,9 +110,6 @@ func TestAgent_Adapter_ResponsesFormat_EmptyToolResult(t *testing.T) {

result, bifrostErr := manager.CheckAndExecuteAgentForResponsesRequest(
ctx, req, initialResponse, mocker.MakeResponsesRequest,
func(ctx *schemas.BifrostContext, request *schemas.BifrostMCPRequest) (*schemas.BifrostMCPResponse, error) {
return manager.ExecuteToolCall(ctx, request)
},
)

// Assertions
Expand Down Expand Up @@ -185,9 +179,6 @@ func TestAgent_Adapter_ResponsesFormat_MultipleToolCalls(t *testing.T) {

result, bifrostErr := manager.CheckAndExecuteAgentForResponsesRequest(
ctx, req, initialResponse, mocker.MakeResponsesRequest,
func(ctx *schemas.BifrostContext, request *schemas.BifrostMCPRequest) (*schemas.BifrostMCPResponse, error) {
return manager.ExecuteToolCall(ctx, request)
},
)

// Assertions
Expand Down Expand Up @@ -237,9 +228,6 @@ func TestAgent_Adapter_ResponsesFormat_MixedPermissions(t *testing.T) {

result, bifrostErr := manager.CheckAndExecuteAgentForResponsesRequest(
ctx, req, initialResponse, mocker.MakeResponsesRequest,
func(ctx *schemas.BifrostContext, request *schemas.BifrostMCPRequest) (*schemas.BifrostMCPResponse, error) {
return manager.ExecuteToolCall(ctx, request)
},
)

// Assertions
Expand Down Expand Up @@ -302,9 +290,6 @@ func TestAgent_Adapter_ResponsesFormat_STDIO(t *testing.T) {

result, bifrostErr := manager.CheckAndExecuteAgentForResponsesRequest(
ctx, req, initialResponse, mocker.MakeResponsesRequest,
func(ctx *schemas.BifrostContext, request *schemas.BifrostMCPRequest) (*schemas.BifrostMCPResponse, error) {
return manager.ExecuteToolCall(ctx, request)
},
)

// Assertions
Expand Down Expand Up @@ -368,9 +353,6 @@ func TestAgent_Adapter_ResponsesFormat_DeepChain(t *testing.T) {

result, bifrostErr := manager.CheckAndExecuteAgentForResponsesRequest(
ctx, req, initialResponse, mocker.MakeResponsesRequest,
func(ctx *schemas.BifrostContext, request *schemas.BifrostMCPRequest) (*schemas.BifrostMCPResponse, error) {
return manager.ExecuteToolCall(ctx, request)
},
)

// Assertions
Expand Down Expand Up @@ -422,9 +404,6 @@ func TestAgent_Adapter_ResponsesFormat_ErrorHandling(t *testing.T) {

result, bifrostErr := manager.CheckAndExecuteAgentForResponsesRequest(
ctx, req, initialResponse, mocker.MakeResponsesRequest,
func(ctx *schemas.BifrostContext, request *schemas.BifrostMCPRequest) (*schemas.BifrostMCPResponse, error) {
return manager.ExecuteToolCall(ctx, request)
},
)

// Assertions
Expand Down Expand Up @@ -502,9 +481,6 @@ func TestAgent_Adapter_ChatAndResponsesParity(t *testing.T) {

chatResult, chatErr := managerChat.CheckAndExecuteAgentForChatRequest(
ctxChat, chatReq, chatInitialResponse, mockerChat.MakeChatRequest,
func(ctx *schemas.BifrostContext, request *schemas.BifrostMCPRequest) (*schemas.BifrostMCPResponse, error) {
return managerChat.ExecuteToolCall(ctx, request)
},
)

// Execute Responses API
Expand All @@ -519,9 +495,6 @@ func TestAgent_Adapter_ChatAndResponsesParity(t *testing.T) {

responsesResult, responsesErr := managerResponses.CheckAndExecuteAgentForResponsesRequest(
ctxResponses, responsesReq, responsesInitialResponse, mockerResponses.MakeResponsesRequest,
func(ctx *schemas.BifrostContext, request *schemas.BifrostMCPRequest) (*schemas.BifrostMCPResponse, error) {
return managerResponses.ExecuteToolCall(ctx, request)
},
)

// Assertions: Both should complete successfully
Expand Down
28 changes: 0 additions & 28 deletions core/internal/mcptests/agent_basic_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,10 +107,6 @@ func TestAgent_BasicLoop(t *testing.T) {
originalReq,
initialResponse,
mockLLM.MakeChatRequest,
func(ctx *schemas.BifrostContext, request *schemas.BifrostMCPRequest) (*schemas.BifrostMCPResponse, error) {
// Use real tool execution
return manager.ExecuteToolCall(ctx, request)
},
)

require.Nil(t, bifrostErr, "agent loop should complete successfully")
Expand Down Expand Up @@ -170,9 +166,6 @@ func TestAgent_BasicLoop_ChatFormat(t *testing.T) {
originalReq,
initialResponse,
mockLLM.MakeChatRequest,
func(ctx *schemas.BifrostContext, request *schemas.BifrostMCPRequest) (*schemas.BifrostMCPResponse, error) {
return manager.ExecuteToolCall(ctx, request)
},
)

require.Nil(t, bifrostErr)
Expand Down Expand Up @@ -233,9 +226,6 @@ func TestAgent_BasicLoop_ResponsesFormat(t *testing.T) {
originalReq,
initialResponse,
mockLLM.MakeResponsesRequest,
func(ctx *schemas.BifrostContext, request *schemas.BifrostMCPRequest) (*schemas.BifrostMCPResponse, error) {
return manager.ExecuteToolCall(ctx, request)
},
)

require.Nil(t, bifrostErr)
Expand Down Expand Up @@ -294,9 +284,6 @@ func TestAgent_SingleIteration(t *testing.T) {
originalReq,
initialResponse,
mockLLM.MakeChatRequest,
func(ctx *schemas.BifrostContext, request *schemas.BifrostMCPRequest) (*schemas.BifrostMCPResponse, error) {
return manager.ExecuteToolCall(ctx, request)
},
)

require.Nil(t, bifrostErr)
Expand Down Expand Up @@ -372,9 +359,6 @@ func TestAgent_MultipleIterations(t *testing.T) {
originalReq,
initialResponse,
mockLLM.MakeChatRequest,
func(ctx *schemas.BifrostContext, request *schemas.BifrostMCPRequest) (*schemas.BifrostMCPResponse, error) {
return manager.ExecuteToolCall(ctx, request)
},
)

require.Nil(t, bifrostErr)
Expand Down Expand Up @@ -429,9 +413,6 @@ func TestAgent_NoToolCalls(t *testing.T) {
originalReq,
initialResponse,
mockLLM.MakeChatRequest,
func(ctx *schemas.BifrostContext, request *schemas.BifrostMCPRequest) (*schemas.BifrostMCPResponse, error) {
return manager.ExecuteToolCall(ctx, request)
},
)

require.Nil(t, bifrostErr)
Expand Down Expand Up @@ -496,9 +477,6 @@ func TestAgent_MixedAutoAndNonAutoTools(t *testing.T) {
originalReq,
initialResponse,
mockLLM.MakeChatRequest,
func(ctx *schemas.BifrostContext, request *schemas.BifrostMCPRequest) (*schemas.BifrostMCPResponse, error) {
return manager.ExecuteToolCall(ctx, request)
},
)

require.Nil(t, bifrostErr)
Expand Down Expand Up @@ -575,9 +553,6 @@ func TestAgent_OnlyAutoTools(t *testing.T) {
originalReq,
initialResponse,
mockLLM.MakeChatRequest,
func(ctx *schemas.BifrostContext, request *schemas.BifrostMCPRequest) (*schemas.BifrostMCPResponse, error) {
return manager.ExecuteToolCall(ctx, request)
},
)

require.Nil(t, bifrostErr)
Expand Down Expand Up @@ -637,9 +612,6 @@ func TestAgent_OnlyNonAutoTools(t *testing.T) {
originalReq,
initialResponse,
mockLLM.MakeChatRequest,
func(ctx *schemas.BifrostContext, request *schemas.BifrostMCPRequest) (*schemas.BifrostMCPResponse, error) {
return manager.ExecuteToolCall(ctx, request)
},
)

require.Nil(t, bifrostErr)
Expand Down
24 changes: 0 additions & 24 deletions core/internal/mcptests/agent_context_filtering_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,6 @@ func TestAgent_ContextToolFilter_Whitelist(t *testing.T) {

result, bifrostErr := manager.CheckAndExecuteAgentForChatRequest(
ctx, req, initialResponse, mocker.MakeChatRequest,
func(ctx *schemas.BifrostContext, request *schemas.BifrostMCPRequest) (*schemas.BifrostMCPResponse, error) {
return manager.ExecuteToolCall(ctx, request)
},
)

// Assertions
Expand Down Expand Up @@ -117,9 +114,6 @@ func TestAgent_ContextToolFilter_BlockedToolError(t *testing.T) {

result, bifrostErr := manager.CheckAndExecuteAgentForChatRequest(
ctx, req, initialResponse, mocker.MakeChatRequest,
func(ctx *schemas.BifrostContext, request *schemas.BifrostMCPRequest) (*schemas.BifrostMCPResponse, error) {
return manager.ExecuteToolCall(ctx, request)
},
)

// Assertions
Expand Down Expand Up @@ -175,9 +169,6 @@ func TestAgent_ContextClientFilter_Whitelist(t *testing.T) {

result, bifrostErr := manager.CheckAndExecuteAgentForChatRequest(
ctx, req, initialResponse, mocker.MakeChatRequest,
func(ctx *schemas.BifrostContext, request *schemas.BifrostMCPRequest) (*schemas.BifrostMCPResponse, error) {
return manager.ExecuteToolCall(ctx, request)
},
)

// Assertions
Expand Down Expand Up @@ -226,9 +217,6 @@ func TestAgent_ContextNarrowing_AutoExecute(t *testing.T) {

result, bifrostErr := manager.CheckAndExecuteAgentForChatRequest(
ctx, req, initialResponse, mocker.MakeChatRequest,
func(ctx *schemas.BifrostContext, request *schemas.BifrostMCPRequest) (*schemas.BifrostMCPResponse, error) {
return manager.ExecuteToolCall(ctx, request)
},
)

// Assertions
Expand Down Expand Up @@ -275,9 +263,6 @@ func TestAgent_ContextToolFilter_EmptyList(t *testing.T) {

result, bifrostErr := manager.CheckAndExecuteAgentForChatRequest(
ctx, req, initialResponse, mocker.MakeChatRequest,
func(ctx *schemas.BifrostContext, request *schemas.BifrostMCPRequest) (*schemas.BifrostMCPResponse, error) {
return manager.ExecuteToolCall(ctx, request)
},
)

// Assertions
Expand Down Expand Up @@ -340,9 +325,6 @@ func TestAgent_ContextToolFilter_WildcardOverride(t *testing.T) {

result, bifrostErr := manager.CheckAndExecuteAgentForChatRequest(
ctx, req, initialResponse, mocker.MakeChatRequest,
func(ctx *schemas.BifrostContext, request *schemas.BifrostMCPRequest) (*schemas.BifrostMCPResponse, error) {
return manager.ExecuteToolCall(ctx, request)
},
)

// Assertions
Expand Down Expand Up @@ -412,9 +394,6 @@ func TestAgent_ContextClientFilter_MultipleClients(t *testing.T) {

result, bifrostErr := manager.CheckAndExecuteAgentForChatRequest(
ctx, req, initialResponse, mocker.MakeChatRequest,
func(ctx *schemas.BifrostContext, request *schemas.BifrostMCPRequest) (*schemas.BifrostMCPResponse, error) {
return manager.ExecuteToolCall(ctx, request)
},
)

// Assertions
Expand Down Expand Up @@ -465,9 +444,6 @@ func TestAgent_ContextToolFilter_ParallelMixed(t *testing.T) {

result, bifrostErr := manager.CheckAndExecuteAgentForChatRequest(
ctx, req, initialResponse, mocker.MakeChatRequest,
func(ctx *schemas.BifrostContext, request *schemas.BifrostMCPRequest) (*schemas.BifrostMCPResponse, error) {
return manager.ExecuteToolCall(ctx, request)
},
)

// Assertions
Expand Down
18 changes: 0 additions & 18 deletions core/internal/mcptests/agent_error_handling_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,6 @@ func TestAgent_ErrorHandling_AllToolsFail(t *testing.T) {
originalReq,
initialResponse,
mockLLM.MakeChatRequest,
func(ctx *schemas.BifrostContext, request *schemas.BifrostMCPRequest) (*schemas.BifrostMCPResponse, error) {
return manager.ExecuteToolCall(ctx, request)
},
)

// Agent should handle all failures gracefully
Expand Down Expand Up @@ -173,9 +170,6 @@ func TestAgent_ErrorHandling_TimeoutInLoop(t *testing.T) {
originalReq,
initialResponse,
mockLLM.MakeChatRequest,
func(ctx *schemas.BifrostContext, request *schemas.BifrostMCPRequest) (*schemas.BifrostMCPResponse, error) {
return manager.ExecuteToolCall(ctx, request)
},
)

// Should handle timeout gracefully
Expand Down Expand Up @@ -340,9 +334,6 @@ func TestAgent_ErrorHandling_PartialBatchFailure(t *testing.T) {
originalReq,
initialResponse,
mockLLM.MakeChatRequest,
func(ctx *schemas.BifrostContext, request *schemas.BifrostMCPRequest) (*schemas.BifrostMCPResponse, error) {
return manager.ExecuteToolCall(ctx, request)
},
)

require.Nil(t, bifrostErr, "partial failures should not crash agent")
Expand Down Expand Up @@ -433,9 +424,6 @@ func TestAgent_ErrorHandling_RecoveryAndContinuation(t *testing.T) {
originalReq,
initialResponse,
mockLLM.MakeChatRequest,
func(ctx *schemas.BifrostContext, request *schemas.BifrostMCPRequest) (*schemas.BifrostMCPResponse, error) {
return manager.ExecuteToolCall(ctx, request)
},
)

require.Nil(t, bifrostErr, "agent should recover from error")
Expand Down Expand Up @@ -575,9 +563,6 @@ func TestAgent_ErrorHandling_MultipleErrorsInSequence(t *testing.T) {
originalReq,
initialResponse,
mockLLM.MakeChatRequest,
func(ctx *schemas.BifrostContext, request *schemas.BifrostMCPRequest) (*schemas.BifrostMCPResponse, error) {
return manager.ExecuteToolCall(ctx, request)
},
)

require.Nil(t, bifrostErr, "agent should handle multiple sequential errors")
Expand Down Expand Up @@ -649,9 +634,6 @@ func TestAgent_ErrorHandling_ErrorMessagePreservation(t *testing.T) {
originalReq,
initialResponse,
mockLLM.MakeChatRequest,
func(ctx *schemas.BifrostContext, request *schemas.BifrostMCPRequest) (*schemas.BifrostMCPResponse, error) {
return manager.ExecuteToolCall(ctx, request)
},
)

require.Nil(t, bifrostErr)
Expand Down
Loading
Loading