PluginsExamples
MessageAugmentPlugin Scenario
Use a pipeline scenario to show how a plugin can enrich an inbound value step by step
MessageAugmentPlugin Scenario
Scenario
You want to enrich a message before it enters the main execution path:
- add the current page title
- add a source marker
This kind of pre-chain value enrichment is a strong fit for pipeline.
Example
import { Agent, type Plugin } from "@downcity/agent";
export const messageAugmentPlugin: Plugin = {
name: "message_augment",
title: "Message Augment",
description: "Adds extra fields to inbound message payloads.",
hooks: {
pipeline: {
"chat.enrich_message": [
async ({ value }) => {
const body = value as Record<string, unknown>;
return {
...body,
source: body.source || "web",
pageTitle: body.pageTitle || "Untitled Page",
};
},
],
},
},
};
const agent = new Agent({
id: "repo-helper",
path: "/path/to/project",
tools: {},
plugins: [messageAugmentPlugin],
});
const message = await agent.plugins.pipeline("chat.enrich_message", {
text: "Please summarize this page",
});What this scenario is meant to teach
- a pipeline receives one value and returns a new value
- several plugins can extend the same chain in sequence