Skip to content

Improve openai_ask tool-use behavior#719

Open
iangmaia wants to merge 10 commits into
trunkfrom
iangmaia/openai-ask-tool-safety-fixes
Open

Improve openai_ask tool-use behavior#719
iangmaia wants to merge 10 commits into
trunkfrom
iangmaia/openai-ask-tool-safety-fixes

Conversation

@iangmaia
Copy link
Copy Markdown
Contributor

@iangmaia iangmaia commented May 12, 2026

What does it do?

Improves openai_ask follow-up behavior after the initial tool-use support:

  • Uses max_completion_tokens for Chat Completions requests.
  • Adds store: false to opt out of OpenAI request storage.
  • Validates function tool definitions before sending them to OpenAI.
  • Keeps malformed or unsupported tool calls from invoking local handlers.
  • Caps local tool execution without dropping the final allowed model response.
  • Avoids logging raw tool arguments, handler exception messages, or backtraces.

Checklist before requesting a review

  • Run bundle exec rubocop to test for code style violations and recommendations.
  • Add Unit Tests (aka specs/*_spec.rb) if applicable.
  • Run bundle exec rspec to run the whole test suite and ensure all your tests pass.
  • Make sure you added an entry in the CHANGELOG.md file to describe your changes under the appropriate existing ### subsection of the existing ## Trunk section.
  • If applicable, add an entry in the MIGRATION.md file to describe how the changes will affect the migration from the previous major version and what the clients will need to change and consider.

Copilot AI review requested due to automatic review settings May 12, 2026 12:54
@iangmaia iangmaia self-assigned this May 12, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR tightens and hardens openai_ask’s Chat Completions + tool-use loop behavior, with a focus on safer logging, stricter tool validation, and clearer iteration limiting semantics.

Changes:

  • Switch Chat Completions requests to max_completion_tokens and opt out of request storage via store: false.
  • Add validation for tool definitions and returned tool-call payloads, preventing malformed/unsupported tool calls from invoking local handlers.
  • Adjust the tool-use loop to cap local tool execution rounds while still allowing one final model turn to produce an answer; reduce sensitive data exposure in logs.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
lib/fastlane/plugin/wpmreleasetoolkit/actions/common/openai_ask_action.rb Updates request parameters, adds tool/max-iteration validation, hardens tool-call execution and logging, and refines loop termination semantics.
spec/openai_ask_action_spec.rb Adds/updates specs for new request fields, iteration cap behavior, tool validation, and sensitive logging guarantees.
CHANGELOG.md Documents the openai_ask tool-use behavior improvements under Trunk bug fixes.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@iangmaia iangmaia requested a review from Copilot May 12, 2026 13:25
@iangmaia iangmaia requested review from jaclync, mokagio and twstokes May 12, 2026 13:28
@iangmaia iangmaia added bug Something isn't working enhancement New feature or request labels May 12, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

Comment thread lib/fastlane/plugin/wpmreleasetoolkit/actions/common/openai_ask_action.rb Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants