Observed since 20 Oct, 22:38 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
Drop-in Anthropic SDK wrapper for AgentLoop — adds memory retrieval and turn logging to messages.create calls. Supports streaming.
Drop-in wrapper that adds AgentLoop memory
retrieval and turn logging to every anthropic.messages.create call.
from anthropic import Anthropic
from agentloop import AgentLoop
from agentloop_anthropic import wrap_anthropic
anthropic = wrap_anthropic(
Anthropic(),
loop=AgentLoop(api_key="ak_..."),
)
msg = anthropic.messages.create(
model="claude-opus-4-7",
max_tokens=1024,
messages=[{"role": "user", "content": "What's the Pix limit at night?"}],
)
That's the whole integration.
For every messages.create call:
loop.search(query) — pulls any relevant correctionssystem prompt (or creates one if absent)loop.log_turn(question, answer) with the assembled textIf either AgentLoop call fails, your Anthropic call still succeeds.
pip install agentloop-py agentloop-py-anthropic anthropic
msg = anthropic.messages.create(
model="claude-opus-4-7",
max_tokens=1024,
messages=[...],
agentloop={
"user_id": "u_123", # tag the logged turn (per-user analytics)
"search_user_id": "u_123", # OPTIONAL: scope memory retrieval to this user
"session_id": "sess_abc",
"signals": {"thumbs_down": True},
"metadata": {"latency_budget_ms": 500},
"skip": False,
"search": False, # or {"limit": 5, "tags": ["pix"]}
},
)
user_id does (changed in v0.2.2)user_id tags the logged turn for per-user dashboard filtering. It does
not filter memory retrieval — search returns the full org-wide
memory corpus by default, regardless of which user this call is for.
That's almost always what you want: any correction your team has ever
made should be available to inform the next response.
If you have a specific reason to want per-user retrieval (e.g. a
personal-assistant agent where each end-user has their own preference
history), set search_user_id explicitly:
agentloop={
"user_id": "u_123", # tag the log
"search_user_id": "u_123", # opt-in: scope retrieval too
}
Migration note: Prior to v0.2.2, the wrapper silently forwarded
user_idto search as well, which suppressed retrieval of org-wide corrections. The fix is non-breaking for the default case. If you previously relied on per-user retrieval, setsearch_user_idto preserve that behavior.
anthropic = wrap_anthropic(
Anthropic(),
loop=loop,
# Custom memory injection. Default: append to system prompt.
# Handles both string and array-of-text-blocks system forms.
inject_memories=lambda memories, existing_system: ...,
# Auto-detect signals from the response before log_turn.
detect_signals=lambda question, answer, memories: {
"agent_punted": "not sure" in answer.lower(),
},
search_limit=3,
search_tags=["production"],
only_log_when_signaled=False,
)
from agentloop_anthropic import ask_with_agentloop, PerCallOptions
from agentloop_anthropic._ask import WrapOptions
resp = ask_with_agentloop(
anthropic, # raw, unwrapped Anthropic client
messages=[{"role": "user", "content": question}],
per_call=PerCallOptions(user_id="u_123"),
config=WrapOptions(loop=loop),
model="claude-opus-4-7",
max_tokens=1024,
)
wrap_anthropic(client) returns a distinct wrapper. Your original
client stays unwrapped and usable.
Not supported in v0.1. Same note as agentloop-py-openai — planned
for a later release.
MIT
Download counts and popularity will appear here as the collector receives them.
| Version | Published | Direct dependencies | Open version |
|---|---|---|---|
| 0.3.0 | 15 May 2026 | 4 |
This describes our collected data; it is not a security assessment.
Observed since 20 Oct, 22:38 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
package:1bbb0ec474f3744d59756de916ceca3870906ce0a7dcb933eaf8f1f98c53dfe9