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.12.tar.gz (109.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.12-cp310-abi3-win_arm64.whl (440.5 kB view details)

Uploaded CPython 3.10+Windows ARM64

deepstrike-0.1.12-cp310-abi3-win_amd64.whl (479.6 kB view details)

Uploaded CPython 3.10+Windows x86-64

deepstrike-0.1.12-cp310-abi3-musllinux_1_2_x86_64.whl (755.4 kB view details)

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

deepstrike-0.1.12-cp310-abi3-musllinux_1_2_aarch64.whl (692.3 kB view details)

Uploaded CPython 3.10+musllinux: musl 1.2+ ARM64

deepstrike-0.1.12-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (543.5 kB view details)

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

deepstrike-0.1.12-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (515.0 kB view details)

Uploaded CPython 3.10+manylinux: glibc 2.17+ ARM64

deepstrike-0.1.12-cp310-abi3-macosx_11_0_arm64.whl (503.0 kB view details)

Uploaded CPython 3.10+macOS 11.0+ ARM64

deepstrike-0.1.12-cp310-abi3-macosx_10_12_x86_64.whl (532.9 kB view details)

Uploaded CPython 3.10+macOS 10.12+ x86-64

File details

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

File metadata

  • Download URL: deepstrike-0.1.12.tar.gz
  • Upload date:
  • Size: 109.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.12.tar.gz
Algorithm Hash digest
SHA256 363fe0c5a7eeb3c607fb678dcd56853da33a9f7b2e11ac86bfedd3a597c9e7ae
MD5 2d747e332fd13f1cfdefc872cf92f5d9
BLAKE2b-256 04a515288c2cc30dca948c36e7e7e92b63f08cb2c9b71f7e3650911ffac4c4ce

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: deepstrike-0.1.12-cp310-abi3-win_arm64.whl
  • Upload date:
  • Size: 440.5 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.12-cp310-abi3-win_arm64.whl
Algorithm Hash digest
SHA256 de097c951673510037fc73b8e33c53a710069523160ec5717d86c345bb0d4c68
MD5 83fdf9924d3e58fc936cd25a55ad35c2
BLAKE2b-256 2d7de634f3f978b9a4ed51403f5c21eedce2ea46e9d6341a3a5b2b7c947fbed4

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: deepstrike-0.1.12-cp310-abi3-win_amd64.whl
  • Upload date:
  • Size: 479.6 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.12-cp310-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 93bea560d2fa632036f437425e97ff936c01e999ca562c503e4d04fe40c4332b
MD5 4938f8b166947671aecd0b7908f5af51
BLAKE2b-256 719979cdaeb78477e11dd7bc24b633fc822917f24405f8f3629e03d1aec632ac

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for deepstrike-0.1.12-cp310-abi3-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 9e492b71ff3a480e2ed431f7885481c19ac9a3d3bb112b47f965e0133739b71e
MD5 8152141b20e1ef5ae6f8501be87be369
BLAKE2b-256 6b07a8ee342f7c5025293206cd974da4f6da04e65b890be0433fdd1b73aa039f

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for deepstrike-0.1.12-cp310-abi3-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 f7a74288a660d91e481832bd75501983fbc324fa5130cde99dac0af14a52287e
MD5 b80a9e113886f2152e9805e8dd888e94
BLAKE2b-256 4dc64bd3f85894e0dc64b072f682f42b81728f5d58516d293354e5310c4defe5

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for deepstrike-0.1.12-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 b397bf251eaab99d2091669f59da47c3fdd6069e06e9254238e3e1491a2fc6bf
MD5 9d041fff26887f4cebe059bd673de73c
BLAKE2b-256 558fc5d1961dfa12238b6fddf930a7053ca919a3619ac703ed39be30995e3b2e

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for deepstrike-0.1.12-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 3cc583977b916bbd5db8bce5bed45e11fb8bfbcc1ad3152c52ae4dcd5d78ef9d
MD5 586070a1229d630cb3034f3c9d24d585
BLAKE2b-256 a02e9563c9cb92cc87586f66d2dba641a6a12dc57eb3c59f9aa996a1e8c414f9

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for deepstrike-0.1.12-cp310-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 5aa1eb62bb17da278040a309622021c179d1ce6adb84de723b9a8800611a11ad
MD5 b9f054b5c2c30da61302d60f481744f9
BLAKE2b-256 ba05b3f7326735d080912f66d9cd2141eff994fac4f9fcadd220b569d6f340bc

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for deepstrike-0.1.12-cp310-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 ec9fa1ee1c9052bfc23960e76368d291eb4c06a178732824aa8348a89861155a
MD5 3f4b2d841454684de05e8154717760fe
BLAKE2b-256 34998a29791ab1041822bc5c10d2b705a363a57f4311f734a2f8a34ebcd23a19

See more details on using hashes here.

Provenance

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