Skip to main content

petfishFramework — a general AI Agent framework

Project description

petfishFramework

The AI agent framework where reliability is architecture, not an afterthought.

Python 3.10+ License: MIT Tests: 187

Why petfishFramework?

Every agent framework lets you call tools. Most let you plug in RAG. But none treat reliability as a structural property of the framework itself — they bolt it on after.

petfishFramework is built around three insights validated by academic research:

  1. Reliability is architectural — the same model scores 30+ points differently depending on the agent scaffold (GAIA benchmark). Framework quality IS product quality.
  2. MCP is the standard — Model Context Protocol is now universal. We make it the canonical tool contract, not an adapter.
  3. Reasoning strategies are pluggable — ReAct is just one option. Tree-of-Thoughts (18× improvement on some tasks), LATS (MCTS for agents), and LLM+P (symbolic planning) are first-class.

Comparison

Dimension LangChain CrewAI petfishFramework
Reliability metric Manual (LangSmith) None Pass^k built-in (freeze+perturb)
Reasoning strategies ReAct only ReAct only ReAct + LATS + LLM+P
MCP support Adapter Adapter Canonical tool contract + real stdio
Cost control Logging None Hard budget enforcement
Multi-agent Manual chains Role-based crews Agent-as-Tool (through chokepoint)
Permissions None None SARC model + 6 DecisionEffects
Replay/audit External None Event-sourced (AUDIT/RESUME/RERUN)
Async Partial No Dual interface (sync + async)
Streaming Yes No Yes
License MIT MIT MIT

Quick Start

pip install petfishframework
from petfishframework import Agent, ReAct
from petfishframework.tools.calculator import Calculator

agent = Agent(
    model="openai:gpt-4o",  # or OpenAIModel(model="gpt-4o")
    reasoning=ReAct(),
    tools=(Calculator(),),
)

result = agent.run("What is 17 * 23?")
print(result.answer)        # "391"
print(result.usage.total_tokens)

Features

Reasoning Strategies

  • ReAct — think-act-observe loop (default, simplest)
  • LATS — Language Agent Tree Search (MCTS, +90% vs ReAct on HotpotQA)
  • LLM+P — LLM + symbolic planner (optimal plans for PDDL domains)

Reliability (Flagship)

  • Pass^k — run k times, measure consistency. Freeze+perturb methodology.
  • Event-sourced Sessions — every model/tool/retrieval call recorded. AUDIT replay, RESUME from checkpoint, RERUN fresh.
  • Budget enforcement — hard limits on tokens, cost, steps, tool calls.
  • Retry + timeout — transient failure recovery built-in.

Tools & MCP

  • MCP-first — single Tool interface that IS MCP-shaped. Native tools and MCP servers use the same contract.
  • Real stdio transportconnect_stdio() spawns real MCP server subprocesses.
  • AgentAsTool — wrap any Agent as a Tool for multi-agent delegation.

Retrieval

  • CRAG (Corrective RAG) — retrieval quality evaluation + web search fallback
  • Adaptive-RAG — query complexity classification → route {no-retrieval/single/multi-step}

Security

  • SARC model — Subject/Action/Resource/Context access control
  • 6 DecisionEffects — ALLOW, DENY, MASK, PARTIAL_ALLOW, REQUIRE_APPROVAL, DEGRADE
  • Two-gate model — visibility gate (CapabilityProjection) + invocation gate (authorize→execute→sanitize)
  • CredentialBroker — agents never hold real credentials

Model Adapters

  • OpenAI (GPT-4o, GPT-4o-mini, ...)
  • Anthropic (Claude Sonnet, Opus, ...)
  • FakeModel (deterministic testing)

Architecture

Agent (recipe) → Session (event-sourced process) → Environment (chokepoint)
                                                         ↕
                                              ReasoningStrategy
                                              (ReAct/LATS/LLM+P)
  • Agent = immutable recipe (model + reasoning + tools + retriever)
  • Session = event-sourced execution (checkpointable, replayable, auditable)
  • Environment = single capability chokepoint (all calls audited, budget-metered, permission-gated)

See docs/architecture.md for full design.

Benchmark

⏳ Pending validation — see docs/validation-roadmap.md

Pass^k comparison (petfishFramework vs raw API) will be documented here after real-model benchmark runs.

Documentation

  • Architecture — 5 core decisions, module structure
  • API Reference — 989-line definitive reference (96 tests validate every API)
  • Validation Roadmap — from paper-validated to real-validated
  • Examples — 3 runnable scripts (quickstart, tools+retrieval, multi-agent)

Development

git clone https://github.com/kylecui/petfishFramework.git
cd petfishFramework
uv sync --all-extras
uv run pytest              # 166 tests
uv run ruff check src/ tests/  # lint clean

License

MIT — © 2026 Kyle Cui

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

petfishframework-0.1.1.tar.gz (270.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

petfishframework-0.1.1-py3-none-any.whl (72.9 kB view details)

Uploaded Python 3

File details

Details for the file petfishframework-0.1.1.tar.gz.

File metadata

  • Download URL: petfishframework-0.1.1.tar.gz
  • Upload date:
  • Size: 270.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for petfishframework-0.1.1.tar.gz
Algorithm Hash digest
SHA256 97a111e995865fa8ac79a48a6559bdb9e974a4f3a2bab7c931d12ae8bb5bc57c
MD5 35b2a1dab93f00f75dfd31cd63f21cc6
BLAKE2b-256 2fc9998fbd85254d9bcd99664debdb79c32c6bd738eb10d73368e19c100bd235

See more details on using hashes here.

File details

Details for the file petfishframework-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for petfishframework-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 c4cee9a1d32ac73c37bd2de2fe3e1fff2fe12554935ac1bc84bbab2ec3e4bf70
MD5 2471b08f3ada79a691d677d57b7740a1
BLAKE2b-256 b3a32138af2600481bb4725e680eea6eec6b8750c9e08f11181fdc636b398ad2

See more details on using hashes here.

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