Skip to content

Commit fd139b1

Browse files
committed
Validate tool iterations only with tools
1 parent c3bab1e commit fd139b1

2 files changed

Lines changed: 19 additions & 1 deletion

File tree

lib/fastlane/plugin/wpmreleasetoolkit/actions/common/openai_ask_action.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ def self.run(params)
3333
# callers can register handlers with either string or symbol keys without surprises.
3434
tool_handlers = (params[:tool_handlers] || {}).transform_keys(&:to_s)
3535
max_tool_iterations = params[:max_tool_iterations] || DEFAULT_MAX_TOOL_ITERATIONS
36-
validate_max_tool_iterations!(max_tool_iterations)
3736

3837
headers = {
3938
'Content-Type': 'application/json',
@@ -48,6 +47,7 @@ def self.run(params)
4847
end
4948

5049
validate_tools_array!(tools)
50+
validate_max_tool_iterations!(max_tool_iterations)
5151
validate_tools!(tools)
5252
run_with_tools(
5353
prompt: prompt,

spec/openai_ask_action_spec.rb

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,24 @@ def run_test(prompt_param:, question_param:, expected_prompt:, expected_response
134134
expect(JSON.parse(expected_req_body)['model']).to eq('gpt-4o-mini')
135135
end
136136

137+
it 'ignores max_tool_iterations on the single-shot path' do
138+
expected_req_body = described_class.request_body(prompt: 'sys', question: 'q')
139+
140+
stub = stub_request(:post, endpoint)
141+
.with(body: expected_req_body)
142+
.to_return(status: 200, body: stubbed_response('Hi.'))
143+
144+
result = described_class.run(
145+
api_token: fake_token,
146+
prompt: 'sys',
147+
question: 'q',
148+
max_tool_iterations: 'not used without tools'
149+
)
150+
151+
expect(result).to eq('Hi.')
152+
expect(stub).to have_been_requested
153+
end
154+
137155
it 'uses max_completion_tokens instead of deprecated max_tokens' do
138156
body = JSON.parse(described_class.request_body(prompt: 'sys', question: 'q'))
139157

0 commit comments

Comments
 (0)