Skip to main content

AgentExperience

AgentExperience

Give agents memory for what actually worked.
Capture runtime evidence, validate reusable strategy deltas, and apply only experience that earns its token budget.

PyPI Python versions CI Apache-2.0 Pre-alpha

Quick start · Tutorial · API guide · Architecture · Contributing


Most agent memory systems store conversations or long summaries. AgentExperience stores a more conservative object: a small, baseline-relative strategy delta backed by independent evidence. It records how an agent ran, separates success from mere completion, measures the cost and benefit of reuse, and can quarantine experience that regresses.

runtime events → verified outcomes → candidate delta → validation → benefit gate → active reuse
      │                 │                  │                │               │
  observable         auditable         immutable       token-aware     reversible

Why AgentExperience?

Capability What it means
Evidence, not anecdotes A completed run is not automatically a successful run. Deterministic evaluators provide auditable evidence.
Minimal experience The default miner creates structured rules relative to a versioned baseline instead of injecting long model-written summaries.
Cost-aware reuse Rule selection respects context budgets; benefit accounting includes input/output tokens, latency, mining cost and truncation.
Safe lifecycle CANDIDATE → VALIDATED → ACTIVE, with quarantine, deprecation and tombstones represented as immutable revisions.
Framework neutral The core has no LangChain, LangGraph, MCP, travel, coding or customer-support semantics. Optional adapters normalize public framework events.
Inspectable storage Checksummed Protobuf events are append-only. SQLite is a rebuildable projection, not the source of truth.
Controlled replay Replay uses registered typed tools, DAG validation, explicit approval and a caller-provided verifier—never arbitrary stored code.

Quick start

Install the framework-independent core:

pip install agent-experience

Or add only the integrations you use:

pip install "agent-experience[langchain,langgraph,mcp]"

Create one runtime, specify the storage path once, and decorate the boundaries you want observed:

from agent_experience import agent_experience

experience = agent_experience("./experience-data")

@experience.tool
def get_weather(city: str) -> dict[str, object]:
    return {"city": city, "temperature_c": 22, "fresh": True}

@experience.run(verify=lambda result: bool(result["fresh"]))
def weather_agent(city: str) -> dict[str, object]:
    return get_weather(city)

print(weather_agent("Berlin"))

That is the entire integration. AgentExperience automatically owns storage, generates stable run and tool identities, propagates causation, sanitizes values, records timing and failures, and queues verified runs for candidate consolidation. There is no Repository, registry, name, contract ID, producer, rule path or CandidateService to configure.

If you only need observation, omit the verifier:

@experience.run
def agent(task: str):
    return do_work(task)

The run is stored, but it cannot create an activatable experience without quality evidence. A standalone @experience.tool call also receives an automatic run context. Call experience.flush() only when a test or short-lived process must wait for background consolidation; normal applications are flushed when the runtime closes.

Observe an application Skill

A Skill is simply a reusable callable capability. Decorate its public entry point exactly like a Tool; the callable's module, signature and code fingerprint become its automatic identity and version. No Skill name, storage path or experience key is required.

from agent_experience import agent_experience

experience = agent_experience("./experience-data")

@experience.tool
def report_skill(rows: list[dict[str, object]]) -> dict[str, object]:
    report = build_report(rows)  # your existing Skill implementation
    return {"report": report, "passed_checks": validate_report(report)}

@experience.run(verify=lambda result: bool(result["passed_checks"]))
def analyst_agent(rows: list[dict[str, object]]) -> dict[str, object]:
    return report_skill(rows)

AgentExperience observes the Skill boundary, sanitized inputs and outputs, latency, failures and task-level quality evidence. It does not store or execute the Skill's source code, and it does not mistake a successful function return for a correct result.

Framework integrations reuse the same runtime and storage:

# LangChain: pass this once when constructing the agent.
agent = create_agent(model, tools, middleware=[experience.langchain()])

# LangGraph: feed typed stream events into the runtime-owned bridge.
graph_events = experience.langgraph()

# MCP: wrap an existing ClientSession; no second path or repository.
session = experience.mcp(session, trust_domain="company-internal")

What is observed?

Source Observed signals Not assumed
Generic Python run start/completion/failure, sanitized inputs/results, outcome evidence that a returned result is correct
Tools contract identity, arguments, result/failure, latency, causation permission to replay the call
LangChain 1.x agent, model and tool lifecycle hooks graph routing or outcome quality
LangGraph 1.x nodes/tasks, routes, checkpoints, interrupts and resumes that graph completion means success
MCP 1.x server identity, capabilities, tool calls, resource/prompt identities and hashes trust in remote content or automatic execution

Applications decide what constitutes success through deterministic evaluators or custom adapters. The core provides extension protocols for FeatureExtractor, BaselineResolver, and TokenEstimator; it does not contain domain keyword tables or benchmark-specific thresholds.

Experience that must earn its keep

from agent_experience import BreakEvenPolicy

policy = BreakEvenPolicy(
    minimum_measurements=3,
    minimum_holdout_samples=20,
    maximum_input_token_increase=128,
    policy_id="production-break-even",
    policy_version="1",
)

Benefit decisions aggregate measurements for the same immutable revision, weighted by sample count. Rejection reasons are machine-readable: insufficient evidence, quality or success-rate regression, negative net benefit, token-budget overflow, or output truncation.

Integrations

Integration Install extra Current level
Plain Python core run + outcome capture
LangChain langchain agent/model/tool observation
LangGraph langgraph graph task/route/interrupt observation
MCP Python SDK mcp capability and client operation observation
AutoGen no extra capability detection only; host event wiring required
CrewAI no extra capability detection only; host event wiring required

See the tutorial for setup and lifecycle examples and the API guide for the supported public surface.

Transparent DeepSeek experiment

The paid end-to-end demo prints every model call, selected rule, token/latency measurement, score, benefit decision and lifecycle transition. It uses travel only as an application-level benchmark; no travel logic exists in the core package.

Copy-Item examples\deepseek_demo_local.example.py examples\deepseek_demo_local.py
# Edit only the ignored deepseek_demo_local.py, then run:
python examples\deepseek_experience_demo.py

The demo performs seven model calls. Generated repositories and reports are ignored by Git.

CLI

agent-exp verify ./experience-repo
agent-exp inspect ./experience-repo
agent-exp extract ./experience-repo --minimum-confidence 0.8
agent-exp candidates ./experience-repo
agent-exp benefits ./experience-repo
agent-exp export ./experience-repo shared.exp
agent-exp import ./other-repo shared.exp

Imported experiences are quarantined until locally reviewed. .exp files are data packages, not trusted executable programs.

Security model

  • inputs and outputs are sanitized before observation;
  • raw secrets should never be stored as experience;
  • retrieved advice is an untrusted reference and cannot override system or permission policy;
  • replay is disabled unless the revision, tool registry, approval policy and verifier all allow it;
  • remote MCP resources and prompts are represented by identity/hash where possible;
  • imported experience starts in QUARANTINED.

Please report vulnerabilities according to SECURITY.md, not in a public issue.

Project status

AgentExperience is pre-alpha. Public APIs and persistent schemas may change before 1.0. The built-in backend is local, single-process and single-writer; it is not presented as a distributed event log or multi-tenant service. Review the architecture and roadmap before production adoption.

Development

python -m venv .venv
.venv/Scripts/python -m pip install -e ".[dev]"  # Windows
python -m ruff check src tests examples setup.py
python -m mypy src
python -m pytest -q
python -m build
python -m twine check dist/*

Contributions are welcome. Read CONTRIBUTING.md and the Code of Conduct first.

License

Apache License 2.0. See LICENSE.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

agent_experience-0.1.0.tar.gz (1.1 MB view details)

Uploaded Source

Built Distribution

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

agent_experience-0.1.0-py3-none-any.whl (75.9 kB view details)

Uploaded Python 3

File details

Details for the file agent_experience-0.1.0.tar.gz.

File metadata

  • Download URL: agent_experience-0.1.0.tar.gz
  • Upload date:
  • Size: 1.1 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for agent_experience-0.1.0.tar.gz
Algorithm Hash digest
SHA256 1701c35679ef81682524ff6107235d5c9b820d68a024c6ed1f5ce9be708c8714
MD5 1ea240dfbf95f8b1c93650cc3a871cd4
BLAKE2b-256 4f33e600621d9d0a852c454372e064c055a8e9ebca38e103edea9fdaec32cfbd

See more details on using hashes here.

Provenance

The following attestation bundles were made for agent_experience-0.1.0.tar.gz:

Publisher: publish.yml on LittleRockets/AgentExperience

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file agent_experience-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for agent_experience-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 02620de4455a958306004ecf540a518cd434c4b87aa6115fc442c0706725b54b
MD5 e80e1dd8ca48a9b06058cdb5f967bc84
BLAKE2b-256 04c72d826b8850c66a14599666f0ffec67d1a7052a177aa2c5217673cfb43b59

See more details on using hashes here.

Provenance

The following attestation bundles were made for agent_experience-0.1.0-py3-none-any.whl:

Publisher: publish.yml on LittleRockets/AgentExperience

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 Sentry Error logging StatusPage Status page