streamctx 0.3.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: streamctx
|
|
3
|
+
Version: 0.3.0
|
|
4
|
+
Summary: Context health monitoring for AI agents — detect poisoning, drift, loops
|
|
5
|
+
Home-page: https://github.com/streamctx/streamctx
|
|
6
|
+
Author: Sneh R Joshi
|
|
7
|
+
Author-email: joshisneh51@gmail.com
|
|
8
|
+
Keywords: llm,ai,agent,context,monitoring,observability,openai,anthropic,token,checkpoint,compression,self-healing
|
|
9
|
+
Classifier: Development Status :: 4 - Beta
|
|
10
|
+
Classifier: Intended Audience :: Developers
|
|
11
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
12
|
+
Classifier: Programming Language :: Python :: 3
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
17
|
+
Classifier: Topic :: Software Development :: Libraries
|
|
18
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
19
|
+
Requires-Python: >=3.9
|
|
20
|
+
Description-Content-Type: text/markdown
|
|
21
|
+
License-File: LICENSE
|
|
22
|
+
Requires-Dist: rich>=13.0.0
|
|
23
|
+
Provides-Extra: openai
|
|
24
|
+
Requires-Dist: openai>=1.0.0; extra == "openai"
|
|
25
|
+
Provides-Extra: anthropic
|
|
26
|
+
Requires-Dist: anthropic>=0.25.0; extra == "anthropic"
|
|
27
|
+
Provides-Extra: all
|
|
28
|
+
Requires-Dist: openai>=1.0.0; extra == "all"
|
|
29
|
+
Requires-Dist: anthropic>=0.25.0; extra == "all"
|
|
30
|
+
Dynamic: author
|
|
31
|
+
Dynamic: author-email
|
|
32
|
+
Dynamic: classifier
|
|
33
|
+
Dynamic: description
|
|
34
|
+
Dynamic: description-content-type
|
|
35
|
+
Dynamic: home-page
|
|
36
|
+
Dynamic: keywords
|
|
37
|
+
Dynamic: license-file
|
|
38
|
+
Dynamic: provides-extra
|
|
39
|
+
Dynamic: requires-dist
|
|
40
|
+
Dynamic: requires-python
|
|
41
|
+
Dynamic: summary
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
# StreamCtx 🧠
|
|
45
|
+
|
|
46
|
+
**Your AI agent is silently corrupting its own context. StreamCtx detects it — and fixes it.**
|
|
47
|
+
|
|
48
|
+
## Install
|
|
49
|
+
|
|
50
|
+
pip install streamctx
|
|
51
|
+
|
|
52
|
+
## 2-Line Setup
|
|
53
|
+
|
|
54
|
+
import streamctx
|
|
55
|
+
streamctx.start() # patches OpenAI + Anthropic automatically
|
|
56
|
+
|
|
57
|
+
---
|
|
58
|
+
|
|
59
|
+
## The Problem Nobody Talks About
|
|
60
|
+
|
|
61
|
+
You ship an AI agent. It works perfectly in demos.
|
|
62
|
+
|
|
63
|
+
Then in production:
|
|
64
|
+
- Agent gets stuck repeating the same failed action 58 times
|
|
65
|
+
- Context from step 3 contradicts context from step 7
|
|
66
|
+
- Agent hallucinates a tool call, writes it to memory, references it forever
|
|
67
|
+
- Your $0.50 task costs $50 because nobody set a limit
|
|
68
|
+
|
|
69
|
+
Every LLM observability tool tracks tokens. Nobody tracks context health.
|
|
70
|
+
|
|
71
|
+
Until now.
|
|
72
|
+
|
|
73
|
+
---
|
|
74
|
+
|
|
75
|
+
## What StreamCtx Does
|
|
76
|
+
|
|
77
|
+
### 1. Context Poison Detection
|
|
78
|
+
|
|
79
|
+
result = streamctx.scan(messages)
|
|
80
|
+
print(result["health_score"]) # 25/100
|
|
81
|
+
print(result["warnings"])
|
|
82
|
+
# ⚠️ Repeated errors: 'failed' 4x — agent stuck in loop
|
|
83
|
+
# 🚨 Context severely poisoned — resume from checkpoint
|
|
84
|
+
|
|
85
|
+
### 2. Context Diff — See Exactly What Changed
|
|
86
|
+
|
|
87
|
+
diff = streamctx.context_diff(step3_msgs, step7_msgs, step_a=3, step_b=7)
|
|
88
|
+
print(diff["summary"])
|
|
89
|
+
# ⚠️ System prompt REMOVED — agent lost instructions
|
|
90
|
+
# ⚠️ Contradiction: 'use gpt' added but 'use claude' removed
|
|
91
|
+
# Drift Score: 50/100
|
|
92
|
+
|
|
93
|
+
### 3. Auto-Checkpoint + Resume
|
|
94
|
+
|
|
95
|
+
session_id = streamctx.get_session_id()
|
|
96
|
+
messages = streamctx.resume(session_id)
|
|
97
|
+
# Pick up exactly where agent left off
|
|
98
|
+
|
|
99
|
+
### 4. 50% Token Compression
|
|
100
|
+
|
|
101
|
+
result = streamctx.compress(messages, max_tokens=2000)
|
|
102
|
+
# 140 tokens → 70 tokens (50% reduction)
|
|
103
|
+
|
|
104
|
+
### 5. Self-Healing
|
|
105
|
+
|
|
106
|
+
stats = streamctx.healing_stats()
|
|
107
|
+
# failures: 1, recoveries: 1
|
|
108
|
+
|
|
109
|
+
### 6. Full Session Report
|
|
110
|
+
|
|
111
|
+
streamctx.report()
|
|
112
|
+
streamctx.stop()
|
|
113
|
+
|
|
114
|
+
---
|
|
115
|
+
|
|
116
|
+
## Feature Comparison
|
|
117
|
+
|
|
118
|
+
Feature | StreamCtx | Langfuse | LangSmith | Mem0
|
|
119
|
+
---------------------|-----------|----------|-----------|-----
|
|
120
|
+
Token tracking | YES | YES | YES | NO
|
|
121
|
+
Cost estimation | YES | YES | YES | NO
|
|
122
|
+
Context Poison Det. | YES | NO | NO | NO
|
|
123
|
+
Context Diff | YES | NO | NO | NO
|
|
124
|
+
Auto-checkpoint | YES | NO | NO | NO
|
|
125
|
+
50% Compression | YES | NO | NO | NO
|
|
126
|
+
Self-healing | YES | NO | NO | NO
|
|
127
|
+
Zero config | YES | NO | NO | NO
|
|
128
|
+
Open source | YES | YES | NO | NO
|
|
129
|
+
|
|
130
|
+
---
|
|
131
|
+
|
|
132
|
+
## Quick Start
|
|
133
|
+
|
|
134
|
+
import streamctx
|
|
135
|
+
from openai import OpenAI
|
|
136
|
+
|
|
137
|
+
streamctx.start()
|
|
138
|
+
client = OpenAI()
|
|
139
|
+
|
|
140
|
+
messages = [{"role": "user", "content": "Hello!"}]
|
|
141
|
+
response = client.chat.completions.create(
|
|
142
|
+
model="gpt-4o-mini",
|
|
143
|
+
messages=messages,
|
|
144
|
+
)
|
|
145
|
+
|
|
146
|
+
result = streamctx.scan(messages)
|
|
147
|
+
print(result["health_score"])
|
|
148
|
+
print(result["recommendation"])
|
|
149
|
+
|
|
150
|
+
streamctx.report()
|
|
151
|
+
streamctx.stop()
|
|
152
|
+
|
|
153
|
+
---
|
|
154
|
+
|
|
155
|
+
## API Reference
|
|
156
|
+
|
|
157
|
+
streamctx.start() # start tracking
|
|
158
|
+
streamctx.stop() # stop tracking
|
|
159
|
+
streamctx.report() # print full report
|
|
160
|
+
streamctx.wrap(client) # manually wrap client
|
|
161
|
+
|
|
162
|
+
streamctx.scan(messages) # context health score
|
|
163
|
+
streamctx.context_diff(a, b) # compare two steps
|
|
164
|
+
|
|
165
|
+
streamctx.checkpoint() # save checkpoint
|
|
166
|
+
streamctx.resume(session_id) # resume from checkpoint
|
|
167
|
+
streamctx.get_session_id() # current session ID
|
|
168
|
+
|
|
169
|
+
streamctx.compress(messages) # 50% token compression
|
|
170
|
+
streamctx.healing_stats() # self-healing stats
|
|
171
|
+
|
|
172
|
+
---
|
|
173
|
+
|
|
174
|
+
## Why StreamCtx?
|
|
175
|
+
|
|
176
|
+
Most tools answer: "How many tokens did I use?"
|
|
177
|
+
|
|
178
|
+
StreamCtx answers: "Why is my agent broken — and how do I fix it?"
|
|
179
|
+
|
|
180
|
+
---
|
|
181
|
+
|
|
182
|
+
## Roadmap
|
|
183
|
+
|
|
184
|
+
DONE:
|
|
185
|
+
- Token tracking + cost estimation
|
|
186
|
+
- Context poison detection
|
|
187
|
+
- Context diff + drift scoring
|
|
188
|
+
- Auto-checkpoint + resume
|
|
189
|
+
- 50% token compression
|
|
190
|
+
- Self-healing engine
|
|
191
|
+
|
|
192
|
+
COMING:
|
|
193
|
+
- Context budget manager (v0.4.0)
|
|
194
|
+
- Visual dashboard
|
|
195
|
+
- Multi-agent support
|
|
196
|
+
|
|
197
|
+
---
|
|
198
|
+
|
|
199
|
+
## License
|
|
200
|
+
|
|
201
|
+
MIT - Sneh R Joshi
|
|
202
|
+
|
|
203
|
+
Built by a solo founder who got tired of AI agents silently going insane.
|
|
204
|
+
|
|
205
|
+
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
streamctx-0.3.0.dist-info/licenses/LICENSE,sha256=8FtXqf8-wMm6B2MfZHtECsBr1k6_F09m7CP_jEhD4sQ,1090
|
|
2
|
+
streamctx-0.3.0.dist-info/METADATA,sha256=qoc2PIc1-cuaZHSnyS9BuoQEVWB4dAIoxB_SMjv6Mn0,5718
|
|
3
|
+
streamctx-0.3.0.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
|
|
4
|
+
streamctx-0.3.0.dist-info/top_level.txt,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
|
|
5
|
+
streamctx-0.3.0.dist-info/RECORD,,
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Sneh R Joshi
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|