Client usage
Examples below match the published exemplar-harness-sdk README and live demos in examples/live/.
Set EXEMPLAR_API_KEY, then:
from exemplar_harness import Harness
harness = Harness.from_env()Memory — add and recall
memory = harness.memory(user_id="user-123", session_id="chat-abc", app_id="my-app")
memory.add("User prefers bullet-point answers.", memory_type="preference")
context = memory.recall("how should I format answers?") # inject into system prompt
results = memory.search("formatting preferences", top_k=5)
listed = memory.list(limit=20)
record = memory.get(listed[0].memory_id)
memory.update(record.memory_id, content="User prefers numbered lists.")
memory.delete(record.memory_id)Skills — create, search, install
skills = harness.skills()
record = skills.create(
name="refund-policy",
instructions="# Refund policy\n\nReturns within 30 days.\n\nSee [references/policy.md](references/policy.md).",
description="Refund workflow",
tags=["support"],
files={"references/policy.md": "# Policy\n\n30-day returns.\n"},
)
items = skills.list(limit=20)
fetched = skills.get("refund-policy")
hits = skills.search("refund", top_k=5)
# Materialize SKILL.md + supporting files for agent runtimes
skills.install(".agents/skills", names=["refund-policy"])Prefer skills.install(dest) folders (SKILL.md + files). record.instructions is the markdown body only—useful for quick editor/MCP use, not the full skill package.
Prompts — create, build, run
prompts = harness.prompts()
record = prompts.create(
name="support-summary",
title="Support summary",
messages=[
{"role": "system", "content": "Be concise."},
{"role": "user", "content": "Summarize topic: {{topic}}."},
],
variables=["topic"],
)
result = prompts.run("support-summary", variables={"topic": "returns"})
print(result["content"])
# Local {{var}} substitution for your own agent framework (no Exemplar model call)
built = prompts.build("support-summary", variables={"topic": "returns"})
# built.messages -> [{"role": "system", ...}, {"role": "user", ...}]Inline run without a stored prompt:
inline = prompts.run_inline(
messages=[
{"role": "system", "content": "Be concise."},
{"role": "user", "content": "Say hello."},
],
model="openai/gpt-4o-mini",
)Session ingest
Direct ingest (no framework)
harness.ingest(
"generic",
session_id="sess-abc",
event="turns",
data={
"turns": [
{
"input": "What is harness eval?",
"output": "Automated judge over agent sessions.",
"model": "gpt-4o",
}
]
},
agent_id="my-agent",
source_app="my-app",
)Session helper with auto judge
session = harness.session(
"sess-abc",
agent_id="support-bot",
source_app="my-app",
auto_judge_run=True,
)
session.ingest(
"generic",
event="turns",
data={"turns": [{"input": "Hello", "output": "Hi!", "model": "gpt-4o"}]},
)Framework helper (Agno)
pip install "exemplar-harness-sdk[agno]"from agno.agent import Agent
from agno.models.openai import OpenAIChat
from exemplar_harness import Harness
from exemplar_harness.integrations.agno import harness_agno_post_hook
harness = Harness.from_env()
agent = Agent(
name="support-bot",
model=OpenAIChat(id="gpt-4o"),
post_hooks=[
harness_agno_post_hook(
harness,
session_id="sess-abc",
agent_id="support-bot",
source_app="my-app",
)
],
)
agent.run("Summarize our refund policy.")Other framework extras: [openai], [google-adk], [claude-agent]. See the SDK README for full quick starts.
Live demos in the repo
Clone exemplar-harness-sdk and run:
poetry install --with dev,live --extras all
cp examples/.env.example examples/.env
# set EXEMPLAR_API_KEY in examples/.env
EXEMPLAR_API_KEY=... python -m examples.live.run_platform_demos --only skills
EXEMPLAR_API_KEY=... python -m examples.live.run_platform_demos --only prompts
EXEMPLAR_API_KEY=... python -m examples.live.run_platform_demos --only memory| Demo | Path |
|---|---|
| Skills CRUD | examples/live/skills_demo.py |
| Prompts CRUD | examples/live/prompts_demo.py |
| Memory CRUD | examples/live/memory_demo.py |
| Agno + MCP | examples/live/agno_demo.py |
| OpenAI + memory | examples/live/openai_memory_demo.py |
Related
Last updated on