phase-8:server code enhancements.

This commit is contained in:
Sai Kiran Vella
2026-06-05 22:44:04 -04:00
parent a7108b448a
commit 1e2aac7164
15 changed files with 781 additions and 94 deletions
+8
View File
@@ -657,6 +657,14 @@ Both `market-calls.json` and `portfolio.json` use `writeFileSync` with no concur
Update `StockScorer.test.js` to cover the three new scoring factors: analyst consensus scoring (including the `numberOfAnalysts < 3` guard), DCF margin of safety scoring (positive/negative/null cases), and the new 52W risk flags.
#### 8l — Anthropic prompt caching for LLMAnalyst
`LLMAnalyst.analyze()` sends a large system prompt on every `/api/analyze` call. Enabling Anthropic prompt caching would cache the static system prompt across calls, reducing latency and token costs significantly.
Target: add `cache_control: { type: 'ephemeral' }` to the system prompt message block in `AnthropicClient.complete()` (or in `LLMAnalyst.analyze()` if the system prompt is built there). Use the `anthropic-beta: prompt-caching-2024-07-31` header. The cache has a 5-minute TTL and applies to the longest common prefix of consecutive requests — ideal for the static analysis instructions that never change between calls.
See: https://docs.anthropic.com/en/docs/build-with-claude/prompt-caching
---
## Adding a New Asset Type