Skip to main content

No project description provided

Project description

DeepStrike Python SDK

Agent 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 Agent, OpenAIProvider, tool

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

agent = Agent(OpenAIProvider(api_key="sk-...", model="gpt-5-mini"), max_tokens=4096, max_turns=25)
agent.register(add)

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

Streaming:

async for event in agent.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.


Agent options

agent = Agent(
    provider,
    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

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

Skills

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

agent = Agent(provider, 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 retrieve(self, query: str, top_k: int = 5) -> list[str]:
        return await vector_db.search(query, top_k)

agent = Agent(provider, 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): ...

agent = Agent(provider, 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 agent.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)

agent = Agent(provider, 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"))

agent = Agent(provider, max_tokens=4096, max_turns=25, signal_source=gw)

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

Harness (evaluation framework)

from deepstrike import SinglePassHarness, EvalLoopHarness, HarnessLoop, HarnessRequest

# 1. SinglePass — run once, always passes
outcome = await SinglePassHarness(agent).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(agent, gate=ContainsHello(), max_attempts=3).run(req)

# 3. HarnessLoop — LLM-as-judge with feedback injection + skill extraction
loop = HarnessLoop(agent, eval_provider=eval_provider, max_attempts=3, skill_dir="./skills")
outcome = await loop.run(HarnessRequest(goal="Write a haiku", criteria=["Must be 3 lines"]))
print(outcome.passed, outcome.feedback)

Stream events

Class Key fields
TextDelta delta
ThinkingDelta delta
ToolCallEvent id, name, arguments
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.6.tar.gz (94.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.6-cp310-abi3-win_arm64.whl (416.2 kB view details)

Uploaded CPython 3.10+Windows ARM64

deepstrike-0.1.6-cp310-abi3-win_amd64.whl (455.7 kB view details)

Uploaded CPython 3.10+Windows x86-64

deepstrike-0.1.6-cp310-abi3-musllinux_1_2_x86_64.whl (730.6 kB view details)

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

deepstrike-0.1.6-cp310-abi3-musllinux_1_2_aarch64.whl (668.3 kB view details)

Uploaded CPython 3.10+musllinux: musl 1.2+ ARM64

deepstrike-0.1.6-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (519.5 kB view details)

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

deepstrike-0.1.6-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (491.2 kB view details)

Uploaded CPython 3.10+manylinux: glibc 2.17+ ARM64

deepstrike-0.1.6-cp310-abi3-macosx_11_0_arm64.whl (480.1 kB view details)

Uploaded CPython 3.10+macOS 11.0+ ARM64

deepstrike-0.1.6-cp310-abi3-macosx_10_12_x86_64.whl (508.8 kB view details)

Uploaded CPython 3.10+macOS 10.12+ x86-64

File details

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

File metadata

  • Download URL: deepstrike-0.1.6.tar.gz
  • Upload date:
  • Size: 94.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.6.tar.gz
Algorithm Hash digest
SHA256 9beacd941832ec76fb1073116f0e346b742b14dd3d6d7768fca8cff720dd3ed8
MD5 1a9445a09c78129c830d4c22c7894d2e
BLAKE2b-256 0f3f56950922f3764a7c47c80e0015bce8ff8b46bb3b75fffe80222b67717687

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: deepstrike-0.1.6-cp310-abi3-win_arm64.whl
  • Upload date:
  • Size: 416.2 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.6-cp310-abi3-win_arm64.whl
Algorithm Hash digest
SHA256 5fff8e6b4ebe9e572c0efa4317357604ed0a2cb5aa5134e9c5979a173229ff76
MD5 5d96de9ecc499adaad5f21acf73854cc
BLAKE2b-256 cbb9c281cd7e8ffc47bddfe114a0c060a65deb296454c7ece4d4a02857dbe2b5

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: deepstrike-0.1.6-cp310-abi3-win_amd64.whl
  • Upload date:
  • Size: 455.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.1.6-cp310-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 155ec248c13a498da1e6673225b94c5bdf25bffb680777e8584f0ef6857af4a0
MD5 c433b7e439a37b4c60399c27908137c1
BLAKE2b-256 1182c719efa4544579426ec71bea1e20b90b0335428ac0f6d77221873ab9019f

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for deepstrike-0.1.6-cp310-abi3-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 b13fdfd32f09fa50e53ed4f6d57f6f3d6825a02e185dce88552e2e4e4464f8c6
MD5 d6ff0bed0c1a6f1b712e02edfdaf39b9
BLAKE2b-256 50c0f87417afc2cb37ddcb74144b2f323506cb3eb63be4d2d52d9a4242603ea9

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for deepstrike-0.1.6-cp310-abi3-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 19c4d1d3972b02c57adcee747feaeefc8fa9ea8b8ad6560e26477580bf957476
MD5 bcf64ddb0c915e2be776b7c39106df6a
BLAKE2b-256 8858b7dc7f015e831ff555bbba7aedc9e2bc0f8237bce76eefb58610aac66df7

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for deepstrike-0.1.6-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 dfe2a0fabdb59afb3cb05485f95cdc3b7ea5e459c7fa40d5b86381520d313ce8
MD5 6d8741ebda97d48e63285121850e0f2e
BLAKE2b-256 91ddf3a698f204d52d4cff7826228e26dd7b7dcd3bf98559704603086e3e1d8d

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for deepstrike-0.1.6-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 23721d80924df45a9b54fe80f9ba62dc84e77ba1af295dac0744a8f2a4f272d7
MD5 223db6c3c2056b393f69de3abe5cf24f
BLAKE2b-256 0018aef84147477521fd365e61ec79aae20e793295a1a337781ffbc384f25c27

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for deepstrike-0.1.6-cp310-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 e4dbc389dfe7dc4cefdd0f46a6a5a594422f90b845082b96f2ec43379406f7b1
MD5 f7dc29be67a0c20149619b4e9b67be82
BLAKE2b-256 dfdaac49b591031b4cd83c5d6be9ed6d443133a934ca792f6bc44cc956b39c42

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for deepstrike-0.1.6-cp310-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 ed91e21c3bbdee1327475ff1773b1aa751d9c7a50fbc804c0b4465a97869dda3
MD5 1d4b3d45810bfa64b29cac5cf742bdbd
BLAKE2b-256 99177735feefe0d3b8f4a70f52af7cf62a8f140409c2db3a3bca0dccee323e8e

See more details on using hashes here.

Provenance

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