Skip to content

Commit 293752c

Browse files
author
Latence AI
committed
pivot: retrieval-only SDK — disable code(), session, memory APIs
- GroundingClient.code() raises NotImplementedError - MemoryClient, TraceSession, session() raise NotImplementedError - Remove memory_state/memory_policy from rag() params - Hide memory/code response fields with exclude=True - Update README and docs for retrieval-only product
1 parent 9942988 commit 293752c

11 files changed

Lines changed: 84 additions & 352 deletions

File tree

‎README.md‎

Lines changed: 24 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@
55
<h1 align="center">Latence TRACE Python SDK</h1>
66

77
<p align="center">
8-
Real-time protection for AI agents. Verify answers, redact private data,
9-
reduce wasted context, and log decisions without replacing your stack.
8+
Stateless retrieval quality for knowledge agents. Groundedness verification,
9+
context compression, privacy redaction, and context utilization scoring
10+
— without replacing your stack.
1011
</p>
1112

1213
<p align="center">
@@ -44,26 +45,24 @@ print(score.runtime_decision)
4445

4546
## Why This Exists
4647

47-
Agents are moving from demos into real workflows. That means private data,
48-
unsupported answers, prompt attacks, tool drift, and wasted memory are no longer
49-
abstract research problems. They become support escalations, broken automations,
50-
audit gaps, token waste, and user trust issues.
48+
Knowledge agents are moving from demos into real workflows. That means private
49+
data, unsupported answers, and wasted context are no longer abstract research
50+
problems. They become support escalations, audit gaps, token waste, and user
51+
trust issues.
5152

52-
TRACE is the protection layer that sits next to your RAG pipeline, coding agent,
53-
or tool-using workflow. Your agent keeps running. TRACE checks the turn and
54-
returns evidence plus a decision your application can route.
53+
TRACE is the retrieval quality layer that sits next to your RAG pipeline or
54+
knowledge workflow. Your agent keeps running. TRACE checks the turn and returns
55+
evidence plus a decision your application can route.
5556

5657
## What TRACE Does
5758

5859
TRACE is intentionally small at the SDK layer. The heavy work lives in your
5960
TRACE runtime deployment; this package is the thin Python interface.
6061

61-
- Verify RAG answers against retrieved context.
62-
- Score coding-agent output against codebase context.
63-
- Redact private data before it spreads through tools, logs, or prompts.
64-
- Compress and repair long-running context with InfiniMem.
65-
- Roll up an agent session into review-ready signals.
66-
- Persist caller-carried state without forcing sticky server sessions.
62+
- **Groundedness** — verify RAG answers against retrieved context.
63+
- **Compression** — reduce long context to what matters.
64+
- **Privacy** — redact private data before it spreads through tools, logs, or prompts.
65+
- **Context utilization** — score which retrieved chunks are actually used.
6766

6867
## Proof Points
6968

@@ -72,17 +71,12 @@ microbenchmarks. See the linked artifacts for full context.
7271

7372
- Grounding: local managed-runtime 360 reported `1.00` AUROC for grounded vs.
7473
ungrounded RAG cases.
75-
- Coding agents: local 360 reported `1.00` AUROC for code phantom detection.
76-
- Wasted context: held-out unused-context classification reported `1.00`
74+
- Context utilization: held-out unused-context classification reported `1.00`
7775
precision and `1.00` recall.
78-
- Latency: local concurrency burst reported about `368 ms` RAG p95 and
79-
`334 ms` code p95 in the managed-runtime proof.
76+
- Latency: local concurrency burst reported about `368 ms` RAG p95 in the
77+
managed-runtime proof.
8078
- Privacy: redaction returns labels, offsets, scores, redacted output, entity
8179
counts, and timings for logging-ready GDPR workflows.
82-
- Memory: InfiniMem is designed for up to `90%` context reduction while keeping
83-
hot context available to the agent.
84-
- Guard checks: Prompt Guard warmup proved `torch.compile` enabled on CUDA in
85-
the runtime proof.
8680

8781
Evidence:
8882

@@ -118,14 +112,10 @@ export LATENCE_TRACE_URL="https://your-trace-endpoint.example.com"
118112

119113
The SDK mirrors the TRACE product API directly:
120114

121-
- Privacy: `client.privacy.redact(...)`
122115
- RAG grounding: `client.grounding.rag(...)`
123-
- Code grounding: `client.grounding.code(...)`
124116
- Text compression: `client.compression.text(...)`
125117
- Message compression: `client.compression.messages(...)`
126-
- Memory update: `client.memory.step(...)`
127-
- Stateless rollup: `client.rollup(...)`
128-
- Caller-carried sessions: `client.session(...)`
118+
- Privacy: `client.privacy.redact(...)`
129119

130120
`Latence` is synchronous. `AsyncLatence` exposes the same surface for asyncio
131121
services.
@@ -157,21 +147,6 @@ if score.risk_band.value != "green":
157147

158148
Example: [RAG grounding with guard checks](examples/rag_grounding_guard.py)
159149

160-
### Coding Agents
161-
162-
Use TRACE when an agent explains, edits, or reasons over code.
163-
164-
```python
165-
score = trace.grounding.code(
166-
query="Does this patch add retry handling?",
167-
response_text=agent_answer,
168-
raw_context=code_context,
169-
extra={"response_language_hint": "python"},
170-
)
171-
```
172-
173-
Example: [Code grounding](examples/code_grounding.py)
174-
175150
### Privacy
176151

177152
Use TRACE before customer data enters prompts, tools, traces, or logs.
@@ -187,7 +162,7 @@ print(redacted.unique_labels)
187162

188163
Example: [Privacy redaction](examples/privacy_redact.py)
189164

190-
### Compression And Memory
165+
### Compression
191166

192167
Use TRACE when long-running workflows start dragging dead context forward.
193168

@@ -198,51 +173,16 @@ compressed = trace.compression.text(
198173
)
199174
```
200175

201-
```python
202-
memory = trace.memory.step(
203-
turn_text="User asked for manual refund approval.",
204-
prior_memory_state=current_state,
205-
)
206-
current_state = memory.next_memory_state
207-
```
208-
209-
Examples: [Compression](examples/compression.py), [Memory step](examples/memory_step.py)
210-
211-
### Sessions
212-
213-
TRACE runtimes can stay stateless while the SDK carries state for your agent.
214-
215-
```python
216-
from latence import FileSessionStorage, Latence
217-
218-
trace = Latence()
219-
session = trace.session(
220-
session_id="support-run-42",
221-
storage=FileSessionStorage(".trace-sessions"),
222-
)
223-
224-
session.event("tool", "loaded refund policy")
225-
session.memory_step(turn_text="Keep finance approval as required context.")
226-
score = session.rag(
227-
query="Can I promise the refund?",
228-
response_text="Yes, the refund is guaranteed in 48 hours.",
229-
raw_context="Refunds require manual finance approval.",
230-
)
231-
session.save()
232-
```
233-
234-
Docs: [Sessions](docs/sessions.md)
235-
Example: [Session facade](examples/session_facade.py)
176+
Example: [Compression](examples/compression.py)
236177

237178
## For Whom
238179

239180
TRACE is for teams building or operating:
240181

241182
- RAG products where unsupported answers are expensive.
242-
- Coding agents that need codebase-grounded reasoning over many steps.
243-
- Support agents that touch customer records and policies.
183+
- Knowledge agents that touch customer records and policies.
244184
- Legal, finance, healthcare, or regulated workflows that need evidence.
245-
- Internal agent platforms where observability, retries, and human review matter.
185+
- Internal platforms where observability, retries, and human review matter.
246186

247187
It is also useful for framework authors and platform teams that need one
248188
consistent protection API across LangGraph, LangChain, LlamaIndex, n8n, Cursor,
@@ -281,10 +221,10 @@ async with AsyncLatence() as trace:
281221

282222
## Now What
283223

284-
If you are integrating TRACE into an agent:
224+
If you are integrating TRACE into a knowledge agent:
285225

286226
1. Run the [quickstart](docs/quickstart.md).
287-
2. Pick one product path: RAG, code, privacy, compression, memory, or session.
227+
2. Pick one product path: groundedness, compression, privacy, or context utilization.
288228
3. Add one route in your app for `green`, `amber`, and `red`.
289229
4. Log request ID, risk band, runtime decision, and redacted evidence.
290230
5. Replay a few real failures and tune your thresholds.

‎docs/quickstart.md‎

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -30,17 +30,6 @@ print(score.risk_band)
3030
print(score.runtime_decision)
3131
```
3232

33-
Use the `context_trust_enabled` flag when you need to disable the prompt-guard
34-
lane for a specific request. It is enabled by default.
35-
36-
```python
37-
score = trace.grounding.rag(
38-
query="Can this invoice be refunded?",
39-
response_text="Yes, it will be refunded within 48 hours.",
40-
raw_context="Refunds require manual finance approval.",
41-
context_trust_enabled=False,
42-
)
43-
```
4433

4534
## 2. Redact Private Data
4635

‎docs/sessions.md‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Sessions
22

3+
> **Deprecated.** Sessions have been deprecated. Use stateless `grounding.rag()` calls.
4+
5+
---
6+
37
TRACE compute deployments are stateless. Session state belongs to the caller so
48
the same deployment can serve RunPod, VPC, on-prem, and local agent workflows
59
without shared server storage.

‎examples/code_grounding.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# DEPRECATED: Code grounding has been removed from the product. Use rag grounding instead.
12
"""Score an agentic coding answer against code context."""
23

34
from latence import Latence

‎examples/memory_step.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# DEPRECATED: Memory API has been removed from the product.
12
"""Call the stateless InfiniMem update endpoint directly."""
23

34
from latence import Latence

‎pyproject.toml‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,11 @@ requires-python = ">=3.10"
1111
license = "MIT"
1212
authors = [{ name = "latence.ai", email = "support@latence.ai" }]
1313
keywords = [
14-
"agents",
1514
"groundedness",
1615
"hallucination-detection",
16+
"knowledge",
1717
"rag",
18+
"retrieval",
1819
"trace",
1920
]
2021
classifiers = [

‎src/latence/__init__.py‎

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,10 @@
1212
the runtime.
1313
"""
1414

15-
from latence.async_client import AsyncLatence, AsyncLatenceTraceClient, AsyncTraceSession
16-
from latence.client import Latence, LatenceTraceClient, TraceSession
15+
from latence.async_client import AsyncLatence, AsyncLatenceTraceClient # noqa: F401
16+
# from latence.async_client import AsyncTraceSession # removed: sessions API removed
17+
from latence.client import Latence, LatenceTraceClient # noqa: F401
18+
# from latence.client import TraceSession # removed: sessions API removed
1719
from latence.errors import (
1820
LatenceTraceAPIError,
1921
LatenceTraceAuthError,
@@ -39,7 +41,7 @@
3941
GroundednessRequest,
4042
GroundednessResponse,
4143
GroundednessScores,
42-
MemoryUpdateResponse,
44+
# MemoryUpdateResponse, # removed: memory API removed
4345
NLIVerdict,
4446
RiskBand,
4547
RollupDriftTrend,
@@ -52,19 +54,19 @@
5254
TokenScore,
5355
)
5456
from latence.sessions import (
55-
FileSessionStorage,
56-
InMemorySessionStorage,
57-
SessionStorage,
57+
# FileSessionStorage, # removed: sessions API removed
58+
# InMemorySessionStorage, # removed: sessions API removed
59+
# SessionStorage, # removed: sessions API removed
5860
TraceEvent,
59-
TraceSessionSnapshot,
61+
# TraceSessionSnapshot, # removed: sessions API removed
6062
)
6163

6264
__version__ = "0.1.6"
6365

6466
__all__ = [
6567
"AsyncLatence",
6668
"AsyncLatenceTraceClient",
67-
"AsyncTraceSession",
69+
# "AsyncTraceSession", # removed: sessions API removed
6870
"AttributionMode",
6971
"ComplianceCustomLabel",
7072
"ComplianceEntity",
@@ -75,14 +77,14 @@
7577
"ComplianceUsage",
7678
"CompressionResponse",
7779
"CorpusRoute",
78-
"FileSessionStorage",
80+
# "FileSessionStorage", # removed: sessions API removed
7981
"GroundednessNLIAtom",
8082
"GroundednessNLIClaim",
8183
"GroundednessNLIDiagnostics",
8284
"GroundednessRequest",
8385
"GroundednessResponse",
8486
"GroundednessScores",
85-
"InMemorySessionStorage",
87+
# "InMemorySessionStorage", # removed: sessions API removed
8688
"Latence",
8789
"LatenceTraceAPIError",
8890
"LatenceTraceAuthError",
@@ -91,7 +93,7 @@
9193
"LatenceTraceServerError",
9294
"LatenceTraceTimeout",
9395
"LatenceTraceValidationError",
94-
"MemoryUpdateResponse",
96+
# "MemoryUpdateResponse", # removed: memory API removed
9597
"NLIVerdict",
9698
"RiskBand",
9799
"RollupDriftTrend",
@@ -100,11 +102,11 @@
100102
"RuntimeDecision",
101103
"RuntimeEvidenceUnit",
102104
"RuntimeUnsupportedSpan",
103-
"SessionStorage",
105+
# "SessionStorage", # removed: sessions API removed
104106
"SupportUnit",
105107
"TokenScore",
106108
"TraceEvent",
107-
"TraceSession",
108-
"TraceSessionSnapshot",
109+
# "TraceSession", # removed: sessions API removed
110+
# "TraceSessionSnapshot", # removed: sessions API removed
109111
"__version__",
110112
]

0 commit comments

Comments
 (0)