CareThread

A jurisdiction aware care continuity agent that uses CockroachDB as persistent agent memory and AWS for clinical document intelligence.


Inspiration

Modern imaging generates incidental findings faster than manual workflows can track them. A radiology report may recommend repeat chest computed tomography in six to twelve months for a solitary pulmonary nodule. The discharge summary from the same admission may never mention it. Six months later, no one owns the obligation.

This is not negligence in the ordinary sense. It is a memory failure at the boundary between systems, specialties, and visits. Retrospective cohort work on solitary pulmonary nodules reports that roughly half of patients do not receive guideline concordant follow up [1]. In a safety net population, 39 percent had no documented surveillance at all for incidental nodules in the five to eight millimeter range [2]. Communication failures appear in nearly half of medical malpractice claims, and 40 percent of those failures involve a broken handoff [3]. The Joint Commission has long treated miscommunication as a leading contributor to sentinel events [4].

Existing responses tend to be human heavy: nurse navigators, registries, manual chart review. A tracking program at one academic center reduced the proportion of patients with no imaging follow up within two years from 48 percent to 31 percent and was associated with a shift toward earlier stage lung cancer diagnosis [5]. That outcome is clinically meaningful. It also shows the ceiling of systems that depend on people to remember what software forgot.

We entered this hackathon because the problem maps cleanly onto agentic memory. An agent that watches clinical documentation needs a store that survives restarts, scales with document volume, and keeps vectors, structured facts, and transactional obligation state in one place. When that memory goes offline, the agent does not degrade gracefully. It stops. CareThread is our answer: a care continuity agent whose system of record is CockroachDB on AWS, with inference and artifact storage on Amazon Bedrock and S3.


What it does

CareThread monitors ingested clinical artifacts for follow up obligations that were recommended and then dropped. Its unit of work is a CareThread: a persistent, auditable case tied to one patient, one finding, and one recommended interval.

The agent performs five bounded functions:

  1. Detect unresolved follow up recommendations in radiology reports, discharge summaries, and progress notes
  2. Propose opening a trackable obligation rather than letting the finding vanish when the encounter ends
  3. Retrieve patient scoped memory when new documents arrive and score candidate matches against open threads
  4. Propose linking completion evidence, updating status, extending deadlines, or escalating overdue cases
  5. Wait for clinician approval before any consequential state change takes effect

The design boundary is deliberate. CareThread does not diagnose, interpret imaging autonomously, message patients, or close cases on its own. It coordinates follow up based on clinician authored evidence. That makes it a memory and accountability layer, not a diagnostic engine.

The MVP centers on incidental pulmonary nodule follow up, with additional demo threads for cardiac, thyroid, renal, and spine findings to show that the same architecture generalizes. A family analysis path flags hereditary risk patterns across consented relatives without crossing unrelated patient boundaries.


Architecture

Component Responsibility
Clinician Interface Upload documents, review proposals, approve or reject actions, inspect history
API Layer Routes requests, enforces access rules, coordinates ingestion and review
Ingestion Pipeline Store raw documents, extract text, chunk content, derive facts and findings
Action Agent Detects care gaps and proposes opening or closing threads
Matching Agent Links new documents to open obligations with scored evidence matches
Follow Up Agent Scans overdue threads and proposes escalation
Family Agent Flags hereditary risk patterns across consented relatives
Proposal Queue Holds pending actions until a clinician decides
Approval Service Sole path for state changes; validates transitions before writing
Persistent Memory Obligations, evidence links, embeddings, structured clinical facts
Audit Log Immutable record of every proposal, approval, rejection, and state change

Read path. A document enters through ingestion. Content is stored, parsed, and written to memory. The Action Agent and Matching Agent read patient scoped state during ingest. The Follow Up Agent and Family Agent run on demand. All four return proposals with reasons. Nothing changes until a clinician acts.

Write path. Agents insert proposals only. The approval service commits approved changes to memory and appends to the audit log. Rejected proposals remain on record.


How we built it

Agentic memory in CockroachDB

CockroachDB is not a log dump or a side cache in CareThread. It is the agent system of record. We store four memory classes in one distributed SQL engine:

Memory class Tables Role
Semantic artifact_chunks.embedding (VECTOR, 256d) Patient scoped similarity search during evidence matching
Structured facts, findings Normalized clinical signals extracted from free text
Transactional care_threads, thread_evidence, proposed_actions Obligation lifecycle with ACID guarantees
Audit thread_events Append only provenance: who acted, prior state, new state, metadata

Vectors and relational rows live in the same database. That removes the consistency gap that appears when a separate vector store drifts from operational state. Patient scoping is enforced in application code: every retrieval query filters on patient_id. The Family Agent is the one sanctioned cross patient read, limited to an explicit consented family group.

We run on CockroachDB Cloud in AWS us east 1 with TLS verified connections. Distributed vector indexing stores Titan embeddings natively; CockroachDB built in VECTOR type means we do not depend on a Postgres extension in production [6].

AWS integration

Service Function
Amazon Bedrock (Claude Sonnet 4.5) Structured extraction of facts and findings; evidence match judging with schema validated JSON via forced tool use; patient and family chat summaries
Amazon Bedrock (Titan Text Embeddings v2) 256 dimensional chunk embeddings stored in CockroachDB
Amazon S3 Private artifact bucket with SSE-S3; patient keyed object prefixes
AWS IAM Credential chain for all AWS calls

Agent design

Four agents share the same memory substrate but different responsibilities:

  • Action Agent proposes OPEN_THREAD and CLOSE_THREAD when gaps or completion evidence are detected
  • Matching Agent scores open threads using embedding similarity, anatomical location, finding type, and title overlap, then defers final judgment to Claude when Bedrock is enabled
  • Follow Up Agent scans overdue threads and proposes ESCALATE_THREAD with explicit day counts and reasons
  • Family Agent reads consented relative findings and proposes hereditary risk review threads without diagnosing or writing state

All agents respect the same invariant: propose only, never commit. State transitions follow an explicit machine (PROPOSED → OPEN → IN_PROGRESS → AWAITING_EVIDENCE → OVERDUE → ESCALATED → CLOSED) validated in thread_state_machine.py.

Frontend and demo loop

A Next.js application provides six screens: dashboard, thread detail, evidence match review, patient memory, clinician review queue, and history with provenance. A seed script loads a reproducible demo dataset including PDF and image artifacts, family clusters, and a full open to close thread lifecycle for the flagship Jane Doe pulmonary nodule case.


Alignment with judging criteria

Agentic memory design

CockroachDB holds semantic, structured, transactional, and audit memory together. The agent cannot function without it: there is no in memory session state that substitutes for obligation tracking across days and documents. Embeddings, thread status, proposed actions, and provenance events all persist in the same cluster. This is memory at the scale the use case demands (every chunk of every document for every patient under follow up), not a toy key value store.

Technical implementation

We use CockroachDB Cloud and distributed vector indexing as our two qualifying CockroachDB tools. Integration is through SQLAlchemy with the cockroachdb+psycopg2 dialect, certifi backed TLS, and pgvector compatible VECTOR columns that work natively on CockroachDB without extension creation.

We have not yet wired the CockroachDB Cloud MCP Server or ccloud CLI into the runtime. Those are on our near term roadmap for operator visibility and cluster management. What we did prioritize is safe agent access patterns: read heavy agents query through scoped SQL; write paths go through a single approval service; we handle CockroachDB serializable retry behavior in our test suite.

Bedrock integration uses forced tool schemas so extraction and matching return validated JSON, not freeform prose that could corrupt state. Per call fallback to local extractors prevents a single API failure from blocking ingestion.

Real world impact

The use case targets a documented failure mode, not a synthetic benchmark. Lost follow up on incidental findings affects a large fraction of real patients [1][2]. Manual tracking programs improve outcomes [5] but do not scale with imaging volume. CareThread automates the memory layer those programs still staff by hand: detect the obligation, keep it visible, match later evidence, escalate when overdue, and preserve a defensible audit trail for quality review and medicolegal inquiry [3].

If deployed inside a health system, the agent would sit alongside existing EHR and PACS workflows rather than replace clinicians. Its value is continuity across handoffs, which is exactly where the literature locates the failure [3][4].

Production readiness

We designed for production constraints even in MVP form:

Security. Role based access control gates approval actions. Patient scoped retrieval prevents cross patient leakage. Agents cannot write obligation state directly. S3 objects are private with server side encryption.

Honest gaps. Authentication is header based demo RBAC, not enterprise SSO. There is no deployed AWS compute layer yet; backend and frontend run locally against cloud memory and cloud AI. We have not completed a formal security review or HIPAA BAA path. These are known blockers before any real patient data.

Resilience. Bedrock and S3 calls degrade to local fallbacks on failure. CockroachDB serializable isolation conflicts are expected under concurrent writes and are handled in tests. Thread events provide observability: every state change is reconstructable from the audit log without relying on model conversation history.

Scalability. CockroachDB distributed architecture supports horizontal scale as document volume grows. Chunk level embeddings allow semantic search without reprocessing entire charts. The approval queue pattern decouples agent throughput from clinical review capacity.

Creativity and originality

Most agent demos treat memory as chat history or a vector RAG sidecar. CareThread treats memory as obligations with lifecycle, evidence, and accountability. That is closer to how production clinical workflows actually fail: not because nobody saw the finding, but because nobody retained ownership of it across time.

The insight is that agentic systems in regulated domains need transactional memory, not just retrieval memory. A thread is a first class object with status, due dates, linked evidence, and an approval gate. That design choice is what separates a demo chatbot from something a hospital quality team could trust.


Challenges we ran into

Clinical safety versus agent utility. Full autonomy would fail any responsible review. Pure rules miss nuance in free text. We settled on a hybrid: deterministic scoping and state machines in code, Bedrock for extraction and judgment inside strict schemas, humans holding veto on every write.

CockroachDB operational semantics. Schema creation runs as asynchronous jobs in CockroachDB, which required careful sequencing in our seed script. End to end tests surfaced transaction retry behavior under serializable isolation when multiple writes contend.

Evidence matching across fragmented documentation. A follow up scan report and an original radiology recommendation rarely share wording. Co locating Titan embeddings with structured findings in CockroachDB let us combine cosine similarity with location and finding type signals before the LLM judge step.

Demo reliability. Bedrock calls can fail mid presentation. Per call fallback to local deterministic extractors and hash based embeddings ensures ingestion never hard stops, at the cost of lower quality during degradation.


Accomplishments that we are proud of

We shipped a complete agent loop, not a concept demo. Artifact ingest, vector storage, fact extraction, gap detection, thread proposal, evidence matching, overdue escalation, and closure all run end to end with provenance visible in the UI.

We treated memory as the product. CockroachDB holds the full lifecycle of an obligation: who proposed what, which artifact supported it, which clinician approved it, and how state changed over time.

We enforced clinical boundaries in code rather than in prompt text alone. Patient scoped retrieval, a single approval gate for mutations, and immutable event logging are structural guarantees.

We grounded the problem in published failure rates and in evidence that structured tracking improves outcomes [1][5], then built the automation layer those programs still staff manually.


What is next for CareThread

Deployment. Move ingestion and scheduled agent runs to AWS Lambda or Amazon ECS so memory in CockroachDB is always reachable by event driven workers, not only a local FastAPI process.

CockroachDB toolchain. Connect the CockroachDB Cloud managed MCP Server for audited read only agent and operator access to cluster state. Adopt ccloud CLI for provisioning, backup policy, and environment automation with JSON output suitable for agent driven operations.

Clinical expansion. Widen finding coverage beyond the pulmonary nodule anchor case. Add real authentication, enterprise SSO, and EHR facing ingest adapters. Complete the path to HIPAA aligned deployment with proper BAAs and audit export.

Multi agent memory sharing. CareThread should function as shared agentic memory inside a hospital: one distributed database where multiple specialized agents read the same patient obligations, write only through approval, and never lose track of a recommendation because the original encounter closed.

The hackathon asks why agentic memory matters now. CareThread is our answer. Follow up failures are measured in tens of percent of patients [1][2]. The fix in the literature is persistent tracking [5]. We built that tracking as production grade memory on CockroachDB, with AWS powering the language and embedding layer that turns unstructured charts into structured, actionable obligations.


References

[1] Williams et al., Rate of Incidental Lung Nodule Follow Up: A Cohort Study Evaluating Adherence to Guideline Recommendations, American Journal of Medical Oncology, 2025. https://doi.org/10.1016/j.ajmo.2025.100091

[2] Triplette et al., Follow up of incidental pulmonary nodules and association with mortality in a safety net cohort, Journal of Thoracic Oncology, 2020. https://pmc.ncbi.nlm.nih.gov/articles/PMC7757426/

[3] Siegler et al., Frequency and Nature of Communication and Handoff Failures in Medical Malpractice Claims, Journal of Patient Safety, 2022. https://pubmed.ncbi.nlm.nih.gov/35188927/

[4] The Joint Commission, contributing factors in sentinel events including communication; cited in patient safety communication literature. https://pmc.ncbi.nlm.nih.gov/articles/PMC11131125/

[5] Mazzone et al., Improvement in Stage of Lung Cancer Diagnosis With Incidental Pulmonary Nodules Followed With a Patient Tracking System and Computerized Registry, Chest, 2022. https://pmc.ncbi.nlm.nih.gov/articles/PMC8924678/

[6] CockroachDB Distributed Vector Indexing documentation. https://www.cockroachlabs.com/docs/stable/vector-indexes

Built With

Share this project:

Updates

Submission history