Skip to content

feat(tool-calling): enhance campus assistant tools - #466

Open
haidiliuxin wants to merge 2 commits into
spring-ai-alibaba:mainfrom
haidiliuxin:feat/campus-assistant-advanced-tooling
Open

feat(tool-calling): enhance campus assistant tools#466
haidiliuxin wants to merge 2 commits into
spring-ai-alibaba:mainfrom
haidiliuxin:feat/campus-assistant-advanced-tooling

Conversation

@haidiliuxin

Copy link
Copy Markdown
Contributor

Summary

  • Expand CampusScheduleTools#createCampusSchedule to return a staged campus plan with preparation, main activity, and wrap-up steps.
  • Add estimateCampusActivityRisk as a second local tool for weather-aware outdoor activity decisions.
  • Add validation for blank text input and invalid duration.
  • Add more HTTP request scenarios and README guidance for the advanced campus assistant example.
  • Increase unit tests from 3 to 9 cases.

Why

The merged campus assistant example demonstrates basic multi-tool composition. This follow-up makes it a stronger tutorial by showing multiple local @Tool methods, tool parameter validation, weather-aware risk estimation, and local tests that do not require external API keys.

Tests

mvn -f spring-ai-alibaba-tool-calling-example/pom.xml test
Tests run: 9, Failures: 0, Errors: 0, Skipped: 0
BUILD SUCCESS

Related

@GTyingzi

Copy link
Copy Markdown
Collaborator

@codex

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 18ce483050

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +37 to +39
int preparationMinutes = Math.min(10, Math.max(5, durationMinutes / 6));
int wrapUpMinutes = Math.min(10, Math.max(5, durationMinutes / 8));
int mainActivityMinutes = Math.max(1, durationMinutes - preparationMinutes - wrapUpMinutes);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Keep schedule phases within requested duration

When the request is for a short session, such as 5 or 10 minutes, the fixed lower bounds allocate preparation=5 and wrapUp=5 while mainActivityMinutes is forced to at least 1, so the returned plan totals 11 minutes even though it still reports the original durationMinutes. Because this tool accepts any positive duration from the assistant, short campus plans become internally inconsistent; rebalance or cap the phases so their sum never exceeds the requested duration.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in dd92548. Short schedules now proportionally rebalance preparation and wrap-up within the available transition time while reserving at least one minute for the main activity, so all phases always sum to the requested duration. Added a 5-minute regression test. The module test suite now passes with 11 tests.

Comment on lines +73 to +75
if (durationMinutes > 120 && !"HIGH".equals(riskLevel)) {
riskLevel = "MEDIUM";
suggestion = "Long activity duration detected. Add breaks and hydration reminders.";

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Preserve weather-specific advice for long activities

When weatherSummary first triggers MEDIUM risk and the duration is over 120 minutes, this branch overwrites the weather-related suggestion with only the long-duration advice. For example, light rain plus 180 minutes returns no protection or indoor-backup guidance even though the weather caused the risk, so append the duration advice or only replace the LOW-risk suggestion.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in dd92548. Weather-specific guidance is now preserved and the long-duration reminder is appended when weather already caused MEDIUM risk. For LOW-risk weather, the long-duration advice remains the primary suggestion. Added a light rain plus 180-minute regression test. All 11 module tests pass.

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