AI crash debugging for Python in production
Project description
ThinkingSDK
AI crash debugging for Python in production. One line catches every uncaught exception in your live app, ships it to ThinkingSDK's analysis service, and gives you back the root cause and a concrete fix, not just another stack trace.
pip install thinkingsdk
import thinkingsdk as thinking
thinking.start(api_key="sk_live_...") # the whole integration
That is it. Deploy. When your app throws an unhandled exception, in a request handler, a worker thread, or a background job, ThinkingSDK captures it with full context, analyzes it, and shows you the diagnosis in your dashboard at thinkingsdk.ai. Get your project key there.
What you get for every crash
- Root cause in plain language. Why it happened, grounded in the actual stack and the local variables at each frame, not just where it threw.
- A concrete fix. The specific code change to make, not a generic "handle the exception."
- Full context. Stack trace, locals per frame, and the execution path into the failure.
- Smart grouping. Repeated crashes are deduplicated, so one real bug is one issue, not a thousand alerts.
How it works
ThinkingSDK installs exception hooks at startup:
sys.excepthookfor the main thread andthreading.excepthookfor worker threads, so no uncaught exception escapes unseen.- Captured events are sent asynchronously in batches on a background sender, off your request path, so reporting a crash never blocks or slows the failing request.
- Only runtime event data leaves your process. Your source code is never uploaded.
Deeper call tracing and performance capture are available via config, off by default to keep overhead near zero.
Performance
ThinkingSDK is built to stay off your application's hot path. The capture path is cheap and bounded; the network and the AI analysis happen elsewhere. What makes that true, in the client itself:
- Background daemon thread, sends off your request path; capture just enqueues in microseconds.
- Bounded ring buffer (
deque(maxlen=…)), drops oldest when full instead of back-pressuring, so a flood can't stall your app or grow memory. - Batching (50 events, or ~2s), flat network cost, not one request per event.
- Circuit breaker, pauses sending after repeated backend failures, so a down service can't become retry pressure on you.
- Bounded retries + exponential backoff + hard request timeout, all confined to the background thread.
- Priority sampling, exceptions/errors always captured, routine events sampled by rate.
- Call-stack dedup, a hot error loop collapses to one analyzed issue, not thousands of sends.
- Idle-until-throw hooks,
excepthookadds no per-call/per-line cost on the happy path; deeper tracing is opt-in.
Framework and library integrations
Awareness for the stack you already run:
- Web: FastAPI, Flask, Django
- Data: SQLAlchemy, psycopg2, PyMongo, Redis
- Standard library: logging
Production example (FastAPI)
import thinkingsdk as thinking
from fastapi import FastAPI
thinking.start(api_key="sk_live_...")
app = FastAPI()
@app.get("/orders/{order_id}")
def get_order(order_id: str):
# If this raises in production, ThinkingSDK captures it with the request
# context and returns an AI root cause plus a fix in your dashboard.
return load_order(order_id)
When load_order blows up on a malformed id, you do not get a bare KeyError buried in your logs. You get:
KeyError in get_order -> load_order at order_store.py:42
Root cause: load_order indexes self._orders[order_id] directly, but order_id
arrives from the URL unvalidated, so any unknown id raises KeyError instead of
returning a 404.
Suggested fix:
order = self._orders.get(order_id)
if order is None:
raise HTTPException(status_code=404, detail="order not found")
return order
Configuration
thinking.start() accepts:
api_key: your project key from thinkingsdk.aiserver_url: defaults to the hosted service (https://api.thinkingsdk.ai); point it at your own deployment to self hostconfig: a dict of tuning options
thinking.start(
api_key="sk_live_...",
config={
"capture_exceptions": True,
"capture_performance": False,
"sample_rate": 1.0, # e.g. 0.1 to sample 10% on a high traffic service
},
)
Environment variables
export THINKINGSDK_API_KEY=sk_live_...
export THINKINGSDK_SERVER_URL=https://api.thinkingsdk.ai # optional override
Self hosting
The analysis service (the AI engine and dashboard) runs as a separate component. To use your own instead of the hosted service, point server_url at your deployment. See thinkingsdk.ai for details.
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file thinkingsdk-0.1.0.tar.gz.
File metadata
- Download URL: thinkingsdk-0.1.0.tar.gz
- Upload date:
- Size: 95.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f77c555f9c8a1982ce22be24d1b2a6f1137b6d9694f8f5c125b9f4f9ad8e60dc
|
|
| MD5 |
25240fce58968cef4e6ab4b89e430c95
|
|
| BLAKE2b-256 |
9e26b81c31482678d33d11cb317ec3b195bc41c7cd31696da0901246b5381a18
|
File details
Details for the file thinkingsdk-0.1.0-py3-none-any.whl.
File metadata
- Download URL: thinkingsdk-0.1.0-py3-none-any.whl
- Upload date:
- Size: 92.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
59bde66be69c536fe70c5aaeb777c043b86c531befc2ef49bc45966583786d72
|
|
| MD5 |
0b2834643225848e5ddf0ed4180b9c1f
|
|
| BLAKE2b-256 |
04c952bf331c24ccef714191c15e47d946b5c74f6206d67013856a08c39039b6
|