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.15.tar.gz (122.1 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.15-cp310-abi3-win_arm64.whl (458.3 kB view details)

Uploaded CPython 3.10+Windows ARM64

deepstrike-0.1.15-cp310-abi3-win_amd64.whl (497.0 kB view details)

Uploaded CPython 3.10+Windows x86-64

deepstrike-0.1.15-cp310-abi3-musllinux_1_2_x86_64.whl (772.7 kB view details)

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

deepstrike-0.1.15-cp310-abi3-musllinux_1_2_aarch64.whl (710.0 kB view details)

Uploaded CPython 3.10+musllinux: musl 1.2+ ARM64

deepstrike-0.1.15-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (561.3 kB view details)

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

deepstrike-0.1.15-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (532.7 kB view details)

Uploaded CPython 3.10+manylinux: glibc 2.17+ ARM64

deepstrike-0.1.15-cp310-abi3-macosx_11_0_arm64.whl (520.6 kB view details)

Uploaded CPython 3.10+macOS 11.0+ ARM64

deepstrike-0.1.15-cp310-abi3-macosx_10_12_x86_64.whl (550.3 kB view details)

Uploaded CPython 3.10+macOS 10.12+ x86-64

File details

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

File metadata

  • Download URL: deepstrike-0.1.15.tar.gz
  • Upload date:
  • Size: 122.1 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.15.tar.gz
Algorithm Hash digest
SHA256 d394a7bdbadd329af973d8cc6f6635bcb98b126e3878af323046ceb11c577a69
MD5 6df429f6bf1b7dffb30e0cac3ae8b4aa
BLAKE2b-256 a08fc9ed3a93accaa1dd66b9c100bdaecb03db2cf7ad2c0843888ba38ee03919

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: deepstrike-0.1.15-cp310-abi3-win_arm64.whl
  • Upload date:
  • Size: 458.3 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.15-cp310-abi3-win_arm64.whl
Algorithm Hash digest
SHA256 d1e2c9c29164fd9e7707bffbd29a7914683c65c7bfaa30d11c17a3b83b55dd59
MD5 1c83d445db3316f956094f264e4a4501
BLAKE2b-256 f30c02b3f0d1c07b36bd3699caa00b6db4b78e315f367d11f1ebf8a8074fe4e5

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: deepstrike-0.1.15-cp310-abi3-win_amd64.whl
  • Upload date:
  • Size: 497.0 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.15-cp310-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 aba48ec2da7a7d33ec33286f35ce50f7466dd919f50e41b84419aa9228be4e7c
MD5 0660ef39b63a0e3d91490ddbfd2a7dd1
BLAKE2b-256 c1fcb47b499902cf3b281c126a6225def7e020cb08e44cf26bb9a4e69f052cb1

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for deepstrike-0.1.15-cp310-abi3-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 8589a33d3e66696573f867c642339ef6ba56f2aa3fc18308a8feaac0328f268b
MD5 5a6ef2e2ac8fe7e3ca6537eda657d5b2
BLAKE2b-256 4889332646825747900b11dc0ea378f8d1c1f59f239de07ff6845954414cba15

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for deepstrike-0.1.15-cp310-abi3-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 926e8726ea8d89a12fb9da824de142c3c7339d7383d1a884fb5ece2bcfb7948b
MD5 3720358b4af7b897278c5de0fbc587c9
BLAKE2b-256 ae1a306e65a59d46ea8e0f3ac30c449f5a07a9a79f8723d52b3de0f4000e811c

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for deepstrike-0.1.15-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 180bbc3315cdf9d338c074f6c2cc6d905262fa8b86f21df1b88103d3fc475f26
MD5 835ea2c45d64f0bc512b3fda1b07cd26
BLAKE2b-256 ce9581ca26fd8828d124e23ae27069dbdf8ef61cb257d8422f40007b3549dc25

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for deepstrike-0.1.15-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 c16ad7cdd03c7cd54f99c2c17a0be0fbc9ccad8034a43005adba5c7ca69a0064
MD5 dad5ced222c682716b275c91ab79f536
BLAKE2b-256 41ade3ca0fbb767db6fab5bef660ac50c1949c8f6780aab4cb8c30b0387ea56b

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for deepstrike-0.1.15-cp310-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 f0903f583526a60276563c4247f6e48701346a7145ac19749075c486529f282b
MD5 5bc131971f0a485fd00af0487a9f39c3
BLAKE2b-256 ddc49ca51b82d1db38118d5e07c94c7c08b899ac56745de80107a9fb27e1648d

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for deepstrike-0.1.15-cp310-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 888b923338af44d79fea5c615b9d5f231918a2ad9eeae876fadc4360429303da
MD5 fd600f9eb81c6adbb6bf809d90ec37c3
BLAKE2b-256 8f6af639dc3bf59d375de2ac973d6a0b8e3b33f370c8eda6cdd79bb06f09a603

See more details on using hashes here.

Provenance

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