feat(backend): weather.gov pilot via backend tool registry#223
feat(backend): weather.gov pilot via backend tool registry#223
Conversation
📝 WalkthroughWalkthroughIntegrated a backend-owned, read-only Weather.gov forecast tool into chat orchestration: planner-level weather types, single-tool policy preferring weather over web search, tool registry/adapters with fail-open execution and telemetry, server/handler wiring, prompts/schema updates, and comprehensive tests and docs. Changes
Sequence Diagram(s)sequenceDiagram
participant Client as Client
participant Handler as Chat Handler
participant Orch as Chat Orchestrator
participant Policy as Tool Policy
participant Registry as Tool Registry
participant Adapter as Weather Adapter
participant NWS as weather.gov API
Client->>Handler: POST /chat (generation plan)
Handler->>Orch: invoke orchestrator with plan
Orch->>Policy: applySingleToolPolicy(generation)
Policy-->>Orch: (maybe-modified) generation + logEvent?
Orch->>Registry: resolveToolSelection(generation, weatherForecastTool?)
Registry-->>Orch: BackendToolSelection (toolIntent, toolRequest, toolExecution?)
alt weather eligible & tool available
Orch->>Registry: executeSelectedTool(selection)
Registry->>Adapter: executeWeatherForecastTool(request)
Adapter->>NWS: GET /points or /gridpoints/.../forecast
NWS-->>Adapter: Forecast JSON
Adapter-->>Registry: toolResultMessage + toolExecutionContext (executed)
Registry-->>Orch: execution result
else unavailable or failed
Registry-->>Orch: toolExecutionContext (skipped/failed), no toolResultMessage
end
Orch->>Orch: inject toolResultMessage as system message (if present)
Orch-->>Handler: planner/generation payload (with tool metadata)
Handler-->>Client: response + metadata
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
- add strict weather location bounds validation in planner normalization - prefer daily forecast endpoint before hourly fallback for weather.gov - omit planner weather payload when tool result is absent - move weather tool instantiation into service initialization - remove weather intent input cast by widening typed tool intent contract - preserve specific weather tool error classes in reasonCode mapping - align orchestrator/planner tests and prompt guidance with tool policy
- emit explicit weather failure marker in planner payload when tool has no result message - reject mixed lat/lon + gridpoint weather location shapes in planner normalization - align planner test fixtures and assertions with explicit tool skip/failure metadata - constrain weather prompt schema numeric fields to backend validator requirements - promote weather_forecast to first-class tool invocation name
Summary by CodeRabbit
New Features
Documentation
Tests