Skip to main content

One-line monitoring for any Python job, agent, or script. Decorate or wrap your code and StillRunning gets a ping on success/failure with duration, cost, tokens, and model.

Project description

stillrunning-sdk

Monitoring for any Python job, agent, or script, in one line.

Decorate or wrap your code and StillRunning gets a ping on success or failure with the run's duration, plus optional cost, tokens, and model. Get alerted the moment a cron job stops, an agent fails, or a script runs too long or costs too much, with no ping plumbing. Works with LangChain, CrewAI, agent scripts, Celery/RQ workers, and plain cron jobs.

pip install stillrunning-sdk

30-second quickstart

  1. Create a workflow at stillrunning.ai/app/new and copy its token.

  2. export STILLRUNNING_TOKEN=your_token_here

  3. Monitor your work:

    from stillrunning_sdk import StillRunning
    
    sr = StillRunning()  # reads STILLRUNNING_TOKEN
    
    @sr.monitor
    def nightly_job():
        ...
    

Every call to nightly_job is now timed and reported, success on return, failure on exception (re-raised untouched).

Three ways to use it

Decorator , monitor a function:

@sr.monitor
def sync_customers():
    ...

Context manager , attach AI metrics inside the block:

with sr.track() as run:
    result = call_agent(prompt)
    run.meta(tokens_in=result.usage.input, tokens_out=result.usage.output, model="gpt-4o")
    # model + tokens -> costUsd estimated automatically

Run a callable , inline:

answer = sr.run(lambda: call_agent(prompt), meta={"model": "claude-sonnet-4", "tokens_in": 1200})

Heartbeats and manual pings

For a cron job that just needs to say "I ran", or when you can't wrap the work:

sr.heartbeat()                          # bare success ping
sr.ping(event="start", traceId="...")   # low-level: success | fail | start | log

Cost estimation

Give model plus token counts and cost is estimated from a built-in pricing table (Claude / GPT / Gemini). It's approximate, it powers relative cost-anomaly detection and a ballpark spend figure. Pass an explicit cost_usd for exact accounting, or extend the table:

from stillrunning_sdk import register_model_pricing
register_model_pricing([(r"my-custom-model", (1.5, 6.0))])  # USD per 1M (input, output) tokens

Unknown models simply send no cost rather than a wrong one.

Grouping multi-step runs with with_trace

from stillrunning_sdk import StillRunning, with_trace
sr = StillRunning()

with with_trace():
    sr.run(plan_step)
    sr.run(execute_step)   # both pings share one trace_id

Configuration

StillRunning(
    token=None,        # defaults to env STILLRUNNING_TOKEN
    base_url="https://stillrunning.ai",
    timeout=3.0,       # seconds; bounds each ping so a slow StillRunning never hangs your job
    await_ping=True,   # False = fire-and-forget in a daemon thread (lowest latency)
    on_error=None,     # callable(Exception) -> observe ping delivery failures
    transport=None,    # custom transport (testing / non-urllib runtimes)
)

Monitoring never raises into your code: a failed ping routes to on_error and is otherwise swallowed.

Requirements

Python 3.9+. No runtime dependencies (uses the standard library).

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

stillrunning_sdk-0.1.0.tar.gz (17.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

stillrunning_sdk-0.1.0-py3-none-any.whl (10.3 kB view details)

Uploaded Python 3

File details

Details for the file stillrunning_sdk-0.1.0.tar.gz.

File metadata

  • Download URL: stillrunning_sdk-0.1.0.tar.gz
  • Upload date:
  • Size: 17.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.10 {"installer":{"name":"uv","version":"0.10.10","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for stillrunning_sdk-0.1.0.tar.gz
Algorithm Hash digest
SHA256 502c900a3a15ad1135039fbad81bd89d5d433eeff4ee67aea85cdc35a074de05
MD5 e8d0d400ec9ad23df857097e6c381d07
BLAKE2b-256 f2f8531e2502c4d6d4ea61e656db0d655b0a774230741470ee61f51e6a0771d3

See more details on using hashes here.

File details

Details for the file stillrunning_sdk-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: stillrunning_sdk-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 10.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.10 {"installer":{"name":"uv","version":"0.10.10","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for stillrunning_sdk-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 05573c9ab78b7446ba8b77b76e87065f1d701ccc96c39e6c1549432ffa3b031f
MD5 d1784e7f2a7bcea8d931e24e71f572cb
BLAKE2b-256 00bea84c6732acd52d4bdea852b4ab8f31121d26ab6d71894045105a679218d7

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page