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.7.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.7-cp310-abi3-win_arm64.whl (415.9 kB view details)

Uploaded CPython 3.10+Windows ARM64

deepstrike-0.1.7-cp310-abi3-win_amd64.whl (455.3 kB view details)

Uploaded CPython 3.10+Windows x86-64

deepstrike-0.1.7-cp310-abi3-musllinux_1_2_x86_64.whl (730.1 kB view details)

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

deepstrike-0.1.7-cp310-abi3-musllinux_1_2_aarch64.whl (668.2 kB view details)

Uploaded CPython 3.10+musllinux: musl 1.2+ ARM64

deepstrike-0.1.7-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (519.6 kB view details)

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

deepstrike-0.1.7-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (491.7 kB view details)

Uploaded CPython 3.10+manylinux: glibc 2.17+ ARM64

deepstrike-0.1.7-cp310-abi3-macosx_11_0_arm64.whl (479.4 kB view details)

Uploaded CPython 3.10+macOS 11.0+ ARM64

deepstrike-0.1.7-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.7.tar.gz.

File metadata

  • Download URL: deepstrike-0.1.7.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.7.tar.gz
Algorithm Hash digest
SHA256 abe8aef29c1a2daae88e8405a5a01fe2bcac60f946fa9eac4408d031eaa8bce7
MD5 25fac5f8275f1f6b366ea2b8191e2f51
BLAKE2b-256 1613e5fe1f0fd15b9f43759a8089dd094d8b1bf83dac7f01821e4dc87dc354cf

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: deepstrike-0.1.7-cp310-abi3-win_arm64.whl
  • Upload date:
  • Size: 415.9 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.7-cp310-abi3-win_arm64.whl
Algorithm Hash digest
SHA256 c9a5662982bffdaebbc82e38fefdbdbb605f7379061e1bdd23d76adb53ff1eba
MD5 a92c5d5f28503ef8169ae67621f9b490
BLAKE2b-256 23accc0f8a34f6b734b85a7c948c6acfbbfabad5888026d321a0a0e11cad045b

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: deepstrike-0.1.7-cp310-abi3-win_amd64.whl
  • Upload date:
  • Size: 455.3 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.7-cp310-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 815a0d02b8426b248eaaca40495a1ce7bef55eb323b3c0cd8148b1f81ba83dd8
MD5 57cd0c77a29394e5a3e71f4ffe063335
BLAKE2b-256 0dcbede89b104616a6deee56c25858edfa6e414a7dc4adc0fb9d8c825b0a08ce

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for deepstrike-0.1.7-cp310-abi3-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 be35f21f9bc172a25eaf3734a2692bdabaa10879412717e7d2ef0a16220deb6e
MD5 2a5a5e99f257958087de00c7ad9eb7b8
BLAKE2b-256 f50c18e98e4e349c7de36d8521c7fe922685f8d2acf12a623cef802602d4d28c

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for deepstrike-0.1.7-cp310-abi3-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 f6a7c3152fe779b0e44f592ac2f4434cdb6385aa9342cf30af96d96c22c20cc3
MD5 42046fb6513cea465dad1c625e132ef5
BLAKE2b-256 387e49ec09db8d179cb5ff6e71b8fcfb4e62af8c37a143cf9c7b41a361fce62e

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for deepstrike-0.1.7-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 343e2b4ae3407317e5427d3fb1c6dca71e89c6223351d1f6a2177278ffcfc36a
MD5 b8a770bd7a73dda84a4cc252b55ba526
BLAKE2b-256 3c8b24de5e0320bd0acf035fe907be04686c38e60342b22d61eaa8d6eb5f2e31

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for deepstrike-0.1.7-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 524a0044c618df2e78a7fda235d0050be68600e3e8089aca69af628971cf85a7
MD5 5d20c4b76813b4c54224e9d7dc9e0b1d
BLAKE2b-256 3ce4570dadf14eca25fe59c811a9bdab13683f325f43abb0ad9492ab91e02f81

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for deepstrike-0.1.7-cp310-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 19eb533bfaa9702fc41dd5e9574305c25142dd70fc6f3e625e733a526444bcca
MD5 845172d1730eca6ca327fee07203fdcf
BLAKE2b-256 00c5a9983970c6eae8062b8f49c2e8b0e25c0f97de8d9837b88b9979a3909885

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for deepstrike-0.1.7-cp310-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 629ff98f9fb032e8d11dfa241ad7bf793e2f45c73f726266ab9f0cbd904de227
MD5 b2814fa518a7edd2bd185bb8bb79ea11
BLAKE2b-256 d70f580e75491b5d2905d39075c78d3ee70be0e81fd578e2c8f6c9b4e9134630

See more details on using hashes here.

Provenance

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