Skip to content

chore: [OpenAI] Improve e2e test stability#936

Open
Jonas-Isr wants to merge 3 commits into
mainfrom
e2e-improvement
Open

chore: [OpenAI] Improve e2e test stability#936
Jonas-Isr wants to merge 3 commits into
mainfrom
e2e-improvement

Conversation

@Jonas-Isr

@Jonas-Isr Jonas-Isr commented Jul 8, 2026

Copy link
Copy Markdown
Member

Context

Changed the WeatherMethod example used for tool calls:

  • removed the Request inner class,
  • instead use two primitive arguments.

Also changed all uses of the test class accordingly

Please also consider the docs PR:

@Jonas-Isr Jonas-Isr changed the title chore: [SpringAI] Improve e2e test stability chore: [OpenAI] Improve e2e test stability Jul 9, 2026

@CharlesDuboisSAP CharlesDuboisSAP left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Should we also change the unit tests and documentation as well?

Comment on lines +123 to -127
record WeatherRequest(String location, WeatherMethod.Unit unit) {}

// 1. Define the function
final List<OpenAiTool> tools =
List.of(
OpenAiTool.forFunction(WeatherMethod::getCurrentWeather)
.withArgument(WeatherMethod.Request.class)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why did you move the Request from the WeatherMethod.Request to the service class, it's duplication.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

You need this workaround since forFunction() in OpenAiTool needs a function with only a single argument as input. To then still use the WeatherMethod.getCurrentWeather() method you need the local WeatherRequest method. But this ensures that the WeatherMethod.getCurrentWeather() is only called with primitive arguments.

@CharlesDuboisSAP CharlesDuboisSAP Jul 13, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

That doesn't answer the question, I didn't talk about getCurrentWeather ?

assertThat(toolCall2.name()).isEqualTo("getCurrentWeather");
assertThat(toolCall1.arguments())
.matches("\\{\"arg0\": \\{\"location\": \"[^\"]*Potsdam[^\"]*\", \"unit\": \"C\"}}");
.matches("\\{\"arg0\": \"[^\"]*Potsdam[^\"]*\", \"arg1\": \"C\"}");

@CharlesDuboisSAP CharlesDuboisSAP Jul 13, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can't arguments be properly parsed by spring to as location and unit? arg0 might be worse for reliability

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

As far as I know this is the (only) way Spring does it.

@CharlesDuboisSAP CharlesDuboisSAP Jul 13, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I had managed to do it with Copilot a couple weeks ago but reverted it, I think it's possible

@Jonas-Isr

Copy link
Copy Markdown
Member Author

Should we also change the unit tests and documentation as well?

Yes, changed the unit tests as well. For the documentation see the PR linked in the description above.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants