@@ -398,6 +398,100 @@ describe("session.llm.stream", () => {
398398 } )
399399 } )
400400
401+ test ( "inherited object property names report through the hidden fallback" , async ( ) => {
402+ const providerID = "alibaba"
403+ const { model } = await loadFixture ( providerID , "qwen-plus" )
404+ const request = waitRequest (
405+ "/chat/completions" ,
406+ createEventResponse (
407+ [
408+ {
409+ id : "chatcmpl-inherited" ,
410+ object : "chat.completion.chunk" ,
411+ choices : [
412+ {
413+ delta : {
414+ role : "assistant" ,
415+ tool_calls : [
416+ {
417+ index : 0 ,
418+ id : "call-inherited" ,
419+ type : "function" ,
420+ function : { name : "constructor" , arguments : "{}" } ,
421+ } ,
422+ ] ,
423+ } ,
424+ } ,
425+ ] ,
426+ } ,
427+ {
428+ id : "chatcmpl-inherited" ,
429+ object : "chat.completion.chunk" ,
430+ choices : [ { delta : { } , finish_reason : "tool_calls" } ] ,
431+ } ,
432+ ] ,
433+ true ,
434+ ) ,
435+ )
436+ await using tmp = await tmpdir ( {
437+ config : {
438+ enabled_providers : [ providerID ] ,
439+ provider : { [ providerID ] : { options : { apiKey : "test-key" , baseURL : `${ state . server ! . url . origin } /v1` } } } ,
440+ } ,
441+ } )
442+ await Instance . provide ( {
443+ directory : tmp . path ,
444+ fn : async ( ) => {
445+ const resolved = await Provider . getModel ( ProviderID . make ( providerID ) , ModelID . make ( model . id ) )
446+ const sessionID = SessionID . make ( "session-inherited-tool" )
447+ const agent = {
448+ name : "custom-builder" ,
449+ mode : "primary" ,
450+ options : { } ,
451+ permission : PermissionNext . fromConfig ( { "*" : "allow" } ) ,
452+ } satisfies Agent . Info
453+ const stream = await LLM . stream ( {
454+ user : {
455+ id : MessageID . make ( "msg_inherited-tool" ) ,
456+ sessionID,
457+ role : "user" ,
458+ time : { created : Date . now ( ) } ,
459+ agent : agent . name ,
460+ model : { providerID : ProviderID . make ( providerID ) , modelID : resolved . id } ,
461+ } ,
462+ sessionID,
463+ model : resolved ,
464+ agent,
465+ system : [ ] ,
466+ abort : new AbortController ( ) . signal ,
467+ messages : [ { role : "user" , content : "Call the requested tool" } ] ,
468+ tools : {
469+ read : tool ( { inputSchema : jsonSchema ( { type : "object" , properties : { } } ) , execute : async ( ) => "read" } ) ,
470+ invalid : tool ( {
471+ inputSchema : jsonSchema < { tool : string ; error : string } > ( {
472+ type : "object" ,
473+ properties : { tool : { type : "string" } , error : { type : "string" } } ,
474+ required : [ "tool" , "error" ] ,
475+ } ) ,
476+ execute : async ( input ) => input ,
477+ } ) ,
478+ } ,
479+ } )
480+ const events = [ ]
481+ for await ( const event of stream . fullStream ) events . push ( event )
482+ expect ( events . find ( ( event ) => event . type === "tool-result" ) ) . toMatchObject ( {
483+ toolName : "invalid" ,
484+ output : { tool : "constructor" , error : expect . stringContaining ( "constructor" ) } ,
485+ } )
486+ expect ( events . some ( ( event ) => event . type === "tool-error" || event . type === "error" ) ) . toBe ( false )
487+ const capture = await request
488+ expect ( ( capture . body . tools as { function : { name : string } } [ ] ) . map ( ( item ) => item . function . name ) ) . toEqual ( [
489+ "read" ,
490+ ] )
491+ } ,
492+ } )
493+ } )
494+
401495 test . skip ( "sends temperature, tokens, and reasoning options for openai-compatible models" , async ( ) => {
402496 const server = state . server
403497 if ( ! server ) {
0 commit comments