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.10.tar.gz (95.2 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.10-cp310-abi3-win_arm64.whl (417.4 kB view details)

Uploaded CPython 3.10+Windows ARM64

deepstrike-0.1.10-cp310-abi3-win_amd64.whl (456.8 kB view details)

Uploaded CPython 3.10+Windows x86-64

deepstrike-0.1.10-cp310-abi3-musllinux_1_2_x86_64.whl (732.1 kB view details)

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

deepstrike-0.1.10-cp310-abi3-musllinux_1_2_aarch64.whl (669.8 kB view details)

Uploaded CPython 3.10+musllinux: musl 1.2+ ARM64

deepstrike-0.1.10-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (520.8 kB view details)

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

deepstrike-0.1.10-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (493.3 kB view details)

Uploaded CPython 3.10+manylinux: glibc 2.17+ ARM64

deepstrike-0.1.10-cp310-abi3-macosx_11_0_arm64.whl (480.8 kB view details)

Uploaded CPython 3.10+macOS 11.0+ ARM64

deepstrike-0.1.10-cp310-abi3-macosx_10_12_x86_64.whl (509.9 kB view details)

Uploaded CPython 3.10+macOS 10.12+ x86-64

File details

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

File metadata

  • Download URL: deepstrike-0.1.10.tar.gz
  • Upload date:
  • Size: 95.2 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.10.tar.gz
Algorithm Hash digest
SHA256 bd2a0b54aad941506e8b94e5a3341a901b7961d5a9bd829e70d303a3e91baad8
MD5 ff0aab8ca81241b3e2fa856a3721b287
BLAKE2b-256 9d383ffc78b9dcd77171b09b914ab0cd19a690170f4575b8f82ec6f7b87465d0

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: deepstrike-0.1.10-cp310-abi3-win_arm64.whl
  • Upload date:
  • Size: 417.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.10-cp310-abi3-win_arm64.whl
Algorithm Hash digest
SHA256 cf327dc828050282d236dde70e69e466f6ffc2eb48b6919baa09cd0890a5759f
MD5 07748106484009fb6e5bf25054992aca
BLAKE2b-256 04f8f1c15840c5c05c5855fac78ce0ef0dcec75a0529a0c51e3651455c72ea1e

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: deepstrike-0.1.10-cp310-abi3-win_amd64.whl
  • Upload date:
  • Size: 456.8 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.10-cp310-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 f265a23665050653f36d712309c0fce2132aae7706ac267baed9f08cab7bbdbe
MD5 8a27466ef9cb795e100e156733d7179f
BLAKE2b-256 85d2a1c38ce00181a9040d98bf38ba2060d1ac2f95bff99addaea4cd2791a905

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for deepstrike-0.1.10-cp310-abi3-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 8a52dac90f9498380bf2c2e7b6bbc1a5d0f33129198e2f5ce801f3e80337ece4
MD5 d29d990ee71d38058c22e5cd47deb826
BLAKE2b-256 576786348f72b5116571f91e4ba13091d7ab370dc6b4dd436b06cc9835e47c14

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for deepstrike-0.1.10-cp310-abi3-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 e99453df171fcf030dca216857e97f6c115f76583363f3dd3afb128a262c3077
MD5 c1f3131e3aea3eb41093ce3f779162c0
BLAKE2b-256 053c9072278462419e3f99d5b03174c574370e3920009eb3e94e78511e06f928

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for deepstrike-0.1.10-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 79c5b69d5e5099843dd1f80e79ee0113a68c35c8332d3845dc31715ee206d9ee
MD5 7da6bc0f78d94f4102ddc9c858bac0c2
BLAKE2b-256 6f162c428409aa622cb5bb88dcda828ddb3f4450385752af098f0d7c273dbeff

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for deepstrike-0.1.10-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 2f23c6b7770a7f15f2bea523c56b66c03eaba8773755cbf781558f45de74d6db
MD5 72750d18060e2cbb66bb3a8288970ddf
BLAKE2b-256 1ceaf83de9492e15eccaeb2c07ba7b9fc567d562fe6ca1c2fe6dd0ca8e20c0ae

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for deepstrike-0.1.10-cp310-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 4b2f08ccf827055fea8396a3e5e7a255550d470d8078096ef82c53b8a4a0e077
MD5 9db4900a13d549eb562a60879eb3963c
BLAKE2b-256 24d9ae69da2f345781538314d0b722bc6f452606a8823c69fe4feee793fe367c

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for deepstrike-0.1.10-cp310-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 c6d0e96f0faaaf0ee719938f0faec4254606474fcb7b573c9b3630d31b396e31
MD5 08494c6ba2899fabb586edeedae5ea3a
BLAKE2b-256 109f539f9b25d94d33859b2a12d4954d50c9071b42fb09a3671d24ccce2b3072

See more details on using hashes here.

Provenance

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