blib/lib/Langertha/Role/ParallelToolUse.pm

filter: Statementstmt 100% 14 / 14 Branchbran 100% 10 / 10 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 2 / 2 Podpod n/a totaltotal 100% 26 / 26 CC 6 SCAR 16.7
CC
6
Cov
100%
__ANON__
6.0
BEGIN
1.0
CRAP 5.3
« blib/lib/Langertha/Input/Tools.pm ↑ Summary blib/lib/Langertha/Role/ResponseSize.pm »
1 package Langertha::Role::ParallelToolUse;
2 # ABSTRACT: Role for an engine that supports parallel tool calling control
3 183 our $VERSION = '0.503';
4 183 ▶use Moose::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 183 has parallel_tool_use => (
7 is => 'ro',
8 isa => 'Bool',
9 predicate => 'has_parallel_tool_use',
10 );
11  
12 3894 ▶around BUILDARGS => sub {
Subroutine __ANON__: called CC=6 SCAR=17.9
13 3894 my ( $orig, $class, @args ) = @_;
14 3894 my $params = $class->$orig(@args);
15  
16 3894 ▶ return $params if exists $params->{parallel_tool_use};
Branch: 1 branch
BranchTrueFalseTotal
if exists $params->{"parallel_tool_use"} 40 3854 3894
17  
18 3854 ▶ if ( exists $params->{parallel_tool_calls} ) {
Branch: 2 branches
BranchTrueFalseTotal
if (exists $params->{'parallel_tool_calls'}) { } 2 3852 3854
elsif (exists $params->{'disable_parallel_tool_use'}) { } 2 3850 3852
19 2 ▶ $params->{parallel_tool_use} = delete $params->{parallel_tool_calls} ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
delete $params->{'parallel_tool_calls'} ? : 1 1 2
20 }
21 elsif ( exists $params->{disable_parallel_tool_use} ) {
22 2 ▶ $params->{parallel_tool_use} = delete $params->{disable_parallel_tool_use} ? 0 : 1;
Branch: 1 branch
BranchTrueFalseTotal
delete $params->{'disable_parallel_tool_use'} ? : 1 1 2
23 }
24  
25 3854 return $params;
26 183 };
27  
28  
29  
30 183 1;
31  
32 __END__
33  
34 =pod
35  
36 =encoding UTF-8
37  
38 =head1 NAME
39  
40 Langertha::Role::ParallelToolUse - Role for an engine that supports parallel tool calling control
41  
42 =head1 VERSION
43  
44 version 0.503
45  
46 =head2 parallel_tool_use
47  
48 parallel_tool_use => 1 # allow multiple tool calls per assistant turn
49 parallel_tool_use => 0 # restrict to one tool call per turn
50  
51 Canonical boolean controlling whether the model may emit multiple tool calls
52 in a single assistant turn. Translated per-engine to the provider's native
53 parameter:
54  
55 =over 4
56  
57 =item * OpenAI-compatible engines send C<parallel_tool_calls> in the request.
58  
59 =item * Anthropic-compatible engines send C<< disable_parallel_tool_use => !parallel_tool_use >>
60 in the C<tool_choice> block.
61  
62 =back
63  
64 The field is sent only when the request carries tools and the engine
65 C<supports('parallel_tool_use')>. Engines whose wire has no such knob
66 (Gemini, Ollama native and C</v1>, Perplexity, MiniMax, Scaleway, Hetzner)
67 clear the capability; a value set there is not sent, with a warning (once per
68 engine instance for the attribute, every request for a per-request value). An explicit
69 C<parallel_tool_calls> request argument is passed through as given.
70  
71 For convenience the constructor also accepts the provider-native names as
72 aliases and normalizes them:
73  
74 # all three are equivalent
75 ->new( parallel_tool_use => 0 )
76 ->new( parallel_tool_calls => 0 ) # OpenAI name
77 ->new( disable_parallel_tool_use => 1 ) # Anthropic name (inverted)
78  
79 If unset the provider default is used (typically parallel enabled).
80  
81 =head1 SEE ALSO
82  
83 =over
84  
85 =item * L<Langertha::Role::Tools> - MCP tool calling interface
86  
87 =item * L<Langertha::ToolChoice> - Canonical tool_choice conversion
88  
89 =back
90  
91 =head1 SUPPORT
92  
93 =head2 Issues
94  
95 Please report bugs and feature requests on GitHub at
96 L<https://github.com/Getty/langertha/issues>.
97  
98 =head2 IRC
99  
100 Join C<#langertha> on C<irc.perl.org> or message Getty directly.
101  
102 =head1 CONTRIBUTING
103  
104 Contributions are welcome! Please fork the repository and submit a pull request.
105  
106 =head1 AUTHOR
107  
108 Torsten Raudssus <getty@cpan.org>
109  
110 =head1 COPYRIGHT AND LICENSE
111  
112 This software is copyright (c) 2026 by Torsten Raudssus L<https://raudssus.de/>.
113  
114 This is free software; you can redistribute it and/or modify it under
115 the same terms as the Perl 5 programming language system itself.
116  
117 =cut
« blib/lib/Langertha/Input/Tools.pm ↑ Summary blib/lib/Langertha/Role/ResponseSize.pm »