feat: end-to-end WhatsApp death-certificate verification#45
Merged
Merged
Conversation
…handoff Wire the full flow: an inbound WhatsApp image is stored in a transient media store on arrival, the death-certificate agent invokes a context-aware verify tool that pulls the image out of band (never through the model), runs the full reliability pipeline (document, authenticity, consistency, score) and hands the case off to GiveLight when it clears the acceptance policy. - session_store: transient per-session media store (save/load latest image) - orchestrator: SessionContext deps + context-aware tool registration; thread deps through Session/run_stream; default Vertex region -> us-central1 - verify tool: run_pipeline + build_handoff_payload + deliver_to_gl (stub), replacing the base64-image-as-tool-arg design that could not work via an LLM - api: extract image/document messages; whatsapp_media.download_media resolves a Meta media ID to bytes (WHATSAPP_TOKEN); route bytes into chat() - chat: store uploaded image, build SessionContext, route image turns on the conversation narrative; the model sees only a text notice, never the bytes - fix: death-cert agent referenced a tool name that did not resolve - tests: media store, context tools, verify tool, api image path, and a TestModel integration test driving the tool + deps + handoff end to end
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.
Summary
session_mediacollection, 72h TTL, ~700 KB guard) so tools can retrieve the latest image bysession_id.needs_context: trueis registered with aRunContextcarryingSessionContextdeps and pulls out-of-band state itself — the image never passes through the model.image/documentmessages inPOST /message; resolve the Meta media ID to bytes viawhatsapp_media.download_media(WHATSAPP_TOKEN) and route bytes intochat().VERTEX_LOCATIONus-east1→us-central1.Notes
WHATSAPP_TOKENand the local e2e driver scripts are intentionally out of scope of this PR.WHATSAPP_TOKENmust be provisioned. This assumes the upstream webhook forwards raw Meta payloads (media IDs); if it pre-resolves media, onlywhatsapp_media.pyand_extract_messagechange.Validation
.venv/bin/python -m pytest tests/unit/test_api.py tests/unit/test_chat.py tests/unit/test_session_store.py tests/unit/test_verify_flow_integration.py tests/unit/tools/death_certificate_pipeline/test_verify.pypassed: 34 tests.score=96 band=high,gl.handoff_stubfired, agent confirmed the case was forwarded.srcand the focused tests.