Script agent calendar and prompts - #19
Merged
Merged
Conversation
Add a "Create calendar event" blueprint, and fix the two things that kept
it from working.
The entity selector's pre-`filter` shorthand (`entity: {domain: calendar}`)
was ignored, so the field was offered every exposed entity instead of just
the calendars.
The model was never told today's date, so a date or date & time field came
back with "Saturday" rather than a date. The date goes in the user prompt,
which is evaluated per utterance, rather than the system prompt, which is
the cached prefix and would be rebuilt every midnight. Recognized sentences
are now cached against the rendered prompt so a date-carrying prompt cannot
replay yesterday's answer.
Both prompts are editable on the Settings page and saved in the overrides
file. The system prompt is also reworded to ask for the no-match reply in
the requested language instead of bundling that into one sentence with what
to say; this rebuilds the prompt cache once on upgrade.
Also: a duration reaches a script as an "HH:MM:SS" string from the model but
as a mapping from Home Assistant's UI, and Home Assistant reads a two-part
"01:00" as one minute, so the field description now asks for all three parts
and the blueprint handles both shapes. config.yaml and const.py disagreed
about the version, which was failing test_release; both are now 1.9.0.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
mypy skips the body of an unannotated function entirely, so most of web_server.py was never being checked. That only showed up as three "annotation-unchecked" notes, in the functions that happened to declare an annotated local. Annotate all 32 unannotated functions instead: the Flask views return ResponseReturnValue, and the two websocket helpers take the aiohttp type that production passes them. Checking those bodies turned up nothing, which is the point -- there was no way to know before. disallow_untyped_defs makes a new unannotated function an error rather than a note that is easy to scroll past. The WSGI middleware's types exist only in typeshed, so its annotations are quoted: Python evaluates annotations on a def at definition time, and importing web_server raised NameError without the quotes. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
const.py still said 1.9.0 while config.yaml and the changelog said 1.1.0, which was failing test_release. The version is written in three places and only two of them were checked. The changelog's newest heading is the third, and it is the copy that gets left behind when the number changes -- which is exactly what happened here. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add calendar blueprint and make it work correctly