@@ -5,8 +5,8 @@ import ai.grazie.code.agents.core.tools.Tool
5
5
import ai.grazie.code.agents.core.tools.ToolDescriptor
6
6
import ai.grazie.code.agents.core.tools.ToolRegistry
7
7
import ai.grazie.code.agents.core.tools.ToolResult
8
- import ai.grazie.code.agents.core .utils.ActiveProperty
9
- import ai.grazie.code.agents.core .utils.RWLock
8
+ import ai.grazie.code.agents.local .utils.ActiveProperty
9
+ import ai.grazie.code.agents.local .utils.RWLock
10
10
import ai.grazie.code.agents.local.InternalAgentsApi
11
11
import ai.grazie.code.agents.local.agent.LocalAgentConfig
12
12
import ai.grazie.code.agents.local.agent.LocalAgentStateManager
@@ -579,7 +579,6 @@ class LocalAgentLLMWriteSession internal constructor(
579
579
* @param args the arguments required to execute the tool.
580
580
* @return a `SafeTool.Result` containing the tool's execution result of type `TResult`.
581
581
*/
582
- @Suppress(" UNCHECKED_CAST" )
583
582
suspend inline fun <reified TArgs : Tool.Args , reified TResult : ToolResult > callTool (
584
583
tool : Tool <TArgs , TResult >,
585
584
args : TArgs
@@ -594,7 +593,6 @@ class LocalAgentLLMWriteSession internal constructor(
594
593
* @param args The arguments required to execute the tool, which must be a subtype of [Tool.Args].
595
594
* @return A [SafeTool.Result] containing the result of the tool execution, which is a subtype of [ToolResult].
596
595
*/
597
- @Suppress(" UNCHECKED_CAST" )
598
596
suspend inline fun <reified TArgs : Tool.Args > callTool (
599
597
toolName : String ,
600
598
args : TArgs
@@ -609,7 +607,6 @@ class LocalAgentLLMWriteSession internal constructor(
609
607
* @param args The arguments to be passed to the tool, conforming to the [Tool.Args] type.
610
608
* @return The raw result of the tool's execution as a String.
611
609
*/
612
- @Suppress(" UNCHECKED_CAST" )
613
610
suspend inline fun <reified TArgs : Tool.Args > callToolRaw (
614
611
toolName : String ,
615
612
args : TArgs
@@ -626,7 +623,6 @@ class LocalAgentLLMWriteSession internal constructor(
626
623
* @param args The arguments to be passed to the tool for its execution.
627
624
* @return A result wrapper containing either the successful result of the tool's execution or an error.
628
625
*/
629
- @Suppress(" UNCHECKED_CAST" )
630
626
suspend inline fun <reified TArgs : Tool.Args , reified TResult : ToolResult > callTool (
631
627
toolClass : KClass <out Tool <TArgs , TResult >>,
632
628
args : TArgs
@@ -644,8 +640,8 @@ class LocalAgentLLMWriteSession internal constructor(
644
640
* @return A SafeTool instance wrapping the found tool and its environment.
645
641
* @throws IllegalArgumentException if the specified tool is not found in the tool registry.
646
642
*/
647
- @Suppress(" UNCHECKED_CAST" )
648
643
inline fun <reified TArgs : Tool.Args , reified TResult : ToolResult > findTool (toolClass : KClass <out Tool <TArgs , TResult >>): SafeTool <TArgs , TResult > {
644
+ @Suppress(" UNCHECKED_CAST" )
649
645
val tool = (toolRegistry.stages.first().tools.find(toolClass::isInstance) as ? Tool <TArgs , TResult >
650
646
? : throw IllegalArgumentException (" Tool with type ${toolClass.simpleName} is not defined" ))
651
647
@@ -658,7 +654,6 @@ class LocalAgentLLMWriteSession internal constructor(
658
654
* @param args The input arguments required for the tool execution, represented as an instance of `Tool.Args`.
659
655
* @return A `SafeTool.Result` containing the outcome of the tool's execution, which may be of any type that extends `ToolResult`.
660
656
*/
661
- @Suppress(" UNCHECKED_CAST" )
662
657
suspend inline fun <reified ToolT : Tool <* , * >> callTool (
663
658
args : Tool .Args
664
659
): SafeTool .Result <out ToolResult > {
@@ -724,7 +719,6 @@ class LocalAgentLLMWriteSession internal constructor(
724
719
* @param concurrency The maximum number of concurrent executions. Default value is 16.
725
720
* @return A flow emitting the results of the tool executions wrapped in a SafeTool.Result object.
726
721
*/
727
- @Suppress(" UNCHECKED_CAST" )
728
722
inline fun <reified TArgs : Tool.Args , reified TResult : ToolResult > Flow<TArgs>.toParallelToolCalls (
729
723
tool : Tool <TArgs , TResult >,
730
724
concurrency : Int = 16
@@ -744,7 +738,6 @@ class LocalAgentLLMWriteSession internal constructor(
744
738
* @param concurrency The maximum number of parallel executions allowed. Default is 16.
745
739
* @return A Flow containing the results of the tool executions, wrapped in `SafeTool.Result`.
746
740
*/
747
- @Suppress(" UNCHECKED_CAST" )
748
741
inline fun <reified TArgs : Tool.Args , reified TResult : ToolResult > Flow<TArgs>.toParallelToolCalls (
749
742
toolClass : KClass <out Tool <TArgs , TResult >>,
750
743
concurrency : Int = 16
@@ -762,7 +755,6 @@ class LocalAgentLLMWriteSession internal constructor(
762
755
* @param concurrency the number of concurrent tool calls to be executed. Defaults to 16.
763
756
* @return a flow of raw string results from the parallel tool calls.
764
757
*/
765
- @Suppress(" UNCHECKED_CAST" )
766
758
inline fun <reified TArgs : Tool.Args , reified TResult : ToolResult > Flow<TArgs>.toParallelToolCallsRaw (
767
759
toolClass : KClass <out Tool <TArgs , TResult >>,
768
760
concurrency : Int = 16
@@ -782,8 +774,8 @@ class LocalAgentLLMWriteSession internal constructor(
782
774
* @return the tool that matches the specified name and types
783
775
* @throws IllegalArgumentException if the tool is not defined or the types are incompatible
784
776
*/
785
- @Suppress(" UNCHECKED_CAST" )
786
777
inline fun <reified TArgs : Tool.Args , reified TResult : ToolResult > findToolByNameAndArgs (toolName : String ): Tool <TArgs , TResult > =
778
+ @Suppress(" UNCHECKED_CAST" )
787
779
(toolRegistry.getTool(toolName) as ? Tool <TArgs , TResult >
788
780
? : throw IllegalArgumentException (" Tool \" $toolName \" is not defined or has incompatible arguments" ))
789
781
@@ -795,8 +787,8 @@ class LocalAgentLLMWriteSession internal constructor(
795
787
* @throws IllegalArgumentException If the tool with the specified name is not defined or its arguments
796
788
* are incompatible with the expected type.
797
789
*/
798
- @Suppress(" UNCHECKED_CAST" )
799
790
inline fun <reified TArgs : Tool.Args > findToolByName (toolName : String ): SafeTool <TArgs , * > {
791
+ @Suppress(" UNCHECKED_CAST" )
800
792
val tool = (toolRegistry.getTool(toolName) as ? Tool <TArgs , * >
801
793
? : throw IllegalArgumentException (" Tool \" $toolName \" is not defined or has incompatible arguments" ))
802
794
0 commit comments