Skip to content

Connect the chatbot to the conditions check with tool calling - #35

Merged
xquantize merged 15 commits into
mainfrom
agent/chat-conditions-tools-1583
Oct 27, 2026
Merged

xquantize merged 15 commits into
mainfrom
agent/chat-conditions-tools-1583

Conversation

@xquantize

@xquantize xquantize commented Oct 19, 2026 •

Copy link
Copy Markdown
Owner

Part of Stage 3 (#21). Targets feature/conditions.

The chatbot can answer "is this spot worth surfing this morning?" and "where should I go?" from the conditions engine. The model only chooses a tool and phrases the JSON. The window, the score and the ranking are computed in code.

  • complete_message returns the full assistant message so tool calls are visible. chat() still returns text.
  • list_spots, check_spot and rank_spots live in src/swellsense/chat/tools.py. when resolves to a Pacific/Auckland window: now (next 3 hours), this morning 05:00-11:00, this afternoon 12:00-18:00, this evening 17:00-21:00, tomorrow morning, tomorrow afternoon, the next 12 hours, and the next 24 hours.
  • If that part of today has already passed, the tool checks the rest of today (through 21:00). From 17:00 it checks tomorrow morning instead. The result says so in ordinary speech ("The morning's gone."), and the reply must not repeat tool or parameter names.
  • A best score of 0 is reported as "no surfable hours", with no best time. An unknown spot id returns the valid ids.
  • Conditions answers use only the reasons the tool returned. The model does not add its own account of how wind, tide or period shape a wave. A conflicting or uncertain tide is described as left out of the rating. Replies stay under about 100 words, with no filler sign-off.
  • The chat loop runs at most five tool rounds. Emoji are stripped from the final answer. A short Open-Meteo and LINZ credit is added only when a tool actually returned forecast or tide data.

Tests cover a winter clock, the 5 April 2026 fallback, the 27 September 2026 forward change, a passed morning answered as the rest of today, an evening request answered as tomorrow morning, dispatcher routing, a flat score, and a fake model for the fallback wording, the credit, and an emoji in the reply. No new dependencies.

Open in Web Open in Cursor 

cursoragent and others added 13 commits October 14, 2026 21:11
Spot directions are stored as degrees so a later conditions check can
calculate offshore wind and swell fit. The seven profiles are unverified
and their notes are paraphrased from the cited pages.

Co-authored-by: Zane <xquantize@users.noreply.github.com>
Add Spot model and baseline Bay of Plenty spot profiles
Cache the yearly standard-port CSV, read its times as Pacific/Auckland
civil time, and interpolate height and phase between highs and lows.

Co-authored-by: Zane <xquantize@users.noreply.github.com>
Add LINZ tide predictions for Tauranga with tide state at any time
Combine the marine and wind APIs into Pacific/Auckland hours, cache the
pair for one hour, and print them from swellsense forecast.

Co-authored-by: Zane <xquantize@users.noreply.github.com>
Add Open-Meteo forecast for a spot: swell, wind waves and wind
Pure judgements compare a spot profile with one set of numbers. Thresholds
live in one module so they can be tuned without rewriting the rules.

Co-authored-by: Zane <xquantize@users.noreply.github.com>
Add conditions classifiers: wind, swell and tide relative to a spot
Score each hour in code from the wind, swell and tide classifiers, then
report the best hour and rank spots. The check command prints that report
with the forecast and tide attributions.

Co-authored-by: Zane <xquantize@users.noreply.github.com>
Add conditions rating, report and best-time/best-spot answers
Equal best-hour scores share a rank. Within a tie, shore access and an
easier skill come first. --skill lists spots above that level instead
of dropping them.

Co-authored-by: Zane <xquantize@users.noreply.github.com>
Make spot ranking honest about ties, skill and access
The model chooses list_spots, check_spot or rank_spots and phrases the
JSON. Time windows, scores and rankings stay in code. A window that has
already passed, or a best score of 0, is reported as such.

Co-authored-by: Zane <xquantize@users.noreply.github.com>
@xquantize

Copy link
Copy Markdown
Owner Author

@cursor three fixes from a real test: (1) never show tool or parameter names like "this_morning" to the user; speak naturally ("the morning's gone"). (2) When a requested window has passed, automatically check the next sensible window (the rest of today, or tomorrow morning if it's evening) and answer with that, saying the original window had passed. (3) Only add the Open-Meteo / LINZ credit when forecast or tide data was actually used in the answer. Add tests for (2) and (3) with a fake model.

@cursor

cursor Bot commented Oct 19, 2026 •

Copy link
Copy Markdown

A passed window is now answered from the next real one, in ordinary words, and the data credit only appears when a forecast or tide was actually used.

  • Before 17:00, a request for a part of the day that has finished checks the rest of today, through 21:00. From 17:00 it checks tomorrow morning. The result says "The morning's gone." and does not repeat names like this_morning.
  • The Open-Meteo and LINZ line is added by the chat loop only after a tool returns forecast or tide data. A general answer loses that line even if the model writes it.

bash scripts/check.sh passed, 296 tests. Fake-model turns cover a passed morning, an evening request, a board question with the credit stripped, and a forecast answer with the credit added.

View PR

Open in Web Open in Cursor 

…t was used

A request for a part of the day that has finished now checks the rest of
today, or tomorrow morning once it is evening, and says so without tool
names. The Open-Meteo and LINZ line is added only after a forecast or tide
was actually returned.

Co-authored-by: Zane <xquantize@users.noreply.github.com>
@xquantize

Copy link
Copy Markdown
Owner Author

@cursor two fixes from a real test, where the model invented explanations: (1) Tighten the system prompt: explain conditions only with the reasons returned by the tools; never add your own explanations of how wind, tide or period affect waves; if the tide call is conflicting or uncertain, say it was left out of the rating rather than describing its effect; keep answers under about 100 words with no filler sign-offs. (2) In the chat loop, strip emojis from the model's final answer in code, like the data credit. Add a test with a fake model reply containing an emoji.

@cursor

cursor Bot commented Oct 19, 2026 •

Copy link
Copy Markdown

Conditions answers now have to stay with the reasons the tools already returned, and emoji are removed from the final reply in code.

  • The prompt forbids inventing how wind, tide, or period shape a wave. If the tide call is conflicting or uncertain, the reply says it was left out of the rating. Answers stay under about 100 words, with no sign-off.
  • The chat loop strips emoji before it decides on the data credit. A fake reply of "It's a 6 🌊, 1.2 m at 7 s 👍" comes back as "It's a 6, 1.2 m at 7 s", with the Open-Meteo and LINZ line still added because a forecast was used.

bash scripts/check.sh passed, 297 tests.

View PR

Open in Web Open in Cursor 

The prompt now forbids invented wind, tide and period explanations, says an
uncertain tide was left out of the rating, and keeps replies short. Emoji
are removed from the final answer in code.

Co-authored-by: Zane <xquantize@users.noreply.github.com>
@xquantize
xquantize changed the base branch from feature/conditions to main October 27, 2026 20:56
@xquantize
xquantize marked this pull request as ready for review October 27, 2026 20:56
@xquantize
xquantize merged commit b1f8b91 into main Oct 27, 2026
1 check passed
@xquantize
xquantize deleted the agent/chat-conditions-tools-1583 branch October 27, 2026 20:57
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