Files
weatherreporter/docs/integrations/promptkit.md

6.7 KiB

Promptkit Integration

Weatherreporter uses Promptkit for all generated-text reports. The four logical prompts are weather.daily_generated_text, weather.today_generated_text, weather.tomorrow_generated_text, and weather.hourly_generated_text, each at version 2.1.0. Their prompt assets, generated-text JSON Schemas, and Weatherreporter profile catalog are embedded by internal/promptassets.

Logical Profile Catalog

Prompt definitions select a stable Weatherreporter profile ID. Each embedded definition contains only its ID and one Promptkit base-profile reference; the effective execution settings resolve from Promptkit's maintained catalog:

Profile ID Model Reasoning effort Timeout Service tier Default reports
weather-light deepseek/deepseek-v4-flash Provider default 180 seconds flex Hourly
weather-balanced ~google/gemini-flash-latest high 240 seconds flex Daily, Today, Tomorrow
weather-deep ~anthropic/claude-sonnet-latest high 240 seconds flex None

The ~ prefix is part of each OpenRouter rolling-alias model ID. The embedded profiles intentionally omit endpoints, credentials, and execution settings; Promptkit owns inherited resolution and its provider-native defaults. Promptkit's built-in rakestrawhome-gemma-4-31b is also available for ordinary and comparison selection and reports the rakestrawhome backend without Weatherreporter-specific configuration.

Selection And Active Execution

Before weather collection, Weatherreporter validates the report's exact generated-text report/schema/template catalog binding, prompt version and hash, output contract, and selected profile. Active profiles must resolve a nonblank model; an endpoint-only profile may intentionally have no backend identity. A nonblank promptkit.profile selects one profile ID for every report in the command; otherwise the prompt's declared default selects it. Promptkit resolves the selected definition in this order:

  1. explicit in-memory profiles used by an embedding consumer or test;
  2. the configured profile_file or profile_dir;
  3. Weatherreporter's embedded fallback profiles; and
  4. Promptkit's built-in catalog.

A source falls through only when the selected ID is absent. Promptkit resolves a derived profile's base with the same source precedence, so a configured base can shadow a built-in base. A missing, cyclic, malformed, or incomplete selected inheritance chain is an error and does not fall back.

Profiles that require a direct API key are unsupported. Optional environment credential sources are Promptkit runtime concerns and are not checked by Weatherreporter during profile inspection. Active results retain the selected logical profile ID and resolved backend and model. Ordinary errors, summaries, logs, and outputs exclude endpoints, credentials, rendered messages, schemas, request bodies, response bodies, and complete parameter maps.

Promptkit receives the YAML data package as an inline input and returns structured JSON that Weatherreporter validates before rendering its own Markdown template. Before accepting that JSON, Weatherreporter requires exactly one preparation callback and reconciles its prompt/profile/backend/model and rendered/input hashes with the inspected identity and completed result. The callback output contract and completed validation must use the report's expected JSON Schema mode and path. The package contains only reviewed prompt-facing warning summaries, never source transport or provenance details. Safe active provenance remains in memory. Content-rich diagnostics are opt-in through --llm-debug-dir; see operations for retention and permissions. Ordinary generation errors disclose only the safe Weatherreporter category and optional HTTP status; provider code, type, and message are written only to the explicit secure failure-debug artifact.

Each embedded prompt permits one Promptkit-owned corrective generation after an eligible failed or explicitly empty result. This is not an application retry: Weatherreporter performs no provider retry, profile fallback, or request-level output-contract override. Promptkit reports cumulative usage and the actual number of corrective calls; repair exhaustion remains a completed validation failure.

When capture is enabled, its preparation artifact projects a provider endpoint to its scheme and host and retains only reviewed execution settings. Provider extras and URL user information, paths, queries, and fragments are omitted. Capture storage remains confined to the operator-selected debug root; an unsafe filesystem path causes the requested execution to fail. Host availability and operator handling are documented in the operations guide.

Comparison Execution

For compare, Weatherreporter validates the report's generated-text catalog binding, one exact prompt, and every explicitly selected profile before weather collection. It prepares one deterministic YAML data package, retains immutable copies of the report inputs, and executes every profile against the same exact data-package bytes. Each profile remains an independent Promptkit execution: one provider, provenance, or validation failure does not stop its peers, while caller cancellation applies to every in-flight execution.

Weatherreporter starts selected profile executions concurrently and does not add an application-level concurrency limit. Promptkit owns backend capacity and any profile or backend concurrency policy. A shared Weatherreporter executor must safely accept those concurrent Execute calls. The durable comparison output and its compatibility rules are defined by the comparison bundle contract; the user-facing command contract is in the CLI reference.

The generated-text schemas require summary, forecast_discussion, and precipitation_timing, and reject additional properties. Promptkit results are accepted only when their raw JSON is at most 64 KiB; the adapter drops larger results before copying them into Weatherreporter's execution values or debug artifacts. The validator also limits total generated prose to 20,000 characters, with 4,000-character summary and timing fields, a 12,000-character Hourly discussion, and at most 12 day-style paragraphs of 4,000 characters each. Prompts return an empty string for precipitation_timing when the deterministic package contains no precipitation windows.

Prompt/profile configuration and the maintained local override example are owned by the configuration reference. Adapter construction and mapping are documented in the Promptkit adapter internals.