iii-observe
What it does
Shows how to make one function react to events from another function, without changing the original. It is for developers who want to add alerts, logging or follow-up work to an existing iii function.
When to use it
- ✓When you want to run follow-up work after another function succeeds or fails.
- ✓When you want to add alerting or logging to an existing function without editing it.
- ✓When you are moving older trigger code to the newer observer approach.
Skill link
https://github.com/iii-hq/iii/blob/main/skills/iii-observe/SKILL.mdCopy it and paste it into your AI (Claude, ChatGPT or Cursor), asking it to follow the instructions.
How to use
The easiest way: copy the message and paste it into your AI. It reads the skill and follows the instructions.
Ready-to-paste message
For Claude Code, Codex or Cursor: run it in your project folder and the skill gets installed.
Download the SKILL.md and drop it into your agent’s skills folder.
Example of what to ask your AI
“Alert me whenever the orders::validate function fails, without changing its code.”
5 new skills a week. 1 minute to read.
How it works
The skill connects a source function to a target with an observer, adding filters if needed. Each event that passes the filters invokes the target. The observer waits until the target is registered, and the older trigger approach still works for now.
Technical content (original SKILL.md)
Original text by the author, straight from GitHub.
Observe
Since iii 0.25 every function is observable. iii.observe(source, target, options?) connects a
source function to a target function: each event of the source that passes the observer's filters
invokes the target. It replaces registerTrigger, and an observe descriptor on
registerFunction replaces registerTriggerType. Both old APIs still work in 0.25 (see
Migrating from triggers).
| Part | Fields | Notes |
|---|---|---|
source (left side) |
function_id, namespace?, args?, filters?, on?, capture?, deliver? |
args only for owner-delivered functions. on (auto only): success (default), error, complete. capture (auto and obs.emit): default ['input', 'output', 'caller'], [] allowed. deliver: envelope (default), input, output |
target (right side) |
a registered function id (or { function_id, namespace }) |
No inline handler. The observer stays pending until the target is registered |
options |
id?, max_fires?, expires_in_ms?, max_in_flight?, metadata? |
id defaults to a UUID kept across replays. metadata is the sidecar of every activation |
The source namespace resolves like trigger(): the worker's namespace, except engine::* and
configuration::*, which resolve in default.
Observe a function
Register the target first, then observe. This alerts on failed charges of 500 or more:
import { registerWorker, type Observed } from "iii-sdk";
const iii = registerWorker(process.env.III_URL ?? "ws://localhost:49134");
iii.registerFunction("alerts::payment-failed", async (event: Observed<{ amount: number }>) => {
console.log(event.function_id, event.error?.code, event.input?.amount, event.caller?.worker_name);
return null; // ignored for auto delivery
});
const failures = iii.observe(
{
function_id: "payments::charge",
on: "error",
filters: { "input.amount": { $gte: 500 } },
capture: ["input", "error", "caller"],
},
"alerts::payment-failed",
{ max_in_flight: 4 },
);
await failures.ready(); // rejects with ObserveRejection (error.code) on error or disposed
// later: await failures.dispose()
iii.register_function("alerts::payment-failed", lambda event: print(event["error"]["code"]))
failures = iii.observe(
{"function_id": "payments::charge", "on": "error",
"filters": {"input.amount": {"$gte": 500}}, "capture": ["input", "error", "caller"]},
"alerts::payment-failed",
{"max_in_flight": 4},
)
failures.ready() # blocks; in async code: await failures.ready_async()
use iii_sdk::{Capture, Error, ObserverOptions, Observed, On, RegisterFunction, Source};
use serde_json::{json, Value};
iii.register_function(
"alerts::payment-failed",
RegisterFunction::new(|event: Observed<Value>| {
println!("{} failed: {:?}", event.function_id, event.error);
Ok::<_, Error>(())
}),
);
let failures = iii.observe_with(
Source::function("payments::charge")
.on(On::Error)
.filters(json!({ "input.amount": { "$gte": 500 } }))
.capture([Capture::Input, Capture::Error, Capture::Caller]),
"alerts::payment-failed",
ObserverOptions::default().max_in_flight(4),
);
failures.ready().await?;
client.RegisterFunction("alerts::payment-failed", func(ctx context.Context, data json.RawMessage) (any, error) {
var ev iii.Observed
if err := json.Unmarshal(data, &ev); err != nil {
return nil, err
}
log.Printf("%s failed: %s", ev.FunctionID, ev.Error.Code)
return nil, nil
})
failures, err := client.Observe(iii.Source{
FunctionID: "payments::charge",
On: iii.OnError,
Filters: iii.Filters{"input.amount": iii.Op{"$gte": 500}},
Capture: []iii.Capture{iii.CaptureInput, iii.CaptureError, iii.CaptureCaller},
}, "alerts::payment-failed", iii.ObserverOptions{MaxInFlight: 4})
if err == nil {
err = failures.Ready(ctx) // *iii.ObserveRejectionError carries the code
}
The browser SDK (iii-browser-sdk) has the same observe API as Node.
What the target receives
- Envelope (default
deliver):{ observer_id, activation_id, function_id, namespace, invocation_id, status, input?, output?, error?, caller?, metadata?, started_at_ms, duration_ms }. Only captured fields are present.deliver: 'input'or'output'sends that value alone. - The observer's
options.metadataarrives as the handler's metadata argument (Node and browser second argument, Python `met
FAQ
Does the source function need changes?
No. An observer connects to it from outside, without editing its code.
Can I filter which calls run the observer?
Yes. Filters decide which events invoke the target.
Is the older trigger approach still supported?
Yes. It still works in this version, although the observer approach is the newer one.
Details
Original description by the author
Use when observing iii functions with iii.observe, writing filters, reacting to engine events, writing observable functions with owner delivery (onObserverAdded, obs.emit, obs.call), tuning local dispatch, or migrating from the deprecated registerTrigger / registerTriggerType across TypeScript, browser, Python, Rust, and Go.
repo: iii-hq/iii
Popularity
- GitHub stars
- 19k
- Ranking position
- #10496
- License
- —
- Updated
- 11/2/2026
Comments
- …
More skills from this repository
iii-sandbox
19kHelps your agent run untrusted or AI-generated code safely inside a temporary isolated virtual machine, then discard it when finished.
configuration
19kLets your agent set up a shared registry of named configuration values, checked against a schema, so workers can read and react to changes.
iii
19kTeaches your agent how iii workers work, so it can add a capability by first checking what already exists, then building a worker.
iii-observability
19kHelps your agent add tracing, structured logs, metrics and alerts to an iii engine, using OpenTelemetry so you can see what is happening.
Similar skills
diffs
394kLets your agent produce a real, shareable diff of edits as a viewer link or image file, instead of a hand-written summary.
coding-agent
394kHelps your agent hand a larger coding job to Codex, Claude Code, or OpenCode as a background worker, then check on its progress.
gh-issues
394kHelps your agent find GitHub issues, pick the ones to work on, and open pull requests with fixes, including follow-up on review comments.