isotopes-core
Core primitives for building AI agent loops. Provides the engine that powers isotopes — a turn-based execution loop, LLM provider abstraction, middleware system, typed event streaming, context management, and a tool framework.
Installation
From PyPI
# uv
uv add isotopes-core
uv add 'isotopes-core[openai]'
uv add 'isotopes-core[anthropic]'
uv add 'isotopes-core[all]'
# pip
pip install isotopes-core # core only (pydantic)
pip install isotopes-core[openai] # + OpenAI provider
pip install isotopes-core[anthropic] # + Anthropic provider
pip install isotopes-core[all] # all providers + tiktoken
From Source (monorepo)
# Sync just isotopes-core into the workspace environment
uv sync --package isotopes-core
# Include optional provider extras
uv sync --package isotopes-core --extra openai
uv sync --package isotopes-core --extra anthropic
uv sync --package isotopes-core --extra all
API Overview
Agent
The Agent class is the main entry point — it wraps the agent loop with state management, streaming, steering, follow-ups, and abort support.
from isotopes_core import Agent
agent = Agent(
provider=my_provider,
system_prompt="You are a helpful assistant.",
tools=[my_tool],
max_turns=10,
)
async for event in agent.prompt("Hello!"):
if event.type == "message_update":
print(event.delta, end="")
# Inject steering mid-turn, queue follow-ups, or abort
agent.steer("Focus on error handling.")
agent.follow_up("Now write tests.")
agent.abort()
Providers
Providers implement the Provider protocol and stream LLM responses as typed events.
from isotopes_core.providers.proxy import ProxyProvider
from isotopes_core.providers.openai import OpenAIProvider
from isotopes_core.providers.anthropic import AnthropicProvider
# OpenAI-compatible proxy (LiteLLM, Ollama, vLLM, Azure, etc.)
proxy = ProxyProvider(model="gpt-4o", base_url="http://localhost:4141/v1")
# Direct OpenAI
openai = OpenAIProvider(model="gpt-4o", api_key="sk-...")
# Direct Anthropic (supports extended thinking)
anthropic = AnthropicProvider(model="claude-opus-4.6", api_key="sk-ant-...")
A RouterProvider adds multi-provider routing with automatic fallback and circuit breaker.
@auto_tool Decorator
Define tools from plain async functions. The JSON schema is auto-generated from type hints and docstring.
from isotopes_core import auto_tool
@auto_tool
async def grep(pattern: str, path: str = ".", max_results: int = 50) -> str:
"""Search file contents with a regex pattern.
Args:
pattern: The regex pattern to search for.
path: Directory to search in.
max_results: Maximum number of matches to return.
"""
...
Supported types: str, int, float, bool, list[T], T | None. Parameters without defaults become required.
Middleware
Composable middleware chain that intercepts events flowing through the agent loop.
from isotopes_core import LoggingMiddleware, TokenTrackingMiddleware, EventFilterMiddleware
agent = Agent(
provider=my_provider,
middleware=[
LoggingMiddleware(log_level="normal"),
TokenTrackingMiddleware(),
EventFilterMiddleware(exclude={"message_update"}),
],
)
Context Management
- FileTracker — tracks file read/write operations across a session
- SlidingWindowStrategy — drops oldest messages when context exceeds a threshold
- SummarizationStrategy — summarizes old messages using the LLM
- SelectivePruningStrategy — removes specific message types
- pin_message / unpin_message — protect messages from pruning
- count_tokens / estimate_context_usage — token counting with optional tiktoken
Loop Detection
The agent loop detects repetitive tool-call patterns by hashing consecutive tool names and arguments. When a loop is detected, a LoopDetectedEvent is emitted to prevent runaway execution.
License
MIT
Metadata
Release files for isotopes-core 0.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| isotopes_core-0.0.1.tar.gz | 111.4 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| isotopes_core-0.0.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 163.1 kB
Release files / isotopes_core-0.0.1.tar.gz
| Download URL | isotopes_core-0.0.1.tar.gz |
|---|---|
| Size | 111.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
86d69e4db2061031ec15284fba6114d78b9e8c0393e3c27766aeab5657d9e58d
|
|
BLAKE2b-256 checksum How to use checksums |
ffb9c637fda89971c410d49e10da352dc746c13b32849e50b908e390de1e7d8d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Mar 28, 2026.
Transparency logRelease files / isotopes_core-0.0.1-py3-none-any.whl
| Download URL | isotopes_core-0.0.1-py3-none-any.whl |
|---|---|
| Size | 51.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
9a2b9ddb1f3dcdaf5f8d00b886b3b63c668ed97601fb2acf2ce420be73299eaf
|
|
BLAKE2b-256 checksum How to use checksums |
332e4bf234ccfc9f257806a36c28f90a7200d9c434fc6e87369db98ceb07d424
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Mar 28, 2026.
Transparency log