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 (187 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.2.tar.gz (270.7 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.2-py3-none-any.whl (72.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: petfishframework-0.1.2.tar.gz
  • Upload date:
  • Size: 270.7 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.2.tar.gz
Algorithm Hash digest
SHA256 3017613c058a381683170bc149f14a7d77ba6350b32edc967d9bc6684db1b4ed
MD5 ebb966fff1745cee3061b2d3bc78d185
BLAKE2b-256 5af63fce0e43cd0015b75fc38890758fa22563faae4781a35b0083a46453f3c8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for petfishframework-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 8850fe7ee5b59ab05c6fe7e7f14dc5fd2a9f1507ad44a696df23bbcc090e31ff
MD5 e9c60ea512cccc5b6f0ffcb45689fb84
BLAKE2b-256 5cedc6945c175cc1fe7375b9dc8b76686e8dad2c4d0d523f8d1b169fb44812f0

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