Skip to main content

No project description provided

Project description

DeepStrike Python SDK

Runtime framework built on a Rust kernel. The kernel handles loop control, context compression, skill routing, governance, signal prioritization — the SDK handles all I/O.

Install

pip install deepstrike

Requires Python 3.10+. The Rust kernel is distributed as a pre-built wheel (deepstrike._kernel).


Quick start

import asyncio
from deepstrike import (
    InMemorySessionLog,
    LocalExecutionPlane,
    OpenAIProvider,
    RuntimeOptions,
    RuntimeRunner,
    collect_text,
    tool,
)

@tool
async def add(x: int, y: int) -> str:
    """Add two numbers."""
    return str(x + y)

plane = LocalExecutionPlane().register(add)
runner = RuntimeRunner(RuntimeOptions(
    provider=OpenAIProvider(api_key="sk-...", model="gpt-5-mini"),
    session_log=InMemorySessionLog(),
    execution_plane=plane,
    max_tokens=4096,
    max_turns=25,
))

asyncio.run(collect_text(runner.run_streaming("What is 17 + 28?")))
# => "45"

Streaming:

async for event in runner.run_streaming("Summarize README.md"):
    if isinstance(event, TextDelta):
        print(event.delta, end="", flush=True)
    elif isinstance(event, ToolCallEvent):
        print(f"\n[→ {event.name}]")
    elif isinstance(event, DoneEvent):
        print(f"\ndone in {event.iterations} turns ({event.status})")

Providers

Class Backend Notes
OpenAIProvider OpenAI API SSE tool-call accumulation
AnthropicProvider Anthropic API Native SSE, ThinkingDelta support
QwenProvider DashScope enable_thinking via extensions
DeepSeekProvider DeepSeek API Reasoner models strip tools automatically
MiniMaxProvider MiniMax API M1 reasoning via expose_reasoning
OllamaProvider Local Ollama http://localhost:11434 default
KimiProvider Moonshot API

All providers accept RetryConfig for exponential backoff and share a CircuitBreaker.


Runtime options

runner = RuntimeRunner(RuntimeOptions(
    provider=provider,
    session_log=InMemorySessionLog(),
    execution_plane=plane,
    max_tokens=4096,            # context window size
    max_turns=25,               # max turns (default 25)
    timeout_ms=60_000,          # timeout in ms (None = no limit)
    extensions={"temperature": 0.1},
    skill_dir="./skills",       # skill .md files directory
    knowledge_source=my_ks,     # KnowledgeSource implementation
    governance=gov,             # kernel Governance instance
    signal_source=gateway,      # SignalGateway or any SignalSource
    dream_store=my_store,       # DreamStore for long-term memory
    agent_id="my-agent",        # required with dream_store for memory meta-tool
))

Tools

from deepstrike import tool, read_file

plane.register(tool(name="search", description="Search.", parameters=schema)(my_fn))
plane.register(read_file)
plane.unregister("search")

Skills

Set skill_dir — the kernel auto-injects a skill meta-tool, and the LLM loads skills by name on demand.

runner = RuntimeRunner(RuntimeOptions(
    provider=provider,
    session_log=InMemorySessionLog(),
    execution_plane=plane,
    max_tokens=4096,
    max_turns=25,
    skill_dir="./skills",
))
---
name: summarize
description: Summarize text into 2-3 concise bullet points
when_to_use: When you need to condense long text
effort: 1
---
1. Identify the 2-3 most important points
2. Express each as a concise bullet

Knowledge

Implement KnowledgeSource — the kernel injects a knowledge meta-tool.

from deepstrike import KnowledgeSource

class VectorSearch(KnowledgeSource):
    async def init(self) -> None:
        await vector_db.connect()

    async def retrieve(self, query: str, top_k: int = 5) -> list[str]:
        return await vector_db.search(query, top_k)

runner = RuntimeRunner(RuntimeOptions(
    provider=provider,
    session_log=InMemorySessionLog(),
    execution_plane=plane,
    max_tokens=4096,
    max_turns=25,
    knowledge_source=VectorSearch(),
))

Memory

WorkingMemory (in-session scratch pad)

from deepstrike import WorkingMemory

mem = WorkingMemory()
mem.set("step", 1)
mem.get("step")  # 1
mem.clear()

DreamStore (long-term memory + dreaming pipeline)

from deepstrike import DreamStore

class MyStore(DreamStore):
    async def load_sessions(self, agent_id): ...
    async def load_memories(self, agent_id): ...
    async def commit(self, agent_id, result, existing): ...
    async def search(self, agent_id, query, top_k): ...
    async def save_session(self, data): ...

runner = RuntimeRunner(RuntimeOptions(
    provider=provider,
    session_log=InMemorySessionLog(),
    execution_plane=plane,
    max_tokens=4096,
    max_turns=25,
    dream_store=MyStore(),
    agent_id="my-agent",
))

# In-session: LLM calls memory(query) → DreamStore.search()
# Post-session: trigger memory consolidation
result = await runner.dream("my-agent", now_ms=int(time.time() * 1000))

Governance

SDK PermissionManager

from deepstrike import PermissionManager, PermissionMode

pm = PermissionManager(PermissionMode.DEFAULT)
pm.grant("fs", "read")
pm.revoke("db", "drop")
pm.evaluate("fs", "read")  # PermissionDecision(allowed=True, ...)

Kernel Governance (full pipeline)

from deepstrike import Governance

gov = Governance("allow")
gov.add_permission_rule("danger.*", "deny")
gov.block_tool("rm_rf")
gov.set_rate_limit("api_call", max_calls=10, window_ms=60_000)

runner = RuntimeRunner(RuntimeOptions(
    provider=provider,
    session_log=InMemorySessionLog(),
    execution_plane=plane,
    max_tokens=4096,
    max_turns=25,
    governance=gov,
))
# Every tool call: Permission → Veto → RateLimit → Constraint → Audit

Signals

from deepstrike import SignalGateway, ScheduledPrompt, RuntimeSignal

gw = SignalGateway()

gw.schedule(ScheduledPrompt(goal="standup", run_at_ms=target_time))
gw.ingest(RuntimeSignal(kind="interrupt", payload={}, urgency="critical"))

runner = RuntimeRunner(RuntimeOptions(
    provider=provider,
    session_log=InMemorySessionLog(),
    execution_plane=plane,
    max_tokens=4096,
    max_turns=25,
    signal_source=gw,
))

runner.interrupt()  # direct interrupt
gw.destroy()

Harness (evaluation framework)

from deepstrike import SinglePassHarness, EvalLoopHarness, HarnessLoop, HarnessRequest

# 1. SinglePass — run once, always passes
outcome = await SinglePassHarness(runner).run(HarnessRequest(goal="Say hello"))

# 2. EvalLoop — retry until QualityGate passes
class ContainsHello(QualityGate):
    async def evaluate(self, request, outcome) -> bool:
        return "hello" in outcome.result.lower()

outcome = await EvalLoopHarness(runner, gate=ContainsHello(), max_attempts=3).run(req)

# 3. HarnessLoop — LLM-as-judge with feedback injection + skill extraction
loop = HarnessLoop(runner, eval_provider=eval_provider, max_attempts=3, skill_dir="./skills")
async for event in loop.run_streaming(HarnessRequest(goal="Write a haiku")):
    if event.type == "done":
        print(event.verdict.passed, event.verdict.feedback)

Stream events

Class Key fields
TextDelta delta
ThinkingDelta delta
ToolCallEvent id, name, arguments
ToolDeltaEvent call_id, name, delta, chunk?
ToolSuspendEvent call_id, name, suspension_id, payload?
ToolResultEvent call_id, content, is_error
DoneEvent iterations, total_tokens, status
ErrorEvent message

status: completed · max_turns · token_budget · timeout · user_abort · error

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

deepstrike-0.1.14.tar.gz (120.6 kB view details)

Uploaded Source

Built Distributions

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

deepstrike-0.1.14-cp310-abi3-win_arm64.whl (456.9 kB view details)

Uploaded CPython 3.10+Windows ARM64

deepstrike-0.1.14-cp310-abi3-win_amd64.whl (495.5 kB view details)

Uploaded CPython 3.10+Windows x86-64

deepstrike-0.1.14-cp310-abi3-musllinux_1_2_x86_64.whl (771.7 kB view details)

Uploaded CPython 3.10+musllinux: musl 1.2+ x86-64

deepstrike-0.1.14-cp310-abi3-musllinux_1_2_aarch64.whl (708.5 kB view details)

Uploaded CPython 3.10+musllinux: musl 1.2+ ARM64

deepstrike-0.1.14-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (559.5 kB view details)

Uploaded CPython 3.10+manylinux: glibc 2.17+ x86-64

deepstrike-0.1.14-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (531.3 kB view details)

Uploaded CPython 3.10+manylinux: glibc 2.17+ ARM64

deepstrike-0.1.14-cp310-abi3-macosx_11_0_arm64.whl (519.1 kB view details)

Uploaded CPython 3.10+macOS 11.0+ ARM64

deepstrike-0.1.14-cp310-abi3-macosx_10_12_x86_64.whl (549.0 kB view details)

Uploaded CPython 3.10+macOS 10.12+ x86-64

File details

Details for the file deepstrike-0.1.14.tar.gz.

File metadata

  • Download URL: deepstrike-0.1.14.tar.gz
  • Upload date:
  • Size: 120.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for deepstrike-0.1.14.tar.gz
Algorithm Hash digest
SHA256 06398e9c7bcf7d695dbc3d6be12956168bfeca13683d779d1a66e8f675ce3bde
MD5 8d751ac82649c701e22a15c603c31781
BLAKE2b-256 04392fc43a79eebbb76dfe83756867580a59b6f70ac0a99c7d4ab7e74319a50f

See more details on using hashes here.

Provenance

The following attestation bundles were made for deepstrike-0.1.14.tar.gz:

Publisher: release-python.yml on kongusen/deepstrike

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file deepstrike-0.1.14-cp310-abi3-win_arm64.whl.

File metadata

  • Download URL: deepstrike-0.1.14-cp310-abi3-win_arm64.whl
  • Upload date:
  • Size: 456.9 kB
  • Tags: CPython 3.10+, Windows ARM64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for deepstrike-0.1.14-cp310-abi3-win_arm64.whl
Algorithm Hash digest
SHA256 5724822fd328881c780f9f770eebeaf463171e305a80e3cb569e0a3291b7491c
MD5 5265ca57283f7d75aeb2e567693dfe58
BLAKE2b-256 9988491934ca9d8b5852f9a653b1d46fb3bb18d2485dbf017b8d4eef9226bc58

See more details on using hashes here.

Provenance

The following attestation bundles were made for deepstrike-0.1.14-cp310-abi3-win_arm64.whl:

Publisher: release-python.yml on kongusen/deepstrike

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file deepstrike-0.1.14-cp310-abi3-win_amd64.whl.

File metadata

  • Download URL: deepstrike-0.1.14-cp310-abi3-win_amd64.whl
  • Upload date:
  • Size: 495.5 kB
  • Tags: CPython 3.10+, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for deepstrike-0.1.14-cp310-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 9845cb437064c23b2db379a0482daee9e4c144a3f1def5b20626d898fb21c141
MD5 afd9947f8d9e997749638c0a3731d93d
BLAKE2b-256 2d9aa8a41a0f86cd000e3cc5f331402aedf3df8464d6efd90eceb26690642f34

See more details on using hashes here.

Provenance

The following attestation bundles were made for deepstrike-0.1.14-cp310-abi3-win_amd64.whl:

Publisher: release-python.yml on kongusen/deepstrike

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file deepstrike-0.1.14-cp310-abi3-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for deepstrike-0.1.14-cp310-abi3-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 169123f3813b36c079907f57568fc6502f8c523d1139658f08cc5e6999d0e6ea
MD5 b125bdef25bcd1d4c9f8228a0efa52ef
BLAKE2b-256 480699fed7bec5d5d88bfa20bcd0d69206c34bb6edb0b5a9ee7c809c51616690

See more details on using hashes here.

Provenance

The following attestation bundles were made for deepstrike-0.1.14-cp310-abi3-musllinux_1_2_x86_64.whl:

Publisher: release-python.yml on kongusen/deepstrike

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file deepstrike-0.1.14-cp310-abi3-musllinux_1_2_aarch64.whl.

File metadata

File hashes

Hashes for deepstrike-0.1.14-cp310-abi3-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 bff28599f030eaa83b7953f88801991045f0bee358d47a61d577cbc036fbbb54
MD5 e54a3246ba5d1dbe1fcee4bca5a29da1
BLAKE2b-256 f29048b78a90fc3735e0c1f930712a5695f63013a65c5d9a798c687c4c130ac5

See more details on using hashes here.

Provenance

The following attestation bundles were made for deepstrike-0.1.14-cp310-abi3-musllinux_1_2_aarch64.whl:

Publisher: release-python.yml on kongusen/deepstrike

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file deepstrike-0.1.14-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for deepstrike-0.1.14-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 4dc2eba26476c8b08b0600c1e4871e211ec4a08a0566923ccb8bf03b1b5e31cd
MD5 62e6d95a09a2ea8df4f207086e07d713
BLAKE2b-256 bedae70da4ea4d23add680d93deba97f86a9afd0aa318b1d5081ea87dd720c67

See more details on using hashes here.

Provenance

The following attestation bundles were made for deepstrike-0.1.14-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: release-python.yml on kongusen/deepstrike

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file deepstrike-0.1.14-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for deepstrike-0.1.14-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 20dc49577cf10238dbfda61d86e03add050a2e052536f9eebc0a34b7757f73e0
MD5 593514fe74b96fc5b556f13fc0e885dd
BLAKE2b-256 58eefe48bdf282a06f38883323701ca0ebb58c57023e417364a94f17331d5166

See more details on using hashes here.

Provenance

The following attestation bundles were made for deepstrike-0.1.14-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:

Publisher: release-python.yml on kongusen/deepstrike

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file deepstrike-0.1.14-cp310-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for deepstrike-0.1.14-cp310-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 94f75139ac1944c1fb0307201ea19af73c2b7c19aaf035eca680cc5d7dd84eda
MD5 2c433d71f97a6dd0e0fcc4b1b3ce3362
BLAKE2b-256 38c0ab60904d21a05285879bca1df930a7ee4f3cddba8aee94e340a737f9b845

See more details on using hashes here.

Provenance

The following attestation bundles were made for deepstrike-0.1.14-cp310-abi3-macosx_11_0_arm64.whl:

Publisher: release-python.yml on kongusen/deepstrike

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file deepstrike-0.1.14-cp310-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for deepstrike-0.1.14-cp310-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 00f490209a7c2e6c4a299ad1a338c3405ce41b93413c6054db389370cf8f86ed
MD5 1b685b428172d80e0835d2ed475d76fc
BLAKE2b-256 805b73fb8d8fdebd4d55a055129c69b6fd3076bf048183752ec6fc7fe4f77fa7

See more details on using hashes here.

Provenance

The following attestation bundles were made for deepstrike-0.1.14-cp310-abi3-macosx_10_12_x86_64.whl:

Publisher: release-python.yml on kongusen/deepstrike

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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