Skip to main content

Schift Observer Python

A thin, Apache-2.0 instrumentation SDK for the private hosted Schift Observer service. Python 3.11+, no runtime dependencies. No local Context State Management engine, selection algorithm, Agent loop, replay store, evaluation engine, or subprocess.

from schift_observer import ObserverClient, ReActAdapter

client = ObserverClient()  # reads SCHIFT_OBSERVER_API_KEY
run = client.start_run(agentId="support", sessionId="session-1", model="model", provider="custom")
run.record_candidate(srn="srn:document:policy", contextManagementCallId="call-1")
run.record_selection(selected=True, srn="srn:document:policy", contextManagementCallId="call-1")
run.record_assembly(contextManagementCallId="call-1", tokenUsage=120)
ReActAdapter(run).connector("drive.search", "connector-run-1", modelTurnId="turn-1")
run.end_run(status="completed")
client.close(timeout=5)

Configuration is {"schema":"schift.observer.config.v1","observer":{...}}. api_key_ref accepts env://UPPERCASE_NAME; project_id, sampling, retention, redaction and bounded batching/retry controls follow the shared JSON schema. endpoint defaults to the gateway, https://gw.schift.io/v1/observer/events, and also accepts https://api.schift.io/v1/observer/events so existing 0.1.x configurations keep working (exact match; nothing else). No custom transport or local-mode override is supported. Missing key creates no worker and stores no events. Any HTTP 401 or 403 (for example a revoked key, or an organization that is not enabled) stops delivery for the life of the process; health() then reports entitlement "revoked" and counts unauthorized drops. The server owns entitlements, usage, retention and evaluation decisions. Free usage, retention and prices are set by your account's plan and shown in the console and on the pricing page. When the organization has no free usage left and no prepaid credits, the server answers HTTP 402 and that batch is dropped as quota without a retry; ingestion resumes within 5 minutes of adding credits. last_receipt() returns a defensive copy of the last successfully enabled server receipt; disabled or revoked receipts stop delivery without being reported as accepted delivery.

Recording is synchronous in-memory work and never waits for HTTP. One daemon worker batches bounded events. Call flush(timeout=...) or close(timeout=...) for delivery at shutdown; they return false if the caller's wait expires. Python async applications use await client.aflush() / await client.aclose(); these stdlib wrappers offload the wait and do not block the event loop. HTTP timeouts bound socket operations and a monotonic deadline bounds streamed body reads (a blocking socket operation may overrun that deadline by one socket timeout); caller flush deadlines bound shutdown waiting. Delivery is best effort, with stable IDs across retries; hosted ingestion must deduplicate. Events accepted by the in-memory queue can be lost at abrupt process exit.

Metadata-only is the default and removes payload/reason. redaction="redacted" requires a synchronous sanitizer= callback; exceptions or invalid output drop that event. redaction="full_opt_in" explicitly consents to payload capture. All modes strip credential-shaped fields and embedded secrets before queueing. Sanitizers execute on the recording thread and must be cheap; network work belongs in the customer's Agent, not in a sanitizer. health() matches the TypeScript fields: hosted, degraded, entitlement, queuedCount, deliveredCount, dropReasons, and closed, plus the Python missing-reference diagnostic. It never exposes raw errors or credentials.

ReActAdapter, CustomAgentAdapter, OpenAICompatibleAdapter, LangChainAdapter and LangGraphAdapter expose hooks only. Framework callbacks keep nested run IDs but do not treat arbitrary chain execution as Context assembly. Use explicit record_assembly for actual assembly. The LangChain callback facade has no LangChain dependency; it accepts callback-manager flags and standard run kwargs.

LangChainAdapter records into the run you pass in, and your code owns that run's lifecycle, so one run can also carry your own ReAct, connector and cache records. Close it on every path: run.end_run(status="completed") on success and run.end_run(status="failed") when the chain raises; an unclosed run keeps its session running.

Feedback pruning (gateway endpoint, the default): a context_feedback_recorded event makes the server's judge decide whether each mutable item selected in the same session and run can be dropped; other block kinds are never judged, and items without captured text (payload.text/payload.content, or the feedback's payload.contexts) are recorded as no_content without judging. client.get_revisions(session_id) (or await client.aget_revisions(...)) returns the applied discards; leave those srns out of the next assembly and record context_excluded with transition="discard". Failures raise RevisionsError with a transport reason (disabled without a key).

Model callbacks project only standard response.generations[].message.usage_metadata.total_tokens into tokenUsage. All generations must provide valid nonnegative safe integers; missing or malformed usage is omitted. Completed callbacks are counted once. Tool callbacks use their tool run ID as correlationId and do not invent a modelTurnId. Retriever callbacks use searchOperationId. Message and tool content is never copied by these framework hooks, including when payload capture is explicitly enabled.

Metadata

Release files for schift-observer 0.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for schift-observer 0.3.0
File Size Uploaded Provenance Actions
schift_observer-0.3.0.tar.gz 19.3 kB Without provenance Details for schift_observer-0.3.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for schift-observer 0.3.0
File Interpreter ABI Platform Actions
schift_observer-0.3.0-py3-none-any.whl Python 3 none any Details for schift_observer-0.3.0-py3-none-any.whl

Total release size: 44.0 kB

Release files / schift_observer-0.3.0.tar.gz

Download URL schift_observer-0.3.0.tar.gz
Size 19.3 kB
Tags Source
SHA-256 checksum
How to use checksums
8024b44f04a6786a36542cdc62de1eec3d3651b5231d724943439621d2798a3a
BLAKE2b-256 checksum
How to use checksums
5d43bc1ae229ff93b57f831c70d57887a481b97496ecbe8aa245f4e5cc5b0f4e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.16

Release files / schift_observer-0.3.0-py3-none-any.whl

Download URL schift_observer-0.3.0-py3-none-any.whl
Size 24.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d1bf997f33370a66d86d87a2eafb4f8c194e21893f63d5e41852d0684d1e1bf2
BLAKE2b-256 checksum
How to use checksums
87bc817d1c9c41832ed679857ced12d2a1a4b2734dc2dbdab2de70d91ad2e385
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.16

Security for schift-observer 0.3.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.3.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page