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.16.tar.gz (123.2 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.16-cp310-abi3-win_arm64.whl (460.0 kB view details)

Uploaded CPython 3.10+Windows ARM64

deepstrike-0.1.16-cp310-abi3-win_amd64.whl (499.1 kB view details)

Uploaded CPython 3.10+Windows x86-64

deepstrike-0.1.16-cp310-abi3-musllinux_1_2_x86_64.whl (774.5 kB view details)

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

deepstrike-0.1.16-cp310-abi3-musllinux_1_2_aarch64.whl (711.9 kB view details)

Uploaded CPython 3.10+musllinux: musl 1.2+ ARM64

deepstrike-0.1.16-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (563.2 kB view details)

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

deepstrike-0.1.16-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (534.1 kB view details)

Uploaded CPython 3.10+manylinux: glibc 2.17+ ARM64

deepstrike-0.1.16-cp310-abi3-macosx_11_0_arm64.whl (522.2 kB view details)

Uploaded CPython 3.10+macOS 11.0+ ARM64

deepstrike-0.1.16-cp310-abi3-macosx_10_12_x86_64.whl (552.1 kB view details)

Uploaded CPython 3.10+macOS 10.12+ x86-64

File details

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

File metadata

  • Download URL: deepstrike-0.1.16.tar.gz
  • Upload date:
  • Size: 123.2 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.16.tar.gz
Algorithm Hash digest
SHA256 90454630a84e1905706f74602614622d2077a958717b236bb7bd229b27c2b56d
MD5 339b69b8ee0b8acf0c0064a8e513a379
BLAKE2b-256 ef4c752f4473fed48004d59472cec69b55ef9831d4327bd3cf9a9551900c7129

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: deepstrike-0.1.16-cp310-abi3-win_arm64.whl
  • Upload date:
  • Size: 460.0 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.16-cp310-abi3-win_arm64.whl
Algorithm Hash digest
SHA256 479c931043a287edb6136424a54741ae12e09da35a4c31227f59a1e1ec07bf43
MD5 ada0ea0f9d1623994391847f33642bf6
BLAKE2b-256 1147668877774d2b61f3f23d04c082b2738ce431e706a0860fda1bb4ec189f1f

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: deepstrike-0.1.16-cp310-abi3-win_amd64.whl
  • Upload date:
  • Size: 499.1 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.16-cp310-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 9244bcc0244fdd4e27191aaf89615f7be5a3080db0a086952f389cab5372f7d6
MD5 94a30316f510e5540fc54e416de9c0dc
BLAKE2b-256 be1a2f3e4f71e2b4296496226954179a40bb9915d226b6298fb973816637c841

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for deepstrike-0.1.16-cp310-abi3-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 b51aa989d1f766a86020be838ff713c1a005162a1c4785e164806d14f89080ba
MD5 00113e2381400fee4cd8a526d71bfd69
BLAKE2b-256 16e7258f65260bf60496cab1345fbaa2a603e01db51bb5552a78282057400bc3

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for deepstrike-0.1.16-cp310-abi3-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 25c31db3f55207ddc1f13ed1dbe011b0c530a4e4f7bd3b862662c1543c33d4b2
MD5 25f961921f4848238ca22c26a833dd7b
BLAKE2b-256 db67329ea2a8fafc9d8cff264f633e0c89f1f7608aec37b1b19caa2d26f28970

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for deepstrike-0.1.16-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 908fd65654e529d80c2d54cfc6c0b047cb4b9507c36d224e8e4af4dcbe62dd7c
MD5 cebb40da122a1c9315d62d33514c46e4
BLAKE2b-256 45cd05e57f973a0281d861764494eb348f548cd70cfae6107cc519873cac6f61

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for deepstrike-0.1.16-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 e6316f4042246f24d44346e3c1621e4b9b208ef93f4f5f5d92e57ada703d8997
MD5 37e193cae6e042aa710a8e93cecf8d94
BLAKE2b-256 ea111ac66b4ddc908ea14c23fbcb46ad7871f39487050df70206f4df43192fe9

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for deepstrike-0.1.16-cp310-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 c50c23a8e21444ef7d6f3edf4dbcc2975b507b7d55d70736f871511c31d43891
MD5 6a8d05db7b9dcf669c646db60c855d4e
BLAKE2b-256 f902071d58045fe1f7c59f559a57a4231720b19a8bdc344c6a7e637fab287cdb

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for deepstrike-0.1.16-cp310-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 5f1981c936085ef90c5f59783676e4ad1b01644fb361e5cf668a88818dde33c6
MD5 100039cb2f16f4772c50c0cbbf6ebc59
BLAKE2b-256 fc993a35dcd4e5b41e6bbe6febfed0021bef0c3d699dc069b36fef002a6398b6

See more details on using hashes here.

Provenance

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