Skip to main content

Kairos SDK — instrument autonomous systems in 3 lines

Project description

kairos-sdk (Python)

The flight recorder for autonomous operations.

Instrument any AI agent in 3 lines. Every prompt, decision, tool call, and failure — captured, replayable, and governable.

Install

pip install kairos-sdk

Optional — faster HTTP (recommended):

pip install kairos-sdk[http]

Quickstart

from kairos import create_kairos

kairos = create_kairos()

exec = kairos.execution(workflow_name="research-agent")

exec.set_prompt(user_prompt, model="claude-sonnet-4-6")
exec.tool_call("web_search", input={"query": query}, output=results, latency_ms=1200)
exec.decision("Selected most credible source", confidence=0.91)

exec.complete(output)

Open your Kairos dashboard to see the execution replay.

LangChain integration

from kairos import create_kairos

kairos = create_kairos()

class KairosCallbackHandler(BaseCallbackHandler):
    def __init__(self, exec):
        self.exec = exec

    def on_llm_start(self, serialized, prompts, **kwargs):
        self.exec.set_prompt(prompts[0])

    def on_tool_start(self, serialized, input_str, **kwargs):
        self._tool_start = time.time()
        self._tool_name = serialized.get("name", "tool")
        self.exec._emit("tool_called", {"name": self._tool_name, "input": input_str})

    def on_tool_end(self, output, **kwargs):
        latency = int((time.time() - self._tool_start) * 1000)
        self.exec._emit("tool_completed", {"name": self._tool_name, "output": str(output)}, latency_ms=latency)

    def on_chain_end(self, outputs, **kwargs):
        self.exec.complete(outputs.get("output"))

exec = kairos.execution(workflow_name="langchain-agent")
handler = KairosCallbackHandler(exec)
agent.run(query, callbacks=[handler])

API

create_kairos(base_url?, debug?)

kairos = create_kairos(
    base_url="https://kairos-production-64c5.up.railway.app",  # default
    debug=False,
)

kairos.execution(workflow_name?, agent_id?)

Returns a KairosExecution builder.

Method Description
.set_prompt(prompt, model?) Record the prompt sent to the model
.set_model(model) Set the model name
.set_tokens(prompt_tokens, completion_tokens) Set token counts
.set_cost(usd) Set cost in USD
.tool_call(name, input?, output?, latency_ms?) Record a tool call
.decision(reasoning, confidence?) Record a model decision
.policy_check(policy, result) Record a policy check
.memory_write(key, value?) Record a memory write
.memory_read(key, value?) Record a memory read
.retry(attempt, reason?) Record a retry
.event(type, payload?) Emit any custom event
.complete(output?) Finish execution as completed
.fail(error) Finish execution as failed

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

kairos_trace-0.1.1.tar.gz (3.5 kB view details)

Uploaded Source

Built Distribution

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

kairos_trace-0.1.1-py3-none-any.whl (4.2 kB view details)

Uploaded Python 3

File details

Details for the file kairos_trace-0.1.1.tar.gz.

File metadata

  • Download URL: kairos_trace-0.1.1.tar.gz
  • Upload date:
  • Size: 3.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.10

File hashes

Hashes for kairos_trace-0.1.1.tar.gz
Algorithm Hash digest
SHA256 813132542e50612d2a920c146b14c9c4a25c289fd3071ed0368238b9947b67cc
MD5 b8370936373d436ec2ed5c32a27b723b
BLAKE2b-256 44901a859ef42d5f99449204c7f2b5918ad1a189caaae1a9425f6c4d91be34e1

See more details on using hashes here.

File details

Details for the file kairos_trace-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: kairos_trace-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 4.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.10

File hashes

Hashes for kairos_trace-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 5a355fc0c4477f2bbab5f190a2d77fa3bc0ad5e423434bd3fce9020d5718e619
MD5 f8d06ea7b2e3b8b5543586382b31efa3
BLAKE2b-256 3645614250ff3dc51901ccff58948bb000072498e8f52190afe005cd4ecf3313

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