Spaces:
Running
Agent instructions — CarePath unified
CarePath is one unified medical AI product with two clearly separated user-facing modules:
Ghi chép bệnh án AI Internal/technical term: AI Scribe / scriber Backend:
scribe/carepath,/api/v1/*Purpose: listen to a consultation and help generate structured clinical notes.Phiên dịch khám bệnh trực tiếp Internal/technical term: Medical Interpreter / interpreter Backend:
interpreter/app,/api/*+/ws/*Purpose: live two-way interpretation between Vietnamese doctors and English-speaking patients.
The app is served by one FastAPI process plus two Vite frontends:
scribe/frontend/at/interpreter/frontend/at/phien-dich-y-khoa/(/console/is a legacy redirect)
Interpreter status
After restructure Phase 7, the Interpreter is on hold. Accept only bug fixes, safety fixes, and required operational maintenance there; new product work is focused on the Scribe training track unless the owner explicitly reopens it.
docs/history/PLAN.md and docs/history/DEMO-SITE-PLAN.md are historical build
plans for the interpreter and demo site. docs/history/MERGE-PLAN.md is the
executed unification plan, M.0–M.8 done, and docs/history/JUDGE.md is its
review protocol.
docs/research.md holds the interpreter safety background.
Product UX contract
CarePath must be Vietnamese-first.
The target users may include Vietnamese doctors who are not comfortable with English medical software terms. Therefore, the UI must explain workflows by user intent, not by English product names.
Primary user-facing labels
Use these as primary UI labels:
Ghi chép bệnh án AIPhiên dịch khám bệnh trực tiếp
Use these as primary CTAs:
Bắt đầu ghi chépBắt đầu phiên dịch
Use this homepage framing:
Bạn muốn hỗ trợ việc gì hôm nay?
Secondary/internal labels
The following English terms may appear only as secondary helper text, developer labels, comments, docs, or internal route/component names:
- Scribe
- AI Scribe
- Interpreter
- Medical Interpreter
- Console
- Transcript
- Encounter
- Session
Do not use Scribe or Interpreter as primary labels on user-facing screens.
Required distinction between the two modules
The landing page must make it obvious that these are two different workflows:
Ghi chép bệnh án AI
Explain as:
AI nghe buổi khám và tạo ghi chú y khoa có cấu trúc.
Use when:
Phù hợp khi bác sĩ muốn giảm thời gian nhập liệu sau khám.
Clarify that the doctor must review the output before use.
Phiên dịch khám bệnh trực tiếp
Explain as:
Dịch hai chiều giữa bác sĩ tiếng Việt và bệnh nhân tiếng Anh trong lúc khám.
Use when:
Phù hợp khi bác sĩ và bệnh nhân không cùng ngôn ngữ.
Clarify that the system translates only and must not provide medical advice.
Every user-facing screen must answer
- Tôi đang dùng chức năng nào?
- Chức năng này giúp việc gì?
- Tôi cần bấm gì tiếp theo?
- Có rủi ro hoặc giới hạn nào bác sĩ cần biết không?
Vietnamese copy rules
- Vietnamese text must be clear, short, and professional.
- Preserve Vietnamese diacritics.
- Keep text NFC-normalized.
- Avoid unnecessary English.
- Avoid startup/marketing buzzwords on clinical workflow screens.
- Prefer concrete action language over abstract product names.
Good:
Ghi chép bệnh án AI
Phiên dịch khám bệnh trực tiếp
Bắt đầu ghi chép
Bắt đầu phiên dịch
Bác sĩ nói tiếng Việt, bệnh nhân nghe tiếng Anh
Avoid as primary UI:
Scribe
Interpreter
Session
Encounter
Transcript
Start session
Launch interpreter
Non-negotiable safety invariants
This file is the current safety contract. docs/history/PLAN.md §2 preserves
the original MVP source for historical context.
- Translate-only: never generate medical advice, diagnoses, or drug recommendations.
- High/critical-risk turns are blocked from patient display and TTS until doctor confirms.
- Low-confidence output is always visibly flagged, never silently delivered.
- Raw audio is never persisted. Use memory-only processing. No audio columns, no temp files.
- No mic capture before recorded consent.
- On any pipeline or reviewer failure, fail closed: keep the turn blocked, show the doctor raw source and translation, offer escalation. Never fail open to the patient.
Implementation workflow for agents
For UX or product-flow changes, do not implement immediately.
First produce or update a plan in docs/ux-redesign-carepath.md with:
- Current UX problem
- Proposed flow
- Affected routes/pages/components
- Vietnamese-first copy
- Implementation stories
- Dependencies between stories
- Acceptance criteria
- Validation commands
- Risks and fallback behavior
Then implement one story at a time.
Recommended story order for UX redesign
- Update Vietnamese-first product naming and copy.
- Redesign the landing page into two clear workflow cards.
- Add or clarify separate entry routes for the two modules.
- Add pre-start onboarding/explanation screens.
- Improve empty/loading/error states in Vietnamese.
- Run QA for mobile, accessibility, safety copy, and route regressions.
Do not combine homepage redesign, routing changes, and audio/backend logic changes in one large patch.
Agent behavior
- Keep changes small and focused.
- Preserve existing working functionality.
- Do not rewrite backend, audio, risk, or websocket logic unless the current story explicitly requires it.
- Do not introduce new dependencies without documenting why.
- Prefer existing components and styling patterns.
- When changing user-facing Vietnamese text, check diacritics and consistency.
- When changing risk-engine behavior, update fixtures and evals.
- When changing product copy only, avoid touching medical logic.
Commands
Combined service
uvicorn carepath.main:app --app-dir scribe --reload
Requires:
pip install -e ".[dev]" -e "./shared" -e "./interpreter[dev]"
Scriber and combined tests
pytest
python scripts/smoke_backend.py
python scripts/build_term_artifacts.py --check
Interpreter backend alone
cd interpreter && uvicorn app.main:app --reload
pytest
Console
cd interpreter/frontend && npm run dev
npm test
npx playwright test
Demo site
cd scribe/frontend && npm run dev
npm test
npm run build
npm run e2e
npm run build is also the diacritics gate.
Full mock-mode run
Set this in .env:
PROVIDER_MODE=mock
Mock mode must work with no API keys.
Eval regression
python interpreter/eval/run_eval.py --set interpreter/eval/fixtures/eval_starter.tsv --providers mock
Conventions
- Python 3.12.
- Python code must be ruff-formatted and type-hinted.
- Use pure functions for normalization and risk rules.
- TypeScript must be strict.
- Components should be small.
- Keep state minimal: context/zustand is allowed, Redux is not.
shared/carepath_shared/terms/medical_terms.jsonis the canonical medical term source. Regeneratedata/medical_lexicon.jsonandinterpreter/app/glossary/data/seed_glossary.csvwithpython scripts/build_term_artifacts.py; do not hand-edit generated artifacts.- Risk lexicons under
interpreter/app/risk/lexicons/remain separate interpreter safety data. Clinicians edit data, not code. - Every risk-engine behavior change updates
interpreter/eval/fixtures/risk_cases.jsonl. - The fixture run is the test.
- Zero misses on critical fixtures is a hard gate.
- Secrets only via env.
.envis gitignored..env.examplemust stay current.- No new dependencies without noting why in the PR.
- Vietnamese text is data, not decoration: always NFC-normalized, diacritics preserved.
- Tests must include diacritic-stripped variants where matching allows it.
Acceptance criteria for UX clarity changes
A UX clarity change is not done un less all of the following are true:
A Vietnamese doctor can understand the two workflows without knowing the words
ScribeorInterpreter.The landing page clearly separates:
Ghi chép bệnh án AIPhiên dịch khám bệnh trực tiếp
Each workflow has a distinct CTA.
Each workflow explains when to use it.
English terms appear only as secondary helper text, not primary labels.
Mobile layout remains clear.
Existing core functionality still works.
Safety invariants remain unchanged.
Build and relevant tests pass.
Harness workflow
This repository uses Repository Harness for durable task intake, proof, and decision records. This block adds to the CarePath instructions above; it does not replace them.
Priority, highest first:
- The current user request and the safety and product rules in this file.
- Current product contracts in
docs/product/. - Selected story packets in
docs/stories/and accepted decisions indocs/decisions/. - Executable tests and the Harness proof matrix.
docs/history/as context only.
Before any task, read README.md, docs/HARNESS.md, and
docs/FEATURE_INTAKE.md; then run
.\scripts\bin\harness-cli.exe query matrix on Windows. Classify and record
the task as tiny, normal, or high-risk before changing code.
- Tiny work records an intake and runs the relevant quick proof.
- Normal work also updates one story packet and its proof record.
- High-risk work uses
docs/templates/high-risk-story/, records a decision when it changes architecture, data, safety, APIs, or validation, and waits for human direction if its scope is ambiguous. - A UX or product-flow task still must first update
docs/ux-redesign-carepath.md, then follow the Harness lane requirements. - Before a step that could use an external tool, query the available provider:
.\scripts\bin\harness-cli.exe query tools --capability <capability> --status present. A missing provider is a clean skip, never a reason to invent a dependency. - Finish normal and high-risk work with a Harness trace that records the real validation outcome and any friction. Do not claim proof that was not run.