Hello World
The simplest possible agent. Greets on the hand-off turn, stays silent on environment events, and echoes back everything else the user says.
from pipbit import Agent
agent = Agent(name="echo", secret="pb_live_sk_...")
@agent.handle
def handle(req):
if req.is_connect_intro():
# The hand-off arrives as a marker turn (the text is the token
# __pipbit_agent_connected__, never the user's words). Greet here;
# echoing the marker would have the device read the underscores aloud.
return "Echo agent here. Say anything and I'll repeat it."
if req.is_environment_event():
# A subscribed event arrives the same way, with its own marker as
# the text. Say nothing: a deferred turn with no reply.
return req.defer()
return f"You said: {req.text}"
agent.run(host="0.0.0.0", port=3001)
The same agent with no public URL
On the connect transport
(beta) the handler is unchanged; the agent dials out to the platform
instead of waiting for a POST, so it runs on a laptop behind a home
router. Install pip install 'pipbit[connect]', then:
agent = Agent(name="echo", secret="pb_live_sk_...", transport="connect")
# ... the same @agent.handle as above ...
agent.serve() # holds the link; raises ConnectUnavailableError if the platform refuses it
The shipped hello_world example
(HOST/pipbit_agent_examples/hello_world) is exactly this
handler on either transport: python app.py serves the
webhook; with PIPBIT_TRANSPORT=connect it dials out and
logs every change of the link's state. Connect access is a per-agent
grant during the beta — an admin enables it for your agent, or the first
hello is refused with connect_not_enabled.
George — Hardware-store associate
George is a gruff, veteran hardware-store associate powered by an LLM: he coaches DIY projects and helps people find and choose what a job needs. He demonstrates persistent per-user memory, function calling (remember/forget facts, plus an optional simulated in-store lookup for demos), and custom voice configuration.
Key patterns
- Per-user memory — Facts stored in a JSON file keyed by
subject_id - Tool calling — LLM uses
remember_about_userandforget_about_usertools, and withGEORGE_STORE_DATA=demoafind_in_storelookup that makes up aisle, price and stock (off by default; the one function a real deployment replaces) - Voice identity — Configured with a gruff, slow, weathered persona
- Returning-user greeting — Different intro when George has saved facts about the user
Connect intro with context
When a user says "Hey George, how do I change a light bulb?", the
question arrives in req.handoff_context alongside the
connect-intro sentinel — so George answers it instead of greeting (this is
what the shipped example actually does):
@agent.handle
def handle(req):
if req.is_connect_intro():
if req.handoff_context:
# The user's actual first question rode along with the handoff —
# answer it, don't greet.
return generate_response(req.handoff_context, req.conversation, ...)
return "George here. What do you need?"
return generate_response(req.text, req.conversation, ...)
Naomi — Meeting note-taker
Naomi demonstrates a stateful, multi-phase agent. She captures meeting notes, summarises them with an LLM, and emails the summary to participants.
Key patterns
- Session state machine — Tracks phase (collecting recipients, taking notes, wrapping up)
- Deferred replies — Uses
req.defer()for the summarisation step - Proactive messaging — Silence watchdog prompts the user if they go quiet
- Email delivery — Sends HTML-formatted meeting notes via SMTP
- Tool calling — LLM decides when to call
set_recipientsandsend_meeting_notes
Garry — Gmail and Calendar over a linked account
Garry is the worked account linking example: read-only Gmail and Calendar through the user's own Google account.
Key patterns
- Google OAuth via the SDK — including the
access_type=offline/prompt=consentrefresh-token quirks - Deferred worker — instant
req.defer(), real work on a background thread - Handback — an LLM tool signals "the user is done", and the reply ships with
push_reply(..., handback=True) - Own conversation history — keeps a per-user record of what it said, beyond the platform's short window
- Mock mode — runs end to end with no credentials for development
Sonos — linked device control
The most production-shaped example: controls the user's Sonos system over a linked account, with swappable cloud/local/mock backends, LLM tool calling with a deterministic fallback, and gunicorn serving guidance.
Lisa — environment-event monitor
A babysitting monitor built on audio_scene environment
events: LLM classification of ambient sound, soothing responses, and
optional SMS or voice-call escalation to a caretaker.
Building your own
Start from the hello-world pattern and add complexity as you need it. The typical progression is:
- Echo agent — verify your webhook (or connect link) receives traffic
- Add an LLM — route
req.textthrough your model of choice - Add tools — let the LLM call functions (APIs, databases, devices)
- Add state — track per-user context across turns
- Add proactive messaging — push updates when something happens on your side
The agent development prompt can help your AI assistant scaffold each stage.