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.


Context model (four slots)

The kernel renders context as four LLM API slots — only history is compressed.

Slot Source Role
system_stable system partition Identity, rules — never changes within a run
system_knowledge knowledge partition Preloaded memory, skill defs — low frequency
turns[0] task_state + signals Goal, plan, progress, compression log, runtime signals
turns[1..N] history Conversation transcript
runner = RuntimeRunner(RuntimeOptions(
    initial_memory=["User prefers chartreuse."],  # → Slot 2
    system_prompt="You are a helpful assistant.",  # → Slot 1
    # ...
))

Full reference: docs/context-partition-compression.md


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
    initial_memory=["..."],     # preloaded blocks → Slot 2 (system_knowledge)
    sub_agent_harness=SubAgentHarnessConfig(  # optional: HarnessLoop for spawned sub-agents
        eval_provider=eval_provider,
        max_attempts=3,
    ),
))

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. Runtime retrieval results land in history as tool results. Use initial_memory for durable preload into Slot 2.

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 (SDK-side scratch pad)

WorkingMemory is an SDK helper — not the kernel working partition (removed). Kernel task state renders into Slot 3 (turns[0]).

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() → history tool result
# Preload:    initial_memory → Slot 2 (system_knowledge)
# 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")

# Sub-agents: pass sub_agent_harness on RuntimeOptions to auto-evaluate spawned children
from deepstrike import SubAgentHarnessConfig
runner = RuntimeRunner(RuntimeOptions(
    provider=provider,
    session_log=InMemorySessionLog(),
    execution_plane=plane,
    sub_agent_harness=SubAgentHarnessConfig(eval_provider=eval_provider, max_attempts=3),
    # ...
))
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.4.tar.gz (177.0 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.4-cp310-abi3-win_arm64.whl (723.6 kB view details)

Uploaded CPython 3.10+Windows ARM64

deepstrike-0.2.4-cp310-abi3-win_amd64.whl (774.7 kB view details)

Uploaded CPython 3.10+Windows x86-64

deepstrike-0.2.4-cp310-abi3-musllinux_1_2_x86_64.whl (1.0 MB view details)

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

deepstrike-0.2.4-cp310-abi3-musllinux_1_2_aarch64.whl (956.2 kB view details)

Uploaded CPython 3.10+musllinux: musl 1.2+ ARM64

deepstrike-0.2.4-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (831.9 kB view details)

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

deepstrike-0.2.4-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (780.4 kB view details)

Uploaded CPython 3.10+manylinux: glibc 2.17+ ARM64

deepstrike-0.2.4-cp310-abi3-macosx_11_0_arm64.whl (762.9 kB view details)

Uploaded CPython 3.10+macOS 11.0+ ARM64

deepstrike-0.2.4-cp310-abi3-macosx_10_12_x86_64.whl (818.4 kB view details)

Uploaded CPython 3.10+macOS 10.12+ x86-64

File details

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

File metadata

  • Download URL: deepstrike-0.2.4.tar.gz
  • Upload date:
  • Size: 177.0 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.4.tar.gz
Algorithm Hash digest
SHA256 48877b332c3b6752f4f3327299d85e7ff3a34ee3b34fc9ae939edd4b9949d97b
MD5 e4643e5e900af3e46929db7ac6e17725
BLAKE2b-256 98f7a726e44d38983734f58c696f4aca995c6cb7bd65901a2962d56c7449f615

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: deepstrike-0.2.4-cp310-abi3-win_arm64.whl
  • Upload date:
  • Size: 723.6 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.2.4-cp310-abi3-win_arm64.whl
Algorithm Hash digest
SHA256 b923605df5716274a9b5088dc30a650d530c407c18adcd57c0aa3ca9708689ee
MD5 b2fe24316d5a1243336fa3c4c71976ca
BLAKE2b-256 1977c4c4c473fc3b88cf27e949a185b832457ae3c2e41ca9d8db4a73b64663a7

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: deepstrike-0.2.4-cp310-abi3-win_amd64.whl
  • Upload date:
  • Size: 774.7 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.2.4-cp310-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 3105909fe5ad10a63318808c6a5f18258703bfd3a7e25ae3d7432b9d6d98cb3a
MD5 826209690ef772f77f25a83366dc2823
BLAKE2b-256 c115599ab146e6a52225a6e23e1debe8d9c3bff0651a0b17313ce6ed456740b9

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for deepstrike-0.2.4-cp310-abi3-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 2654a522d1ef37d411dc34f875ec76da72534e78f12150beb7dac34771d4e623
MD5 f971696d1167996fd04138a30a0f1db4
BLAKE2b-256 4c0241d021115107c9c1cc909190617fce3e9c09a35778c7ebe145767ec8bb06

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for deepstrike-0.2.4-cp310-abi3-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 a567c9ee90ab46ac5e2d3dd4e9a16fba4df1b73e06ad2485590a57076d9ccfa3
MD5 91d2720044ffcd1cc69dc2b18cb08f07
BLAKE2b-256 fb8c82c075840bf119b3c78bd6b11da01b017dd0bb8d78ca4d8af9359f2c2cb6

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for deepstrike-0.2.4-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 6a36b7c6ce36e687c390ec28e52d23d485f9973a42ae87b80ca4b81fddc93fe1
MD5 d269b5a2fec09c097c6aafeca6fd40e5
BLAKE2b-256 194061cf1ea204cf5e2cf763d6e641ab6a854372f15e82f1ba62e6b9e0d2c17e

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for deepstrike-0.2.4-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 6414e2bdad303c65d04f7a31c5376fe60cd44d99342565f5ee561dfac27cef76
MD5 420fa1f50b20faf27c7108153b65341f
BLAKE2b-256 d95d7c54e681d78eb0e2b3c93b04abea4218e6a709730d05e2626d6463bb7247

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for deepstrike-0.2.4-cp310-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 120ecf1eb1e81435d8dccf2a7b1a3af58b594c890c24026c7aaefb89d2fc289b
MD5 19fd9bcf242ea2451e144b931048ed61
BLAKE2b-256 aafebf269b89226e4e2bf73c751ade62b359a3d09435ed6766fd1e061be74108

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for deepstrike-0.2.4-cp310-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 f308d1f627a955086c473f6b4585b8e1cbbfd8dcf6db423b25fe2733d638c013
MD5 3e579cea746df94c74f22c613c0062ee
BLAKE2b-256 a1a7cb0b67c6c50827685cedac86cd3799f7fc392b151a2a86784ef8ad687a8f

See more details on using hashes here.

Provenance

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