diff --git a/.github/agents/create-safe-output-type.agent.md b/.github/agents/create-safe-output-type.agent.md
index c635f170e0..dd68f287d7 100644
--- a/.github/agents/create-safe-output-type.agent.md
+++ b/.github/agents/create-safe-output-type.agent.md
@@ -270,97 +270,147 @@ func generateFilteredToolsJSON(data *WorkflowData) (string, error) {
**Flow**: Workflow config → parse to struct → filter tools → write JSON → MCP server exposes to agents.
-### 7. Create JavaScript Implementation (`pkg/workflow/js/your_new_type.cjs`)
+### 7. Create Handler Implementation (`actions/setup/js/your_new_type.cjs`)
+
+Create a handler factory that returns a message processing function. The handler manager will call this factory once during initialization and use the returned function to process each message.
```javascript
-async function main() {
- // Check if we're in staged mode
- const isStaged = process.env.GH_AW_SAFE_OUTPUTS_STAGED === "true";
+// @ts-check
+///
- // Read the validated output content from environment variable
- const outputContent = process.env.GH_AW_AGENT_OUTPUT;
- if (!outputContent) {
- core.info("No GH_AW_AGENT_OUTPUT environment variable found");
- return;
- }
+const { getErrorMessage } = require("./error_helpers.cjs");
+const { generateTemporaryId } = require("./temporary_id.cjs");
- if (outputContent.trim() === "") {
- core.info("Agent output content is empty");
- return;
- }
+/**
+ * @typedef {import('./types/handler-factory').HandlerFactoryFunction} HandlerFactoryFunction
+ */
- core.info(`Agent output content length: ${outputContent.length}`);
+/** @type {string} Safe output type handled by this module */
+const HANDLER_TYPE = "your_new_type";
- // Parse the validated output JSON
- let validatedOutput;
- try {
- validatedOutput = JSON.parse(outputContent);
- } catch (error) {
- core.setFailed(`Error parsing agent output JSON: ${error instanceof Error ? error.message : String(error)}`);
- return;
- }
-
- if (!validatedOutput.items || !Array.isArray(validatedOutput.items)) {
- core.info("No valid items found in agent output");
- return;
- }
+/**
+ * Main handler factory for your_new_type
+ * Returns a message handler function that processes individual your_new_type messages
+ * @type {HandlerFactoryFunction}
+ */
+async function main(config = {}) {
+ // Extract and log configuration
+ const customOption = config.custom_option || "";
+ const maxCount = config.max || 10;
+ const isStaged = process.env.GH_AW_SAFE_OUTPUTS_STAGED === "true";
- // Find all your-new-type items
- const items = validatedOutput.items.filter(/** @param {any} item */ item => item.type === "your-new-type");
- if (items.length === 0) {
- core.info("No your-new-type items found in agent output");
- return;
- }
+ core.info(`Custom option: ${customOption}`);
+ core.info(`Max count: ${maxCount}`);
+ core.info(`Staged mode: ${isStaged}`);
+
+ // Track handler state
+ let processedCount = 0;
+ const processedItems = [];
+
+ /**
+ * Message handler function that processes a single your_new_type message
+ * @param {Object} message - The your_new_type message to process
+ * @param {Object} resolvedTemporaryIds - Map of temporary IDs to {repo, number}
+ * @returns {Promise