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.2.1.tar.gz (176.3 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.2.1-cp310-abi3-win_arm64.whl (3.9 MB view details)

Uploaded CPython 3.10+Windows ARM64

deepstrike-0.2.1-cp310-abi3-win_amd64.whl (4.0 MB view details)

Uploaded CPython 3.10+Windows x86-64

deepstrike-0.2.1-cp310-abi3-musllinux_1_2_x86_64.whl (4.3 MB view details)

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

deepstrike-0.2.1-cp310-abi3-musllinux_1_2_aarch64.whl (4.2 MB view details)

Uploaded CPython 3.10+musllinux: musl 1.2+ ARM64

deepstrike-0.2.1-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (4.1 MB view details)

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

deepstrike-0.2.1-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (4.0 MB view details)

Uploaded CPython 3.10+manylinux: glibc 2.17+ ARM64

deepstrike-0.2.1-cp310-abi3-macosx_11_0_arm64.whl (4.0 MB view details)

Uploaded CPython 3.10+macOS 11.0+ ARM64

deepstrike-0.2.1-cp310-abi3-macosx_10_12_x86_64.whl (4.0 MB view details)

Uploaded CPython 3.10+macOS 10.12+ x86-64

File details

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

File metadata

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

File hashes

Hashes for deepstrike-0.2.1.tar.gz
Algorithm Hash digest
SHA256 a38a22c1a65f56464f6c5e8e8ac1b7b0e641b91373e9add2ad1e54d8bb2e9d47
MD5 9dacbf771ced496d681480f61b769e4a
BLAKE2b-256 346a56d69be83022bf70fa2b102fb44bea3f505a7c32562478c74c91f506d8f8

See more details on using hashes here.

Provenance

The following attestation bundles were made for deepstrike-0.2.1.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.2.1-cp310-abi3-win_arm64.whl.

File metadata

  • Download URL: deepstrike-0.2.1-cp310-abi3-win_arm64.whl
  • Upload date:
  • Size: 3.9 MB
  • 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.2.1-cp310-abi3-win_arm64.whl
Algorithm Hash digest
SHA256 5753199a93bbd813a6a9108609f7d5817b7bc954123449bd2bbacd3a77572daa
MD5 11e0cb04a2934d03043436b5798245fe
BLAKE2b-256 56fcf9f425446ea44aac5d1095acc98db599b0deb71f5900df04e8d2d705504a

See more details on using hashes here.

Provenance

The following attestation bundles were made for deepstrike-0.2.1-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.2.1-cp310-abi3-win_amd64.whl.

File metadata

  • Download URL: deepstrike-0.2.1-cp310-abi3-win_amd64.whl
  • Upload date:
  • Size: 4.0 MB
  • 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.2.1-cp310-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 cda9ced245875088050b0b98bfb302a9dde0ae2115b00038a7e331ebda7fa7fd
MD5 3e3789c525ba5265aeb9d9064d7ef27e
BLAKE2b-256 1413ab67ce046e00d4e117c95e2f674215c741aba558a3d0eb586affe003126c

See more details on using hashes here.

Provenance

The following attestation bundles were made for deepstrike-0.2.1-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.2.1-cp310-abi3-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for deepstrike-0.2.1-cp310-abi3-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 dc2520689abf0b2c1b593c70adb86b54b3880a21571b299dfcf19996b0fcee82
MD5 c8ea3439dca214dbeeeb7febcc925734
BLAKE2b-256 b526397467e84f21b230789d9bbca4dcdc797e903d247cc9edacbdf0e3d4120c

See more details on using hashes here.

Provenance

The following attestation bundles were made for deepstrike-0.2.1-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.2.1-cp310-abi3-musllinux_1_2_aarch64.whl.

File metadata

File hashes

Hashes for deepstrike-0.2.1-cp310-abi3-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 9203ebd97123eccfcc9efc6a88da12fd8721bbf78bf29ea3967b96583f524742
MD5 cfaad7f62bc7e5dae73a72e2c83710b5
BLAKE2b-256 31696acda7cd73ab46763aa6ff1532f85b0b3659c21a4ca93e57e5f3452cf4f6

See more details on using hashes here.

Provenance

The following attestation bundles were made for deepstrike-0.2.1-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.2.1-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for deepstrike-0.2.1-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 6caf28d794226f4c68bf1dda50a75ab6afeb72c3764916656d434c4408fc6ff1
MD5 55fc39853f17b697b3f3ad13d096afe9
BLAKE2b-256 ca9f06ccfd5c69ce3f7e611df2fd5139e7866ffbec16ec2a47962f40ccee4f06

See more details on using hashes here.

Provenance

The following attestation bundles were made for deepstrike-0.2.1-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.2.1-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for deepstrike-0.2.1-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 fb9bb747569e04b4df3331a72469cacb5694a48aed3dc679ec6756dd2c2df8b1
MD5 98b0f008728340f1ca0139e9032ac784
BLAKE2b-256 c21662b7b5a4a31be4e10ab5b8d5fa8107477823e8073be1dc84ba031422bd9a

See more details on using hashes here.

Provenance

The following attestation bundles were made for deepstrike-0.2.1-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.2.1-cp310-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for deepstrike-0.2.1-cp310-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 2f4bc85501004eeecdc2498f110b8c01de43cc51b130a7155990c7dcf86273e0
MD5 902aa00885d29cf8e7719c0505ddbf23
BLAKE2b-256 ab6243dd2c48ac7bb9ace703515b6b9ce3e2a63b7f87cf9087b01f0d446e2fbd

See more details on using hashes here.

Provenance

The following attestation bundles were made for deepstrike-0.2.1-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.2.1-cp310-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for deepstrike-0.2.1-cp310-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 b223d9087ad0b8d49d4c8c5e79c0f8b9a0e591601931970dfcf94c9cdb917178
MD5 71dc063dd5d2f98030c1c4004251b5c2
BLAKE2b-256 8b3450058a28a5bb90c91adc4ef0904ac8b5620a8692c08c7befc777867eb008

See more details on using hashes here.

Provenance

The following attestation bundles were made for deepstrike-0.2.1-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