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
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.13.tar.gz (112.5 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.13-cp310-abi3-win_arm64.whl (444.4 kB view details)

Uploaded CPython 3.10+Windows ARM64

deepstrike-0.1.13-cp310-abi3-win_amd64.whl (483.4 kB view details)

Uploaded CPython 3.10+Windows x86-64

deepstrike-0.1.13-cp310-abi3-musllinux_1_2_x86_64.whl (759.2 kB view details)

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

deepstrike-0.1.13-cp310-abi3-musllinux_1_2_aarch64.whl (696.1 kB view details)

Uploaded CPython 3.10+musllinux: musl 1.2+ ARM64

deepstrike-0.1.13-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (547.4 kB view details)

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

deepstrike-0.1.13-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (518.9 kB view details)

Uploaded CPython 3.10+manylinux: glibc 2.17+ ARM64

deepstrike-0.1.13-cp310-abi3-macosx_11_0_arm64.whl (506.7 kB view details)

Uploaded CPython 3.10+macOS 11.0+ ARM64

deepstrike-0.1.13-cp310-abi3-macosx_10_12_x86_64.whl (536.4 kB view details)

Uploaded CPython 3.10+macOS 10.12+ x86-64

File details

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

File metadata

  • Download URL: deepstrike-0.1.13.tar.gz
  • Upload date:
  • Size: 112.5 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.13.tar.gz
Algorithm Hash digest
SHA256 be4e3ecf2cd6ebddffe4e7cad0e99f578a470039c31ef8480a709dc370f4bb6f
MD5 939e781b8a56f52fcf4ff64e00f0c137
BLAKE2b-256 6fed3b3f9556f0c71768f56d57f7f20cd89c2def69626e961b09f7bd9ea02801

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: deepstrike-0.1.13-cp310-abi3-win_arm64.whl
  • Upload date:
  • Size: 444.4 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.13-cp310-abi3-win_arm64.whl
Algorithm Hash digest
SHA256 66c99de11e473cf3916b1214f333aae4898ba54e82c284bf3688e6495f41d643
MD5 568503570c22dee175b34e2e0c9f6d4b
BLAKE2b-256 61438282f061f1e89954f4a39666c592dddbb9ae58264dc915529355f83e92f9

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: deepstrike-0.1.13-cp310-abi3-win_amd64.whl
  • Upload date:
  • Size: 483.4 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.13-cp310-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 5a13db002674d876db3d43510eba55c4f0d0dc9817368b2a18518fc94020ee64
MD5 ceaa48e15bffaa1a80ffef7bb280584b
BLAKE2b-256 3880c84c21d33221b5361399f21efbc97ab7293fcbe7e75df3cc7e42c9bb5302

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for deepstrike-0.1.13-cp310-abi3-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 8c287919b63e1c5356ea462611b16a0d2700af6b3ea2b41c04dfb62922ff765a
MD5 cb7787bf9e28d69fc0f6ef4a70f43a70
BLAKE2b-256 58ea01cbf1117174e57230552c0b7b9153797112765505c240ca895079323596

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for deepstrike-0.1.13-cp310-abi3-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 7e3eb0343f4ea7149412783ace6eed928427fc626ba470927bd23e435c510651
MD5 b60924ede1441e0cdd941d30fcd58046
BLAKE2b-256 3cdfb68d6a01327318588df11f0bce064f2cbb20732f236cbc55e688cc7b42a7

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for deepstrike-0.1.13-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 e28729eecc80418c95c4c681c87b4c76d2acae8b3e74461e9556c812b0c4296e
MD5 fc1392a782091f8aacb6981710ff48e8
BLAKE2b-256 1718ce8688c2fc536fa0ff1c8bc678b30c373f5d163d98768429745ada098424

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for deepstrike-0.1.13-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 f8a6eb5284c64cff318a9f92d412c07a360540bed0299a7bbec43cf7ea4c8f6b
MD5 c6541401aff9ec97358c089c5b7034e2
BLAKE2b-256 2cd7c32bc242563e58ed737dec8258a3f12faaad5dabac9ac811e4a3de1bbdc4

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for deepstrike-0.1.13-cp310-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 a2cae8af5a460ca187ff67a5e84c7c727fe57e27a9c1714e50e431798021ab1d
MD5 c05cf4e76f0a37f9301e2e1cd87a59ca
BLAKE2b-256 f420d7a801d1706aabf450b899857d1d88d304b5857d80de07a7c582e4332f45

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for deepstrike-0.1.13-cp310-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 4fea66cba1d1b1eb765ed4c782c691a11e232044d47986e1f6229c3d95f2a4f5
MD5 46a44da1ac1902dbc0424c9c00713cb9
BLAKE2b-256 d359935adca8a81dabbcd5afa63347261b690b09ad7114b37ddd550b092c0d44

See more details on using hashes here.

Provenance

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