@@ -222,9 +222,9 @@ struct CodeGraphLLMResponse {
222222
223223#[ derive( Debug , Deserialize ) ]
224224struct CodeGraphToolCall {
225- #[ serde( alias = "name" ) ]
225+ #[ serde( alias = "name" , alias = "function" , alias = "tool" ) ]
226226 tool_name : String ,
227- #[ serde( alias = "arguments" ) ]
227+ #[ serde( alias = "arguments" , alias = "args" ) ]
228228 parameters : serde_json:: Value ,
229229}
230230
@@ -637,6 +637,74 @@ mod tests {
637637 assert_eq ! ( tool_calls[ 0 ] . function. arguments, "{\" min_degree\" :4}" ) ;
638638 }
639639
640+ #[ test]
641+ fn test_tool_calls_accepts_args_field ( ) {
642+ let response = CodeGraphChatResponse {
643+ content : r#"{
644+ "reasoning": "Trace chain",
645+ "tool_call": {
646+ "tool_name": "trace_call_chain",
647+ "args": {
648+ "from_node": "GraphToolExecutor",
649+ "max_depth": 4
650+ }
651+ },
652+ "is_final": false
653+ }"#
654+ . to_string ( ) ,
655+ _total_tokens : 0 ,
656+ } ;
657+
658+ let tool_calls = response. tool_calls ( ) . expect ( "tool call not parsed" ) ;
659+ assert_eq ! ( tool_calls[ 0 ] . function. name, "trace_call_chain" ) ;
660+ assert_eq ! ( tool_calls[ 0 ] . function. arguments, "{\" from_node\" :\" GraphToolExecutor\" ,\" max_depth\" :4}" ) ;
661+ }
662+
663+ #[ test]
664+ fn test_tool_calls_accepts_function_field ( ) {
665+ let response = CodeGraphChatResponse {
666+ content : r#"{
667+ "reasoning": "Find hubs",
668+ "tool_call": {
669+ "function": "get_hub_nodes",
670+ "arguments": {
671+ "min_degree": 6
672+ }
673+ },
674+ "is_final": false
675+ }"#
676+ . to_string ( ) ,
677+ _total_tokens : 0 ,
678+ } ;
679+
680+ let tool_calls = response. tool_calls ( ) . expect ( "tool call not parsed" ) ;
681+ assert_eq ! ( tool_calls[ 0 ] . function. name, "get_hub_nodes" ) ;
682+ assert_eq ! ( tool_calls[ 0 ] . function. arguments, "{\" min_degree\" :6}" ) ;
683+ }
684+
685+ #[ test]
686+ fn test_tool_calls_accepts_tool_field ( ) {
687+ let response = CodeGraphChatResponse {
688+ content : r#"{
689+ "reasoning": "Dependencies",
690+ "tool_call": {
691+ "tool": "get_transitive_dependencies",
692+ "parameters": {
693+ "node_id": "AgenticOrchestrator",
694+ "edge_type": "Imports",
695+ "depth": 2
696+ }
697+ },
698+ "is_final": false
699+ }"#
700+ . to_string ( ) ,
701+ _total_tokens : 0 ,
702+ } ;
703+
704+ let tool_calls = response. tool_calls ( ) . expect ( "tool call not parsed" ) ;
705+ assert_eq ! ( tool_calls[ 0 ] . function. name, "get_transitive_dependencies" ) ;
706+ }
707+
640708 // Integration test for ChatProvider
641709 struct MockCodeGraphLLM ;
642710
0 commit comments