Skip to content

Commit 2af0e08

Browse files
authored
doc: update claude-code usage terms (#315)
* doc: update claude-code usage terms * doc: update claude-code usage terms * doc: update claude-code usage terms
1 parent f648178 commit 2af0e08

6 files changed

Lines changed: 224 additions & 18 deletions

File tree

hindsight-api/hindsight_api/config.py

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -447,14 +447,30 @@ class HindsightConfig:
447447
# Reflect agent settings
448448
reflect_max_iterations: int
449449

450+
def validate(self) -> None:
451+
"""Validate configuration values and raise errors for invalid combinations."""
452+
# RETAIN_MAX_COMPLETION_TOKENS must be greater than RETAIN_CHUNK_SIZE
453+
# to ensure the LLM has enough output capacity to extract facts from chunks
454+
if self.retain_max_completion_tokens <= self.retain_chunk_size:
455+
raise ValueError(
456+
f"Invalid configuration: HINDSIGHT_API_RETAIN_MAX_COMPLETION_TOKENS "
457+
f"({self.retain_max_completion_tokens}) must be greater than "
458+
f"HINDSIGHT_API_RETAIN_CHUNK_SIZE ({self.retain_chunk_size}). "
459+
f"\n\nYou have two options to fix this:"
460+
f"\n 1. Increase HINDSIGHT_API_RETAIN_MAX_COMPLETION_TOKENS to a value > {self.retain_chunk_size}"
461+
f"\n 2. Use a model that supports at least {self.retain_max_completion_tokens} output tokens"
462+
f"\n (current model: {self.retain_llm_model or self.llm_model}, "
463+
f"provider: {self.retain_llm_provider or self.llm_provider})"
464+
)
465+
450466
@classmethod
451467
def from_env(cls) -> "HindsightConfig":
452468
"""Create configuration from environment variables."""
453469
# Get provider first to determine default model
454470
llm_provider = os.getenv(ENV_LLM_PROVIDER, DEFAULT_LLM_PROVIDER)
455471
llm_model = os.getenv(ENV_LLM_MODEL) or _get_default_model_for_provider(llm_provider)
456472

457-
return cls(
473+
config = cls(
458474
# Database
459475
database_url=os.getenv(ENV_DATABASE_URL, DEFAULT_DATABASE_URL),
460476
database_schema=os.getenv(ENV_DATABASE_SCHEMA, DEFAULT_DATABASE_SCHEMA),
@@ -631,6 +647,8 @@ def from_env(cls) -> "HindsightConfig":
631647
# Reflect agent settings
632648
reflect_max_iterations=int(os.getenv(ENV_REFLECT_MAX_ITERATIONS, str(DEFAULT_REFLECT_MAX_ITERATIONS))),
633649
)
650+
config.validate()
651+
return config
634652

635653
def get_llm_base_url(self) -> str:
636654
"""Get the LLM base URL, with provider-specific defaults."""

hindsight-api/hindsight_api/engine/providers/mock_llm.py

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ def __init__(
6565
# Storage for test verification
6666
self._mock_calls: list[dict] = []
6767
self._mock_response: Any = None
68+
self._mock_exception: Exception | None = None
6869

6970
async def verify_connection(self) -> None:
7071
"""
@@ -124,6 +125,10 @@ async def call(
124125
self._mock_calls.append(call_record)
125126
logger.debug(f"Mock LLM call recorded: scope={scope}, model={self.model}")
126127

128+
# Raise mock exception if configured
129+
if self._mock_exception is not None:
130+
raise self._mock_exception
131+
127132
# Return mock response
128133
if self._mock_response is not None:
129134
result = self._mock_response
@@ -183,6 +188,10 @@ async def call_with_tools(
183188
}
184189
self._mock_calls.append(call_record)
185190

191+
# Raise mock exception if configured
192+
if self._mock_exception is not None:
193+
raise self._mock_exception
194+
186195
if self._mock_response is not None:
187196
if isinstance(self._mock_response, LLMToolCallResult):
188197
return self._mock_response
@@ -215,6 +224,16 @@ def set_mock_response(self, response: Any) -> None:
215224
"""
216225
self._mock_response = response
217226

227+
def set_mock_exception(self, exception: Exception) -> None:
228+
"""
229+
Set an exception to raise from mock calls.
230+
231+
Args:
232+
exception: The exception to raise on the next call.
233+
After raising, the exception is cleared.
234+
"""
235+
self._mock_exception = exception
236+
218237
def get_mock_calls(self) -> list[dict]:
219238
"""
220239
Get the list of recorded mock calls.
@@ -230,5 +249,6 @@ def get_mock_calls(self) -> list[dict]:
230249
return self._mock_calls
231250

232251
def clear_mock_calls(self) -> None:
233-
"""Clear the recorded mock calls."""
252+
"""Clear the recorded mock calls and any set exception."""
234253
self._mock_calls = []
254+
self._mock_exception = None

hindsight-api/hindsight_api/engine/retain/fact_extraction.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1011,6 +1011,29 @@ def get_value(field_name):
10111011

10121012
except BadRequestError as e:
10131013
last_error = e
1014+
error_str = str(e).lower()
1015+
1016+
# Check if error is related to max_tokens/completion_tokens not being supported
1017+
if any(
1018+
keyword in error_str
1019+
for keyword in [
1020+
"max_tokens",
1021+
"max_completion_tokens",
1022+
"maximum context",
1023+
"token limit",
1024+
"context length",
1025+
]
1026+
):
1027+
# Provide helpful error message with configuration suggestions
1028+
raise ValueError(
1029+
f"Model does not support the required output token limit.\n\n"
1030+
f"The model '{llm_config.model}' (provider: {llm_config.provider}) failed with: {e}\n\n"
1031+
f"You have two options to fix this:\n"
1032+
f" 1. Use a different model that supports at least {config.retain_max_completion_tokens} output tokens\n"
1033+
f" 2. Decrease HINDSIGHT_API_RETAIN_MAX_COMPLETION_TOKENS to a value your model supports\n"
1034+
f" (current value: {config.retain_max_completion_tokens}, must be > RETAIN_CHUNK_SIZE={config.retain_chunk_size})"
1035+
) from e
1036+
10141037
if "json_validate_failed" in str(e):
10151038
logger.warning(
10161039
f" [1.3.{chunk_index + 1}] Attempt {attempt + 1}/{max_retries} failed with JSON validation error: {e}"

hindsight-docs/docs/developer/models.md

Lines changed: 43 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,20 @@ export HINDSIGHT_API_RETAIN_LLM_PROVIDER=anthropic
9191

9292
Other LLM models not listed above may work with Hindsight, but they must support **at least 65,000 output tokens** to ensure reliable fact extraction. If you need support for a specific model that doesn't meet this requirement, please [open an issue](https://github.com/hindsight-ai/hindsight/issues) to request an exception.
9393

94+
:::tip Models with Limited Output Tokens
95+
If your model only supports 32k or fewer output tokens (e.g., some older models), you can reduce the retain completion token limit:
96+
97+
```bash
98+
# For models that support 32k output tokens
99+
export HINDSIGHT_API_RETAIN_MAX_COMPLETION_TOKENS=32000
100+
101+
# For models that support 16k output tokens
102+
export HINDSIGHT_API_RETAIN_MAX_COMPLETION_TOKENS=16000
103+
```
104+
105+
**Important:** `HINDSIGHT_API_RETAIN_MAX_COMPLETION_TOKENS` must be greater than `HINDSIGHT_API_RETAIN_CHUNK_SIZE` (default: 3000). The system will validate this on startup and provide an error message if the configuration is invalid.
106+
:::
107+
94108
### Configuration
95109

96110
```bash
@@ -175,20 +189,40 @@ You can use any model supported by OpenAI Codex CLI
175189
- Usage is billed to your ChatGPT subscription (not separate API costs)
176190
- For personal development use only (see ChatGPT Terms of Service)
177191

178-
**Troubleshooting:**
179-
180-
If authentication fails:
181-
```bash
182-
# Re-login to refresh tokens
183-
codex auth login
184-
```
185-
186192
---
187193

188194
### Claude Code Setup (Claude Pro/Max)
189195

190196
Use your Claude Pro or Max subscription for Hindsight without separate Anthropic API costs.
191197

198+
199+
:::warning Terms of Service Notice
200+
201+
This integration uses the Claude Agent SDK with your personal Claude Pro/Max subscription
202+
credentials. You must be logged into Claude Code on your own machine before using this provider.
203+
204+
**Please be aware:**
205+
206+
- Anthropic's [Agent SDK documentation](https://docs.claude.com/en/api/agent-sdk/overview)
207+
states that third-party developers should not offer claude.ai login or rate limits for
208+
their products. Hindsight does **not** perform any login on your behalf — it uses
209+
credentials you've already authenticated via `claude auth login`.
210+
- In January 2026, Anthropic [enforced restrictions](https://paddo.dev/blog/anthropic-walled-garden-crackdown/)
211+
against third-party tools using Claude subscription OAuth tokens. Those restrictions
212+
targeted tools that **spoofed the Claude Code client identity** — Hindsight uses the
213+
official Claude Agent SDK instead.
214+
- This provider is intended for **local, personal development use only**. Do not use it
215+
in production deployments or shared environments.
216+
- Anthropic's terms may change. If you want guaranteed compliance, use the `anthropic`
217+
provider with an API key instead.
218+
- Usage counts against your Claude Pro/Max subscription limits.
219+
220+
For production or team use, we recommend using `HINDSIGHT_API_LLM_PROVIDER=anthropic` with
221+
an API key from the [Anthropic Console](https://console.anthropic.com/).
222+
223+
:::
224+
225+
192226
**Prerequisites:**
193227
- Active Claude Pro or Max subscription
194228
- Claude Code CLI installed
@@ -233,6 +267,7 @@ You can use any model supported by Claude Code CLI.
233267
- Usage billed to your Claude subscription (not separate API costs)
234268
- For personal development use only (see Claude Terms of Service)
235269

270+
236271
---
237272

238273
## Embedding Model

hindsight-docs/versioned_docs/version-0.4/developer/installation.md

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,81 @@ docker run --rm -it --pull always -p 8888:8888 -p 9999:9999 \
5050
- **API Server**: http://localhost:8888
5151
- **Control Plane** (Web UI): http://localhost:9999
5252

53+
### Docker Image Variants
54+
55+
Hindsight provides two image variants with different size/capability tradeoffs:
56+
57+
| Variant | Size (AMD64) | Size (ARM64) | Use Case |
58+
|---------|--------------|--------------|----------|
59+
| **Full** (`latest`) | ~9 GB | ~3.7 GB | Includes local ML models (embeddings, reranking) |
60+
| **Slim** (`slim`) | ~500 MB | ~500 MB | Requires external embedding/reranking providers |
61+
62+
**Full image** (default):
63+
```bash
64+
docker run --rm -it -p 8888:8888 \
65+
-e HINDSIGHT_API_LLM_API_KEY=$OPENAI_API_KEY \
66+
ghcr.io/vectorize-io/hindsight:latest
67+
```
68+
- ✅ Works out of the box with local ML models
69+
- ✅ No additional services needed
70+
- ❌ Larger image size (AMD64 includes CUDA libraries for GPU support)
71+
72+
**Slim image**:
73+
```bash
74+
docker run --rm -it -p 8888:8888 \
75+
-e HINDSIGHT_API_LLM_API_KEY=$OPENAI_API_KEY \
76+
-e HINDSIGHT_API_EMBEDDINGS_PROVIDER=openai \
77+
-e HINDSIGHT_API_RERANKER_PROVIDER=cohere \
78+
-e HINDSIGHT_API_COHERE_API_KEY=$COHERE_API_KEY \
79+
ghcr.io/vectorize-io/hindsight:slim
80+
```
81+
- ✅ Dramatically smaller image (~95% reduction on AMD64)
82+
- ✅ Faster pull/deploy times
83+
- ✅ Lower memory footprint
84+
- ❌ Requires external embedding/reranking services (OpenAI, Cohere, TEI)
85+
86+
**When to use slim:**
87+
- Cloud deployments where image size matters
88+
- Using managed embedding services (OpenAI, Cohere)
89+
- Running on Text Embeddings Inference (TEI) infrastructure
90+
- Kubernetes environments with fast pull requirements
91+
92+
:::warning Slim Image Requires External Providers
93+
If you run the slim image **without** setting external embedding providers, you'll see this error:
94+
95+
```
96+
ImportError: sentence-transformers is required for LocalSTEmbeddings.
97+
Install it with: pip install sentence-transformers
98+
```
99+
100+
**Fix:** Always set embedding and reranking providers when using slim images:
101+
```bash
102+
-e HINDSIGHT_API_EMBEDDINGS_PROVIDER=openai
103+
-e HINDSIGHT_API_EMBEDDINGS_OPENAI_API_KEY=sk-xxx
104+
-e HINDSIGHT_API_RERANKER_PROVIDER=cohere
105+
-e HINDSIGHT_API_COHERE_API_KEY=xxx
106+
```
107+
:::
108+
109+
See [Configuration](./configuration#embeddings-and-reranking) for all embedding provider options.
110+
111+
### Available Tags
112+
113+
```bash
114+
# Standalone (API + Control Plane)
115+
ghcr.io/vectorize-io/hindsight:latest # Full, latest release
116+
ghcr.io/vectorize-io/hindsight:slim # Slim, latest release
117+
ghcr.io/vectorize-io/hindsight:0.4.9 # Full, specific version
118+
ghcr.io/vectorize-io/hindsight:0.4.9-slim # Slim, specific version
119+
120+
# API only
121+
ghcr.io/vectorize-io/hindsight-api:latest
122+
ghcr.io/vectorize-io/hindsight-api:slim
123+
124+
# Control Plane only
125+
ghcr.io/vectorize-io/hindsight-control-plane:latest
126+
```
127+
53128
---
54129

55130
## Helm / Kubernetes

hindsight-docs/versioned_docs/version-0.4/developer/models.md

Lines changed: 43 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,20 @@ export HINDSIGHT_API_RETAIN_LLM_PROVIDER=anthropic
9191

9292
Other LLM models not listed above may work with Hindsight, but they must support **at least 65,000 output tokens** to ensure reliable fact extraction. If you need support for a specific model that doesn't meet this requirement, please [open an issue](https://github.com/hindsight-ai/hindsight/issues) to request an exception.
9393

94+
:::tip Models with Limited Output Tokens
95+
If your model only supports 32k or fewer output tokens (e.g., some older models), you can reduce the retain completion token limit:
96+
97+
```bash
98+
# For models that support 32k output tokens
99+
export HINDSIGHT_API_RETAIN_MAX_COMPLETION_TOKENS=32000
100+
101+
# For models that support 16k output tokens
102+
export HINDSIGHT_API_RETAIN_MAX_COMPLETION_TOKENS=16000
103+
```
104+
105+
**Important:** `HINDSIGHT_API_RETAIN_MAX_COMPLETION_TOKENS` must be greater than `HINDSIGHT_API_RETAIN_CHUNK_SIZE` (default: 3000). The system will validate this on startup and provide an error message if the configuration is invalid.
106+
:::
107+
94108
### Configuration
95109

96110
```bash
@@ -175,20 +189,40 @@ You can use any model supported by OpenAI Codex CLI
175189
- Usage is billed to your ChatGPT subscription (not separate API costs)
176190
- For personal development use only (see ChatGPT Terms of Service)
177191

178-
**Troubleshooting:**
179-
180-
If authentication fails:
181-
```bash
182-
# Re-login to refresh tokens
183-
codex auth login
184-
```
185-
186192
---
187193

188194
### Claude Code Setup (Claude Pro/Max)
189195

190196
Use your Claude Pro or Max subscription for Hindsight without separate Anthropic API costs.
191197

198+
199+
:::warning Terms of Service Notice
200+
201+
This integration uses the Claude Agent SDK with your personal Claude Pro/Max subscription
202+
credentials. You must be logged into Claude Code on your own machine before using this provider.
203+
204+
**Please be aware:**
205+
206+
- Anthropic's [Agent SDK documentation](https://docs.claude.com/en/api/agent-sdk/overview)
207+
states that third-party developers should not offer claude.ai login or rate limits for
208+
their products. Hindsight does **not** perform any login on your behalf — it uses
209+
credentials you've already authenticated via `claude auth login`.
210+
- In January 2026, Anthropic [enforced restrictions](https://paddo.dev/blog/anthropic-walled-garden-crackdown/)
211+
against third-party tools using Claude subscription OAuth tokens. Those restrictions
212+
targeted tools that **spoofed the Claude Code client identity** — Hindsight uses the
213+
official Claude Agent SDK instead.
214+
- This provider is intended for **local, personal development use only**. Do not use it
215+
in production deployments or shared environments.
216+
- Anthropic's terms may change. If you want guaranteed compliance, use the `anthropic`
217+
provider with an API key instead.
218+
- Usage counts against your Claude Pro/Max subscription limits.
219+
220+
For production or team use, we recommend using `HINDSIGHT_API_LLM_PROVIDER=anthropic` with
221+
an API key from the [Anthropic Console](https://console.anthropic.com/).
222+
223+
:::
224+
225+
192226
**Prerequisites:**
193227
- Active Claude Pro or Max subscription
194228
- Claude Code CLI installed
@@ -233,6 +267,7 @@ You can use any model supported by Claude Code CLI.
233267
- Usage billed to your Claude subscription (not separate API costs)
234268
- For personal development use only (see Claude Terms of Service)
235269

270+
236271
---
237272

238273
## Embedding Model

0 commit comments

Comments
 (0)