Reusable Event Bundles
Package event handlers into reusable plugins. A plugin is just an event list you can use across multiple agents.
on_events takes one event list → custom for this agent. plugins takes a list of event lists → reusable across agents.Quick Start (60 seconds)
That's it! Use built-in plugins or create your own.
What is a Plugin?
A plugin is an event list:
Just like tools:
- • Tools:
Agent(tools=[search, calculate]) - • Plugins:
Agent(plugins=[reflection, logger])
Plugin vs on_events
- • on_events: Takes one event list (custom for this agent)
- • plugins: Takes a list of event lists (reusable across agents)
Built-in Plugins (useful_plugins)
ConnectOnion provides ready-to-use plugins that you can import and use immediately.
Reflection Plugin
Reflects on tool execution results to generate insights:
ReAct Plugin
Uses ReAct-style reasoning to plan next steps:
Image Result Formatter Plugin
Automatically converts base64 image results to proper image message format for vision models:
When to use:
- • Tools that return screenshots as base64
- • Image generation tools
- • Any tool that returns visual data
What it does:
- • Detects base64 images in tool results (data URLs or plain base64)
- • Converts to OpenAI vision API format
- • Allows multimodal LLMs to see images visually instead of as text
- • Supports PNG, JPEG, WebP, GIF formats
Using Multiple Plugins Together
Writing Custom Plugins
Learn by example - here's how the reflection plugin is implemented:
Step 1: Message Compression Helper
Why this works:
- • Keep user messages FULL (need to know what they asked)
- • Keep tool parameters FULL (exactly what actions were taken)
- • Keep assistant text FULL (reasoning/responses)
- • Truncate tool results (save tokens while maintaining overview)
Step 2: Event Handler Function
Key insights:
- • Access agent state via
agent.current_session - • Use
llm_do()for AI-powered analysis - • Add results back to conversation messages
- • Print to console for user feedback
Step 3: Create Plugin (Event List)
That's it! A plugin is just an event list.
Step 4: Use Your Plugin
Quick Custom Plugin Example
Build a simple plugin in 3 lines:
Example: Reflection Plugin
Example: Todo Plugin
Reusing Plugins
Use the same plugin across multiple agents:
Summary
A plugin is an event list
on_events vs plugins:
on_events=[after_llm(h1), after_tool(h2)]→ one event listplugins=[plugin1, plugin2]→ list of event lists
