@@ -396,95 +396,6 @@ describe("session.llm.stream", () => {
396396 } )
397397 } )
398398
399- test ( "keeps tools enabled by prompt permissions" , async ( ) => {
400- const server = state . server
401- if ( ! server ) {
402- throw new Error ( "Server not initialized" )
403- }
404-
405- const providerID = "alibaba"
406- const modelID = "qwen-plus"
407- const fixture = await loadFixture ( providerID , modelID )
408- const model = fixture . model
409-
410- const request = waitRequest (
411- "/chat/completions" ,
412- new Response ( createChatStream ( "Hello" ) , {
413- status : 200 ,
414- headers : { "Content-Type" : "text/event-stream" } ,
415- } ) ,
416- )
417-
418- await using tmp = await tmpdir ( {
419- init : async ( dir ) => {
420- await Bun . write (
421- path . join ( dir , "opencode.json" ) ,
422- JSON . stringify ( {
423- $schema : "https://opencode.ai/config.json" ,
424- enabled_providers : [ providerID ] ,
425- provider : {
426- [ providerID ] : {
427- options : {
428- apiKey : "test-key" ,
429- baseURL : `${ server . url . origin } /v1` ,
430- } ,
431- } ,
432- } ,
433- } ) ,
434- )
435- } ,
436- } )
437-
438- await Instance . provide ( {
439- directory : tmp . path ,
440- fn : async ( ) => {
441- const resolved = await Provider . getModel ( ProviderID . make ( providerID ) , ModelID . make ( model . id ) )
442- const sessionID = SessionID . make ( "session-test-tools" )
443- const agent = {
444- name : "test" ,
445- mode : "primary" ,
446- options : { } ,
447- permission : [ { permission : "question" , pattern : "*" , action : "deny" } ] ,
448- } satisfies Agent . Info
449-
450- const user = {
451- id : MessageID . make ( "user-tools" ) ,
452- sessionID,
453- role : "user" ,
454- time : { created : Date . now ( ) } ,
455- agent : agent . name ,
456- model : { providerID : ProviderID . make ( providerID ) , modelID : resolved . id } ,
457- tools : { question : true } ,
458- } satisfies MessageV2 . User
459-
460- const stream = await LLM . stream ( {
461- user,
462- sessionID,
463- model : resolved ,
464- agent,
465- permission : [ { permission : "question" , pattern : "*" , action : "allow" } ] ,
466- system : [ "You are a helpful assistant." ] ,
467- abort : new AbortController ( ) . signal ,
468- messages : [ { role : "user" , content : "Hello" } ] ,
469- tools : {
470- question : tool ( {
471- description : "Ask a question" ,
472- inputSchema : z . object ( { } ) ,
473- execute : async ( ) => ( { output : "" } ) ,
474- } ) ,
475- } ,
476- } )
477-
478- for await ( const _ of stream . fullStream ) {
479- }
480-
481- const capture = await request
482- const tools = capture . body . tools as Array < { function ?: { name ?: string } } > | undefined
483- expect ( tools ?. some ( ( item ) => item . function ?. name === "question" ) ) . toBe ( true )
484- } ,
485- } )
486- } )
487-
488399 test ( "sends responses API payload for OpenAI models" , async ( ) => {
489400 const server = state . server
490401 if ( ! server ) {
0 commit comments