xiaohongshu
xiaohongshu
Integrates human agents into automated workflows for human-in-the-loop interactions. Use this when humans need to respond alongside AI agents, handle escalations, or provide context that AI cannot determine.
Full skill instructions
Human agents allow humans to participate in agent threads, creating hybrid workflows where humans and AI collaborate. Perfect for support, approval workflows, and escalations.
Store a message from the end user:
// convex/humanAgents.ts
import { mutation } from "./_generated/server";
import { v } from "convex/values";
import { saveMessage } from "@convex-dev/agent";
import { components } from "./_generated/api";
export const saveUserMessage = mutation({
args: { threadId: v.string(), message: v.string() },
handler: async (ctx, { threadId, message }) => {
const { messageId } = await saveMessage(ctx, components.agent, {
threadId,
prompt: message, // User message without agent generation
});
return { messageId };
},
});
Store a message from a human (e.g., support agent):
// convex/humanAgents.ts
import { mutation } from "./_generated/server";
import { v } from "convex/values";
import { saveMessage } from "./_generated/api";
import { components } from "./_generated/api";
export const saveHumanResponse = mutation({
args: {
threadId: v.string(),
humanName: v.string(),
response: v.string(),
},
handler: async (ctx, { threadId, humanName, response }) => {
const { messageId } = await saveMessage(ctx, components.agent, {
threadId,
agentName: humanName, // Human's name as the "agent"
message: {
role: "assistant",
content: response,
},
metadata: {
provider: "human",
providerMetadata: {
human: { name: humanName },
},
},
});
return { messageId };
},
});
Route to AI or human:
// convex/humanAgents.ts
import { action } from "./_generated/server";
import { v } from "convex/values";
import { myAgent } from "./agents/myAgent";
export const routeResponse = action({
args: { threadId: v.string(), userId: v.string(), question: v.string() },
handler: async (ctx, { threadId, userId, question }) => {
// Strategy 1: Check database for assigned responder
const assignment = await ctx.db
.query("threadAssignments")
.filter((a) => a.threadId === threadId)
.first();
if (assignment?.assignedTo === "human") {
return { responder: "human", requiresApproval: true };
}
// Strategy 2: Use fast LLM to classify
const classification = await myAgent.generateText(
ctx,
{ threadId },
{
prompt: `Should a human or AI respond? Question: ${question}`,
}
);
if (classification.text.includes("human")) {
return { responder: "human", reason: classification.text };
}
// Strategy 3: Use AI to respond
return { responder: "ai" };
},
});
Let AI call a tool to request human intervention:
// convex/humanAgents.ts
import { tool } from "ai";
import { z } from "zod";
import { action } from "./_generated/server";
import { v } from "convex/values";
import { myAgent } from "./agents/myAgent";
const askHumanTool = tool({
description: "Ask a human agent for help",
parameters: z.object({
question: z.string().describe("Question for the human"),
}),
});
export const generateWithHumanTool = action({
args: { threadId: v.string(), prompt: v.string() },
handler: async (ctx, { threadId, prompt }) => {
const result = await myAgent.generateText(
ctx,
{ threadId },
{
prompt,
tools: { askHuman: askHumanTool },
maxSteps: 5,
}
);
// Check if AI asked for human help
const humanRequests = result.toolCalls.filter(
(tc) => tc.toolName === "askHuman"
);
if (humanRequests.length > 0) {
// Notify human team
await ctx.runMutation(internal.humanAgents.notifyHumanTeam, {
threadId,
requests: humanRequests,
});
}
return result;
},
});
AI requested human help via tool; human now responds:
// convex/humanAgents.ts
import { internalAction } from "./_generated/server";
import { v } from "convex/values";
import { saveMessage } from "@convex-dev/agent";
import { components } from "./_generated/api";
import { myAgent } from "./agents/myAgent";
export const humanRespondToToolCall = internalAction({
args: {
threadId: v.string(),
messageId: v.string(),
toolCallId: v.string(),
humanName: v.string(),
response: v.string(),
},
handler: async (
ctx,
{ threadId, messageId, toolCallId, humanName, response }
) => {
// Save human response as tool result
await saveMessage(ctx, components.agent, {
threadId,
message: {
role: "tool",
content: [
{
type: "tool-result",
toolName: "askHuman",
toolCallId,
result: response,
},
],
},
metadata: {
provider: "human",
providerMetadata: { human: { name: humanName } },
},
});
// Continue AI generation with human's response
const { thread } = await myAgent.continueThread(ctx, { threadId });
await thread.generateText({ promptMessageId: messageId });
},
});
Store who should respond to a thread:
// convex/humanAgents.ts
import { mutation } from "./_generated/server";
import { v } from "convex/values";
export const assignThread = mutation({
args: {
threadId: v.string(),
assignedTo: v.union(v.literal("ai"), v.literal("human")),
assignedUser: v.optional(v.string()),
},
handler: async (ctx, { threadId, assignedTo, assignedUser }) => {
await ctx.db.insert("threadAssignments", {
threadId,
assignedTo,
assignedUser,
assignedAt: Date.now(),
});
},
});
AI generates response; human approves before sending:
// convex/humanAgents.ts
import { action, mutation } from "./_generated/server";
import { v } from "convex/values";
import { saveMessage } from "@convex-dev/agent";
import { components } from "./_generated/api";
import { myAgent } from "./agents/myAgent";
// Step 1: Generate AI response (pending approval)
export const generateForApproval = action({
args: { threadId: v.string(), prompt: v.string() },
handler: async (ctx, { threadId, prompt }) => {
const { thread } = await myAgent.continueThread(ctx, { threadId });
const result = await thread.generateText({ prompt });
// Save as draft (not yet visible to user)
const { messageId } = await saveMessage(ctx, components.agent, {
threadId,
message: { role: "assistant", content: result.text },
metadata: { status: "pending_approval" },
});
// Notify human reviewer
await ctx.runMutation(internal.humanAgents.notifyForApproval, {
threadId,
messageId,
draftText: result.text,
});
return { messageId, draftText: result.text };
},
});
// Step 2: Human approves or rejects
export const approveOrRejectResponse = mutation({
args: {
messageId: v.string(),
approved: v.boolean(),
review: v.optional(v.string()),
},
handler: async (ctx, { messageId, approved, review }) => {
// Update message metadata
const message = await ctx.db.get(messageId);
if (message) {
await ctx.db.patch(messageId, {
metadata: {
...message.metadata,
status: approved ? "approved" : "rejected",
review,
},
});
}
},
});
Escalate to human when AI confidence is low:
// convex/humanAgents.ts
import { action } from "./_generated/server";
import { v } from "convex/values";
import { z } from "zod";
import { myAgent } from "./agents/myAgent";
export const generateWithConfidence = action({
args: { threadId: v.string(), prompt: v.string() },
handler: async (ctx, { threadId, prompt }) => {
const result = await myAgent.generateObject(
ctx,
{ threadId },
{
prompt,
schema: z.object({
response: z.string(),
confidence: z.number().min(0).max(1),
requiresHuman: z.boolean(),
}),
}
);
const { response, confidence, requiresHuman } = result.object;
if (requiresHuman || confidence < 0.7) {
// Escalate to human
await ctx.runMutation(internal.humanAgents.escalateToHuman, {
threadId,
reason: `AI confidence: ${confidence}`,
aiSuggestion: response,
});
return { escalated: true };
}
return { response, confidence };
},
});
// convex/support.ts
import { mutation, action, query } from "./_generated/server";
import { v } from "convex/values";
import { saveMessage } from "@convex-dev/agent";
import { components } from "./_generated/api";
import { supportAgent } from "./agents";
import { z } from "zod";
import { tool } from "ai";
const escalateTool = tool({
description: "Escalate to human support",
parameters: z.object({
reason: z.string(),
}),
});
// User sends message
export const sendSupportMessage = mutation({
args: { threadId: v.string(), message: v.string() },
handler: async (ctx, { threadId, message }) => {
const { messageId } = await saveMessage(ctx, components.agent, {
threadId,
prompt: message,
});
return { messageId };
},
});
// AI or human responds
export const respondToTicket = action({
args: { threadId: v.string(), promptMessageId: v.string() },
handler: async (ctx, { threadId, promptMessageId }) => {
const result = await supportAgent.generateText(
ctx,
{ threadId },
{
promptMessageId,
tools: { escalate: escalateTool },
maxSteps: 3,
}
);
// Check if escalated
if (result.toolCalls.some((tc) => tc.toolName === "escalate")) {
await ctx.runMutation(internal.support.escalateTicket, { threadId });
}
},
});
// Human responds
export const humanReply = mutation({
args: { threadId: v.string(), humanName: v.string(), reply: v.string() },
handler: async (ctx, { threadId, humanName, reply }) => {
await saveMessage(ctx, components.agent, {
threadId,
agentName: humanName,
message: { role: "assistant", content: reply },
metadata: { provider: "human" },
});
},
});
xiaohongshu
technical spec
product ux expert
database patterns
Conduct multi-agent task orchestration and workflow coordination.
Initialize project with Conductor artifacts (product definition,
Expert in web animations, transitions, and motion design using Framer Motion and CSS
Creates Mermaid and ASCII diagrams for flowcharts, architecture, ERDs, state machines, mindmaps, and more. Use when user mentions diagram, flowchart, mermaid, ASCII diagram, text diagram, terminal diagram, visualize, C4, mindmap, architecture diagram, sequence diagram, ERD, or needs visual docume...
PostgreSQL bindings for H3 hexagonal grid system. Use when working with H3 cells in Postgres, including spatial indexing, geometry/geography integration, and raster analysis.
Context-Driven Development skill for projects using Conductor. Use this skill when you detect a `conductor/` directory in the project, when working on tasks defined in a `plan.md` file, or when the user asks about tracks, specs, or plans. Automatically applies TDD workflow, tracks task completion...
Display project status, active tracks, and next actions
Official Stakpak application containerization standard operating procedure, a step-by-step guidline to properly dockerize applications. This is a rule book curated by the Stakpak Team.
Generate, edit, and beat-sync AI video with leading models in one workspace.
The world's fastest calendar for remote work
Transform Your Design with AI Designer by ImgCreator.ai
Revolutionizing Video Production with AI-Powered Creativity
Extend an image past the frame and let AI fill the new aspect ratio.
Discover your celebrity doppelgänger with StarByFace!
ChainClarity explains 700+ crypto whitepapers in plain English, with layered summaries, comparisons, research tools, alerts, and a $4.99 Pro plan.
Opus.ai: Revolutionize Your Web Experience