Preview
Preview Feature — This feature is currently in preview and under active development. APIs and functionality may change. We recommend testing thoroughly before using in production.
Agent Examples
Real-world examples of agents for common use cases.
Customer Support Agent
A support agent that can look up orders, process returns, and handle common inquiries:
- TypeScript
- Java
- Go
- .NET
const supportAgent = await ductape.agents.define({
tag: 'customer-support',
name: 'Customer Support Agent',
model: {
provider: 'anthropic',
model: 'claude-sonnet-4-20250514',
temperature: 0.5,
},
systemPrompt: `You are a customer support agent for an e-commerce store.
Your responsibilities:
- Help customers with order inquiries
- Process returns and refunds (with approval)
- Answer product questions
- Escalate complex issues
Guidelines:
- Be polite, professional, and empathetic
- Always verify order details before making changes
- Explain policies clearly
- If you can't help, offer to escalate`,
tools: [
{
tag: 'lookup-order',
description: 'Look up order details by order number or customer email',
parameters: {
orderNumber: { type: 'string', description: 'Order number (e.g., ORD-12345)' },
email: { type: 'string', description: 'Customer email address' },
},
handler: async (ctx, params) => {
const orders = await ctx.database.query({
database: 'orders-db',
event: 'find-orders',
params: {
orderNumber: params.orderNumber,
email: params.email,
},
});
if (!orders || orders.length === 0) {
return { found: false, message: 'No orders found' };
}
return {
found: true,
orders: orders.map((o) => ({
number: o.orderNumber,
status: o.status,
total: o.total,
items: o.items,
shippingAddress: o.shippingAddress,
trackingNumber: o.trackingNumber,
createdAt: o.createdAt,
})),
};
},
},
{
tag: 'check-tracking',
description: 'Get real-time tracking information for a shipment',
parameters: {
trackingNumber: {
type: 'string',
description: 'Shipping tracking number',
required: true,
},
},
handler: async (ctx, params) => {
return ctx.api.run({
app: 'shipping-api',
event: 'track-package',
input: { body: { tracking: params.trackingNumber } },
});
},
},
{
tag: 'initiate-return',
description: 'Start a return process for an order item',
requiresConfirmation: true,
parameters: {
orderNumber: { type: 'string', required: true },
itemId: { type: 'string', required: true },
reason: {
type: 'string',
required: true,
enum: ['defective', 'wrong_item', 'not_as_described', 'changed_mind', 'other'],
},
notes: { type: 'string' },
},
handler: async (ctx, params) => {
const returnRequest = await ctx.database.insert({
database: 'returns-db',
event: 'create-return',
data: {
orderNumber: params.orderNumber,
itemId: params.itemId,
reason: params.reason,
notes: params.notes,
status: 'pending',
createdAt: new Date(),
},
});
await ctx.notification.email({
notification: 'transactional',
event: 'return-initiated',
recipients: [ctx.input.customerEmail],
template: {
returnId: returnRequest.id,
orderNumber: params.orderNumber,
},
});
return {
success: true,
returnId: returnRequest.id,
message: 'Return initiated. Customer will receive email with instructions.',
};
},
},
{
tag: 'search-faq',
description: 'Search the FAQ knowledge base',
parameters: {
query: { type: 'string', required: true },
},
handler: async (ctx, params) => {
const results = await ctx.recall({
query: params.query,
topK: 3,
filter: { type: 'faq' },
minScore: 0.7,
});
return {
results: results.matches.map((m) => ({
question: m.metadata?.question,
answer: m.metadata?.answer,
relevance: m.score,
})),
};
},
},
],
memory: {
shortTerm: { maxMessages: 30 },
longTerm: {
enabled: true,
vectorStore: 'support-memory',
retrieveTopK: 3,
autoStore: true,
},
},
humanInLoop: {
enabled: true,
alwaysRequireApproval: ['initiate-return'],
approvalTimeout: 300000,
},
termination: {
maxIterations: 15,
timeout: 180000,
},
});
Map<String, Object> supportAgent = ductape.agents.define(Map.of(
"tag", "customer-support",
"name", "Customer Support Agent",
model: Map.of(
"provider", "anthropic",
"model", "claude-sonnet-4-20250514",
"temperature", 0.5
),
systemPrompt: `You are a customer support agent for an e-commerce store.
Your responsibilities:
- Help customers with order inquiries
- Process returns and refunds (with approval)
- Answer product questions
- Escalate complex issues
Guidelines:
- Be polite, professional, and empathetic
- Always verify order details before making changes
- Explain policies clearly
- If you can't help, offer to escalate`,
tools: [
Map.of(
"tag", "lookup-order",
"description", "Look up order details by order number or customer email",
parameters: Map.of(
orderNumber: Map.of( "type", "string", "description", "Order number (e.g., ORD-12345)" ),
email: Map.of( "type", "string", "description", "Customer email address" )
),
handler: async (ctx, params) => Map.of(
Map<String, Object> orders = ctx.database.query(Map.of(
"database", "orders-db",
"event", "find-orders",
params: Map.of(
orderNumber: params.orderNumber,
email: params.email
)
));
if (!orders || orders.length === 0) Map.of(
return Map.of( "found", false, "message", "No orders found" );
)
return Map.of(
"found", true,
orders: orders.map((o) => (Map.of(
number: o.orderNumber,
status: o.status,
total: o.total,
items: o.items,
shippingAddress: o.shippingAddress,
trackingNumber: o.trackingNumber,
createdAt: o.createdAt
)))
);
)
),
Map.of(
"tag", "check-tracking",
"description", "Get real-time tracking information for a shipment",
parameters: Map.of(
trackingNumber: Map.of(
"type", "string",
"description", "Shipping tracking number",
"required", true
)
),
handler: async (ctx, params) => Map.of(
return ctx.api.run(Map.of(
"app", "shipping-api",
"event", "track-package",
input: Map.of( body: Map.of( tracking: params.trackingNumber ) )
));
)
),
Map.of(
"tag", "initiate-return",
"description", "Start a return process for an order item",
"requiresConfirmation", true,
parameters: Map.of(
orderNumber: Map.of( "type", "string", "required", true ),
itemId: Map.of( "type", "string", "required", true ),
reason: Map.of(
"type", "string",
"required", true,
enum: ['defective', 'wrong_item', 'not_as_described', 'changed_mind', 'other']
),
notes: Map.of( "type", "string" )
),
handler: async (ctx, params) => Map.of(
Map<String, Object> returnRequest = ctx.database.insert(Map.of(
"database", "returns-db",
"event", "create-return",
data: Map.of(
orderNumber: params.orderNumber,
itemId: params.itemId,
reason: params.reason,
notes: params.notes,
"status", "pending",
createdAt: Instant.now()
)
));
ctx.notification.email(Map.of(
"notification", "transactional",
"event", "return-initiated",
recipients: [ctx.input.customerEmail],
template: Map.of(
returnId: returnRequest.id,
orderNumber: params.orderNumber
)
));
return Map.of(
"success", true,
returnId: returnRequest.id,
"message", "Return initiated. Customer will receive email with instructions."
);
)
),
Map.of(
"tag", "search-faq",
"description", "Search the FAQ knowledge base",
parameters: Map.of(
query: Map.of( "type", "string", "required", true )
),
handler: async (ctx, params) => Map.of(
Map<String, Object> results = ctx.recall(Map.of(
query: params.query,
"topK", 3,
filter: Map.of( "type", "faq" ),
"minScore", 0.7
));
return Map.of(
results: results.matches.map((m) => (Map.of(
question: m.metadata?.question,
answer: m.metadata?.answer,
relevance: m.score
)))
);
)
),
],
memory: Map.of(
shortTerm: Map.of( "maxMessages", 30 ),
longTerm: Map.of(
"enabled", true,
"vectorStore", "support-memory",
"retrieveTopK", 3,
"autoStore", true
)
),
humanInLoop: Map.of(
"enabled", true,
alwaysRequireApproval: ['initiate-return'],
"approvalTimeout", 300000
),
termination: Map.of(
"maxIterations", 15,
"timeout", 180000
)
));
import "context"
supportAgent := client.agents.define({
"tag": "customer-support",
"name": "Customer Support Agent",
model: {
"provider": "anthropic",
"model": "claude-sonnet-4-20250514",
"temperature": 0.5,
},
systemPrompt: `You are a customer support agent for an e-commerce store.
Your responsibilities:
- Help customers with order inquiries
- Process returns and refunds (with approval)
- Answer product questions
- Escalate complex issues
Guidelines:
- Be polite, professional, and empathetic
- Always verify order details before making changes
- Explain policies clearly
- If you can't help, offer to escalate`,
tools: [
{
"tag": "lookup-order",
"description": "Look up order details by order number or customer email",
parameters: {
orderNumber: { "type": "string", "description": "Order number (e.g., ORD-12345)" },
email: { "type": "string", "description": "Customer email address" },
},
handler: async (ctx, params) => {
orders := ctx.database.query({
"database": "orders-db",
"event": "find-orders",
params: {
orderNumber: params.orderNumber,
email: params.email,
},
});
if (!orders || orders.length === 0) {
return { "found": false, "message": "No orders found" };
}
return {
"found": true,
orders: orders.map((o) => ({
number: o.orderNumber,
status: o.status,
total: o.total,
items: o.items,
shippingAddress: o.shippingAddress,
trackingNumber: o.trackingNumber,
createdAt: o.createdAt,
})),
};
},
},
{
"tag": "check-tracking",
"description": "Get real-time tracking information for a shipment",
parameters: {
trackingNumber: {
"type": "string",
"description": "Shipping tracking number",
"required": true,
},
},
handler: async (ctx, params) => {
return ctx.api.run({
"app": "shipping-api",
"event": "track-package",
input: { body: { tracking: params.trackingNumber } },
});
},
},
{
"tag": "initiate-return",
"description": "Start a return process for an order item",
"requiresConfirmation": true,
parameters: {
orderNumber: { "type": "string", "required": true },
itemId: { "type": "string", "required": true },
reason: {
"type": "string",
"required": true,
enum: ['defective', 'wrong_item', 'not_as_described', 'changed_mind', 'other'],
},
notes: { "type": "string" },
},
handler: async (ctx, params) => {
returnRequest := ctx.database.insert({
"database": "returns-db",
"event": "create-return",
data: {
orderNumber: params.orderNumber,
itemId: params.itemId,
reason: params.reason,
notes: params.notes,
"status": "pending",
createdAt: new Date(),
},
});
ctx.notification.email({
"notification": "transactional",
"event": "return-initiated",
recipients: [ctx.input.customerEmail],
template: {
returnId: returnRequest.id,
orderNumber: params.orderNumber,
},
});
return {
"success": true,
returnId: returnRequest.id,
"message": "Return initiated. Customer will receive email with instructions.",
};
},
},
{
"tag": "search-faq",
"description": "Search the FAQ knowledge base",
parameters: {
query: { "type": "string", "required": true },
},
handler: async (ctx, params) => {
results := ctx.recall({
query: params.query,
"topK": 3,
filter: { "type": "faq" },
"minScore": 0.7,
});
return {
results: results.matches.map((m) => ({
question: m.metadata?.question,
answer: m.metadata?.answer,
relevance: m.score,
})),
};
},
},
],
memory: {
shortTerm: { "maxMessages": 30 },
longTerm: {
"enabled": true,
"vectorStore": "support-memory",
"retrieveTopK": 3,
"autoStore": true,
},
},
humanInLoop: {
"enabled": true,
alwaysRequireApproval: ['initiate-return'],
"approvalTimeout": 300000,
},
termination: {
"maxIterations": 15,
"timeout": 180000,
},
});
var supportAgent = await ductape.agents.define({
["tag"] = "customer-support",
["name"] = "Customer Support Agent",
model: {
["provider"] = "anthropic",
["model"] = "claude-sonnet-4-20250514",
["temperature"] = 0.5,
},
systemPrompt: `You are a customer support agent for an e-commerce store.
Your responsibilities:
- Help customers with order inquiries
- Process returns and refunds (with approval)
- Answer product questions
- Escalate complex issues
Guidelines:
- Be polite, professional, and empathetic
- Always verify order details before making changes
- Explain policies clearly
- If you can't help, offer to escalate`,
tools: [
{
["tag"] = "lookup-order",
["description"] = "Look up order details by order number or customer email",
parameters: {
orderNumber: { ["type"] = "string", ["description"] = "Order number (e.g., ORD-12345)" },
email: { ["type"] = "string", ["description"] = "Customer email address" },
},
handler: async (ctx, params) => {
var orders = await ctx.database.query({
["database"] = "orders-db",
["event"] = "find-orders",
params: {
orderNumber: params.orderNumber,
email: params.email,
},
});
if (!orders || orders.length === 0) {
return { ["found"] = false, ["message"] = "No orders found" };
}
return {
["found"] = true,
orders: orders.map((o) => ({
number: o.orderNumber,
status: o.status,
total: o.total,
items: o.items,
shippingAddress: o.shippingAddress,
trackingNumber: o.trackingNumber,
createdAt: o.createdAt,
})),
};
},
},
{
["tag"] = "check-tracking",
["description"] = "Get real-time tracking information for a shipment",
parameters: {
trackingNumber: {
["type"] = "string",
["description"] = "Shipping tracking number",
["required"] = true,
},
},
handler: async (ctx, params) => {
return ctx.api.run({
["app"] = "shipping-api",
["event"] = "track-package",
input: { body: { tracking: params.trackingNumber } },
});
},
},
{
["tag"] = "initiate-return",
["description"] = "Start a return process for an order item",
["requiresConfirmation"] = true,
parameters: {
orderNumber: { ["type"] = "string", ["required"] = true },
itemId: { ["type"] = "string", ["required"] = true },
reason: {
["type"] = "string",
["required"] = true,
enum: ['defective', 'wrong_item', 'not_as_described', 'changed_mind', 'other'],
},
notes: { ["type"] = "string" },
},
handler: async (ctx, params) => {
var returnRequest = await ctx.database.insert({
["database"] = "returns-db",
["event"] = "create-return",
data: {
orderNumber: params.orderNumber,
itemId: params.itemId,
reason: params.reason,
notes: params.notes,
["status"] = "pending",
createdAt: DateTime.UtcNow,
},
});
await ctx.notification.email({
["notification"] = "transactional",
["event"] = "return-initiated",
recipients: [ctx.input.customerEmail],
template: {
returnId: returnRequest.id,
orderNumber: params.orderNumber,
},
});
return {
["success"] = true,
returnId: returnRequest.id,
["message"] = "Return initiated. Customer will receive email with instructions.",
};
},
},
{
["tag"] = "search-faq",
["description"] = "Search the FAQ knowledge base",
parameters: {
query: { ["type"] = "string", ["required"] = true },
},
handler: async (ctx, params) => {
var results = await ctx.recall({
query: params.query,
["topK"] = 3,
filter: { ["type"] = "faq" },
["minScore"] = 0.7,
});
return {
results: results.matches.map((m) => ({
question: m.metadata?.question,
answer: m.metadata?.answer,
relevance: m.score,
})),
};
},
},
],
memory: {
shortTerm: { ["maxMessages"] = 30 },
longTerm: {
["enabled"] = true,
["vectorStore"] = "support-memory",
["retrieveTopK"] = 3,
["autoStore"] = true,
},
},
humanInLoop: {
["enabled"] = true,
alwaysRequireApproval: ['initiate-return'],
["approvalTimeout"] = 300000,
},
termination: {
["maxIterations"] = 15,
["timeout"] = 180000,
},
});
Data Analysis Agent
An agent that can query databases and generate insights:
- TypeScript
- Java
- Go
- .NET
const dataAgent = await ductape.agents.define({
tag: 'data-analyst',
name: 'Data Analysis Agent',
model: {
provider: 'anthropic',
model: 'claude-sonnet-4-20250514',
temperature: 0.3,
},
systemPrompt: `You are a data analysis assistant.
You can:
- Query databases to answer business questions
- Calculate metrics and statistics
- Generate insights from data
- Create summaries and reports
Guidelines:
- Always explain your methodology
- Show your calculations
- Highlight key insights
- Suggest follow-up analyses`,
tools: [
{
tag: 'query-sales',
description: 'Query sales data with filters',
parameters: {
startDate: { type: 'string', description: 'Start date (YYYY-MM-DD)' },
endDate: { type: 'string', description: 'End date (YYYY-MM-DD)' },
groupBy: {
type: 'string',
enum: ['day', 'week', 'month', 'product', 'region'],
},
filters: {
type: 'object',
properties: {
product: { type: 'string' },
region: { type: 'string' },
minAmount: { type: 'number' },
},
},
},
handler: async (ctx, params) => {
return ctx.database.query({
database: 'analytics-db',
event: 'sales-report',
params: {
startDate: params.startDate,
endDate: params.endDate,
groupBy: params.groupBy,
...params.filters,
},
});
},
},
{
tag: 'query-customers',
description: 'Query customer data and segments',
parameters: {
segment: {
type: 'string',
enum: ['all', 'new', 'returning', 'churned', 'high_value'],
},
startDate: { type: 'string' },
endDate: { type: 'string' },
},
handler: async (ctx, params) => {
return ctx.database.query({
database: 'analytics-db',
event: 'customer-segments',
params,
});
},
},
{
tag: 'calculate-metrics',
description: 'Calculate business metrics',
parameters: {
metric: {
type: 'string',
required: true,
enum: ['revenue', 'aov', 'conversion_rate', 'ltv', 'churn_rate', 'retention'],
},
period: { type: 'string', enum: ['day', 'week', 'month', 'quarter', 'year'] },
compareWith: { type: 'string', description: 'Previous period for comparison' },
},
handler: async (ctx, params) => {
return ctx.database.query({
database: 'analytics-db',
event: 'calculate-metric',
params,
});
},
},
{
tag: 'run-sql',
description: 'Run a custom SQL query (read-only)',
parameters: {
query: { type: 'string', required: true, description: 'SQL query to execute' },
},
handler: async (ctx, params) => {
// Validate query is read-only
const lowerQuery = params.query.toLowerCase();
if (lowerQuery.includes('insert') || lowerQuery.includes('update') ||
lowerQuery.includes('delete') || lowerQuery.includes('drop')) {
return { error: 'Only SELECT queries are allowed' };
}
return ctx.database.execute({
database: 'analytics-db',
event: 'raw-query',
input: { query: params.query },
});
},
},
],
termination: {
maxIterations: 20,
maxTokens: 30000,
},
});
Map<String, Object> dataAgent = ductape.agents.define(Map.of(
"tag", "data-analyst",
"name", "Data Analysis Agent",
model: Map.of(
"provider", "anthropic",
"model", "claude-sonnet-4-20250514",
"temperature", 0.3
),
systemPrompt: `You are a data analysis assistant.
You can:
- Query databases to answer business questions
- Calculate metrics and statistics
- Generate insights from data
- Create summaries and reports
Guidelines:
- Always explain your methodology
- Show your calculations
- Highlight key insights
- Suggest follow-up analyses`,
tools: [
Map.of(
"tag", "query-sales",
"description", "Query sales data with filters",
parameters: Map.of(
startDate: Map.of( "type", "string", "description", "Start date (YYYY-MM-DD)" ),
endDate: Map.of( "type", "string", "description", "End date (YYYY-MM-DD)" ),
groupBy: Map.of(
"type", "string",
enum: ['day', 'week', 'month', 'product', 'region']
),
filters: Map.of(
"type", "object",
properties: Map.of(
product: Map.of( "type", "string" ),
region: Map.of( "type", "string" ),
minAmount: Map.of( "type", "number" )
)
)
),
handler: async (ctx, params) => Map.of(
return ctx.database.query(Map.of(
"database", "analytics-db",
"event", "sales-report",
params: Map.of(
startDate: params.startDate,
endDate: params.endDate,
groupBy: params.groupBy,
...params.filters
)
));
)
),
Map.of(
"tag", "query-customers",
"description", "Query customer data and segments",
parameters: Map.of(
segment: Map.of(
"type", "string",
enum: ['all', 'new', 'returning', 'churned', 'high_value']
),
startDate: Map.of( "type", "string" ),
endDate: Map.of( "type", "string" )
),
handler: async (ctx, params) => Map.of(
return ctx.database.query(Map.of(
"database", "analytics-db",
"event", "customer-segments",
params
));
)
),
Map.of(
"tag", "calculate-metrics",
"description", "Calculate business metrics",
parameters: Map.of(
metric: Map.of(
"type", "string",
"required", true,
enum: ['revenue', 'aov', 'conversion_rate', 'ltv', 'churn_rate', 'retention']
),
period: Map.of( "type", "string", enum: ['day', 'week', 'month', 'quarter', 'year'] ),
compareWith: Map.of( "type", "string", "description", "Previous period for comparison" )
),
handler: async (ctx, params) => Map.of(
return ctx.database.query(Map.of(
"database", "analytics-db",
"event", "calculate-metric",
params
));
)
),
Map.of(
"tag", "run-sql",
"description", "Run a custom SQL query (read-only)",
parameters: Map.of(
query: Map.of( "type", "string", "required", true, "description", "SQL query to execute" )
),
handler: async (ctx, params) => Map.of(
// Validate query is read-only
Map<String, Object> lowerQuery = params.query.toLowerCase();
if (lowerQuery.includes('insert') || lowerQuery.includes('update') ||
lowerQuery.includes('delete') || lowerQuery.includes('drop')) Map.of(
return Map.of( "error", "Only SELECT queries are allowed" );
)
return ctx.database.execute(Map.of(
"database", "analytics-db",
"event", "raw-query",
input: Map.of( query: params.query )
));
)
),
],
termination: Map.of(
"maxIterations", 20,
"maxTokens", 30000
)
));
import "context"
dataAgent := client.agents.define({
"tag": "data-analyst",
"name": "Data Analysis Agent",
model: {
"provider": "anthropic",
"model": "claude-sonnet-4-20250514",
"temperature": 0.3,
},
systemPrompt: `You are a data analysis assistant.
You can:
- Query databases to answer business questions
- Calculate metrics and statistics
- Generate insights from data
- Create summaries and reports
Guidelines:
- Always explain your methodology
- Show your calculations
- Highlight key insights
- Suggest follow-up analyses`,
tools: [
{
"tag": "query-sales",
"description": "Query sales data with filters",
parameters: {
startDate: { "type": "string", "description": "Start date (YYYY-MM-DD)" },
endDate: { "type": "string", "description": "End date (YYYY-MM-DD)" },
groupBy: {
"type": "string",
enum: ['day', 'week', 'month', 'product', 'region'],
},
filters: {
"type": "object",
properties: {
product: { "type": "string" },
region: { "type": "string" },
minAmount: { "type": "number" },
},
},
},
handler: async (ctx, params) => {
return ctx.database.query({
"database": "analytics-db",
"event": "sales-report",
params: {
startDate: params.startDate,
endDate: params.endDate,
groupBy: params.groupBy,
...params.filters,
},
});
},
},
{
"tag": "query-customers",
"description": "Query customer data and segments",
parameters: {
segment: {
"type": "string",
enum: ['all', 'new', 'returning', 'churned', 'high_value'],
},
startDate: { "type": "string" },
endDate: { "type": "string" },
},
handler: async (ctx, params) => {
return ctx.database.query({
"database": "analytics-db",
"event": "customer-segments",
params,
});
},
},
{
"tag": "calculate-metrics",
"description": "Calculate business metrics",
parameters: {
metric: {
"type": "string",
"required": true,
enum: ['revenue', 'aov', 'conversion_rate', 'ltv', 'churn_rate', 'retention'],
},
period: { "type": "string", enum: ['day', 'week', 'month', 'quarter', 'year'] },
compareWith: { "type": "string", "description": "Previous period for comparison" },
},
handler: async (ctx, params) => {
return ctx.database.query({
"database": "analytics-db",
"event": "calculate-metric",
params,
});
},
},
{
"tag": "run-sql",
"description": "Run a custom SQL query (read-only)",
parameters: {
query: { "type": "string", "required": true, "description": "SQL query to execute" },
},
handler: async (ctx, params) => {
// Validate query is read-only
lowerQuery := params.query.toLowerCase();
if (lowerQuery.includes('insert') || lowerQuery.includes('update') ||
lowerQuery.includes('delete') || lowerQuery.includes('drop')) {
return { "error": "Only SELECT queries are allowed" };
}
return ctx.database.execute({
"database": "analytics-db",
"event": "raw-query",
input: { query: params.query },
});
},
},
],
termination: {
"maxIterations": 20,
"maxTokens": 30000,
},
});
var dataAgent = await ductape.agents.define({
["tag"] = "data-analyst",
["name"] = "Data Analysis Agent",
model: {
["provider"] = "anthropic",
["model"] = "claude-sonnet-4-20250514",
["temperature"] = 0.3,
},
systemPrompt: `You are a data analysis assistant.
You can:
- Query databases to answer business questions
- Calculate metrics and statistics
- Generate insights from data
- Create summaries and reports
Guidelines:
- Always explain your methodology
- Show your calculations
- Highlight key insights
- Suggest follow-up analyses`,
tools: [
{
["tag"] = "query-sales",
["description"] = "Query sales data with filters",
parameters: {
startDate: { ["type"] = "string", ["description"] = "Start date (YYYY-MM-DD)" },
endDate: { ["type"] = "string", ["description"] = "End date (YYYY-MM-DD)" },
groupBy: {
["type"] = "string",
enum: ['day', 'week', 'month', 'product', 'region'],
},
filters: {
["type"] = "object",
properties: {
product: { ["type"] = "string" },
region: { ["type"] = "string" },
minAmount: { ["type"] = "number" },
},
},
},
handler: async (ctx, params) => {
return ctx.database.query({
["database"] = "analytics-db",
["event"] = "sales-report",
params: {
startDate: params.startDate,
endDate: params.endDate,
groupBy: params.groupBy,
...params.filters,
},
});
},
},
{
["tag"] = "query-customers",
["description"] = "Query customer data and segments",
parameters: {
segment: {
["type"] = "string",
enum: ['all', 'new', 'returning', 'churned', 'high_value'],
},
startDate: { ["type"] = "string" },
endDate: { ["type"] = "string" },
},
handler: async (ctx, params) => {
return ctx.database.query({
["database"] = "analytics-db",
["event"] = "customer-segments",
params,
});
},
},
{
["tag"] = "calculate-metrics",
["description"] = "Calculate business metrics",
parameters: {
metric: {
["type"] = "string",
["required"] = true,
enum: ['revenue', 'aov', 'conversion_rate', 'ltv', 'churn_rate', 'retention'],
},
period: { ["type"] = "string", enum: ['day', 'week', 'month', 'quarter', 'year'] },
compareWith: { ["type"] = "string", ["description"] = "Previous period for comparison" },
},
handler: async (ctx, params) => {
return ctx.database.query({
["database"] = "analytics-db",
["event"] = "calculate-metric",
params,
});
},
},
{
["tag"] = "run-sql",
["description"] = "Run a custom SQL query (read-only)",
parameters: {
query: { ["type"] = "string", ["required"] = true, ["description"] = "SQL query to execute" },
},
handler: async (ctx, params) => {
// Validate query is read-only
var lowerQuery = params.query.toLowerCase();
if (lowerQuery.includes('insert') || lowerQuery.includes('update') ||
lowerQuery.includes('delete') || lowerQuery.includes('drop')) {
return { ["error"] = "Only SELECT queries are allowed" };
}
return ctx.database.execute({
["database"] = "analytics-db",
["event"] = "raw-query",
input: { query: params.query },
});
},
},
],
termination: {
["maxIterations"] = 20,
["maxTokens"] = 30000,
},
});
Code Review Agent
An agent that reviews code and provides feedback:
- TypeScript
- Java
- Go
- .NET
const codeReviewAgent = await ductape.agents.define({
tag: 'code-reviewer',
name: 'Code Review Agent',
model: {
provider: 'anthropic',
model: 'claude-sonnet-4-20250514',
temperature: 0.2,
},
systemPrompt: `You are a senior software engineer performing code reviews.
Review criteria:
- Code quality and readability
- Potential bugs and edge cases
- Performance considerations
- Security vulnerabilities
- Best practices and patterns
- Test coverage suggestions
Provide constructive feedback with specific line references and suggestions.`,
tools: [
{
tag: 'get-pr-files',
description: 'Get the files changed in a pull request',
parameters: {
prNumber: { type: 'number', required: true },
},
handler: async (ctx, params) => {
return ctx.api.run({
app: 'github',
event: 'get-pr-files',
input: { body: { pr: params.prNumber } },
});
},
},
{
tag: 'get-file-content',
description: 'Get the content of a specific file',
parameters: {
path: { type: 'string', required: true },
ref: { type: 'string', description: 'Git ref (branch/commit)' },
},
handler: async (ctx, params) => {
return ctx.api.run({
app: 'github',
event: 'get-file',
input: { body: { path: params.path, ref: params.ref } },
});
},
},
{
tag: 'add-review-comment',
description: 'Add a review comment to a specific line',
parameters: {
prNumber: { type: 'number', required: true },
path: { type: 'string', required: true },
line: { type: 'number', required: true },
body: { type: 'string', required: true },
side: { type: 'string', enum: ['LEFT', 'RIGHT'], default: 'RIGHT' },
},
handler: async (ctx, params) => {
return ctx.api.run({
app: 'github',
event: 'create-review-comment',
input: { body: params },
});
},
},
{
tag: 'submit-review',
description: 'Submit the code review',
requiresConfirmation: true,
parameters: {
prNumber: { type: 'number', required: true },
event: {
type: 'string',
required: true,
enum: ['APPROVE', 'REQUEST_CHANGES', 'COMMENT'],
},
body: { type: 'string', required: true },
},
handler: async (ctx, params) => {
return ctx.api.run({
app: 'github',
event: 'submit-review',
input: { body: params },
});
},
},
],
humanInLoop: {
enabled: true,
alwaysRequireApproval: ['submit-review'],
},
});
Map<String, Object> codeReviewAgent = ductape.agents.define(Map.of(
"tag", "code-reviewer",
"name", "Code Review Agent",
model: Map.of(
"provider", "anthropic",
"model", "claude-sonnet-4-20250514",
"temperature", 0.2
),
systemPrompt: `You are a senior software engineer performing code reviews.
Review criteria:
- Code quality and readability
- Potential bugs and edge cases
- Performance considerations
- Security vulnerabilities
- Best practices and patterns
- Test coverage suggestions
Provide constructive feedback with specific line references and suggestions.`,
tools: [
Map.of(
"tag", "get-pr-files",
"description", "Get the files changed in a pull request",
parameters: Map.of(
prNumber: Map.of( "type", "number", "required", true )
),
handler: async (ctx, params) => Map.of(
return ctx.api.run(Map.of(
"app", "github",
"event", "get-pr-files",
input: Map.of( body: Map.of( pr: params.prNumber ) )
));
)
),
Map.of(
"tag", "get-file-content",
"description", "Get the content of a specific file",
parameters: Map.of(
path: Map.of( "type", "string", "required", true ),
ref: Map.of( "type", "string", "description", "Git ref (branch/commit)" )
),
handler: async (ctx, params) => Map.of(
return ctx.api.run(Map.of(
"app", "github",
"event", "get-file",
input: Map.of( body: Map.of( path: params.path, ref: params.ref ) )
));
)
),
Map.of(
"tag", "add-review-comment",
"description", "Add a review comment to a specific line",
parameters: Map.of(
prNumber: Map.of( "type", "number", "required", true ),
path: Map.of( "type", "string", "required", true ),
line: Map.of( "type", "number", "required", true ),
body: Map.of( "type", "string", "required", true ),
side: Map.of( "type", "string", enum: ['LEFT', 'RIGHT'], "default", "RIGHT" )
),
handler: async (ctx, params) => Map.of(
return ctx.api.run(Map.of(
"app", "github",
"event", "create-review-comment",
input: Map.of( body: params )
));
)
),
Map.of(
"tag", "submit-review",
"description", "Submit the code review",
"requiresConfirmation", true,
parameters: Map.of(
prNumber: Map.of( "type", "number", "required", true ),
event: Map.of(
"type", "string",
"required", true,
enum: ['APPROVE', 'REQUEST_CHANGES', 'COMMENT']
),
body: Map.of( "type", "string", "required", true )
),
handler: async (ctx, params) => Map.of(
return ctx.api.run(Map.of(
"app", "github",
"event", "submit-review",
input: Map.of( body: params )
));
)
),
],
humanInLoop: Map.of(
"enabled", true,
alwaysRequireApproval: ['submit-review']
)
));
import "context"
codeReviewAgent := client.agents.define({
"tag": "code-reviewer",
"name": "Code Review Agent",
model: {
"provider": "anthropic",
"model": "claude-sonnet-4-20250514",
"temperature": 0.2,
},
systemPrompt: `You are a senior software engineer performing code reviews.
Review criteria:
- Code quality and readability
- Potential bugs and edge cases
- Performance considerations
- Security vulnerabilities
- Best practices and patterns
- Test coverage suggestions
Provide constructive feedback with specific line references and suggestions.`,
tools: [
{
"tag": "get-pr-files",
"description": "Get the files changed in a pull request",
parameters: {
prNumber: { "type": "number", "required": true },
},
handler: async (ctx, params) => {
return ctx.api.run({
"app": "github",
"event": "get-pr-files",
input: { body: { pr: params.prNumber } },
});
},
},
{
"tag": "get-file-content",
"description": "Get the content of a specific file",
parameters: {
path: { "type": "string", "required": true },
ref: { "type": "string", "description": "Git ref (branch/commit)" },
},
handler: async (ctx, params) => {
return ctx.api.run({
"app": "github",
"event": "get-file",
input: { body: { path: params.path, ref: params.ref } },
});
},
},
{
"tag": "add-review-comment",
"description": "Add a review comment to a specific line",
parameters: {
prNumber: { "type": "number", "required": true },
path: { "type": "string", "required": true },
line: { "type": "number", "required": true },
body: { "type": "string", "required": true },
side: { "type": "string", enum: ['LEFT', 'RIGHT'], "default": "RIGHT" },
},
handler: async (ctx, params) => {
return ctx.api.run({
"app": "github",
"event": "create-review-comment",
input: { body: params },
});
},
},
{
"tag": "submit-review",
"description": "Submit the code review",
"requiresConfirmation": true,
parameters: {
prNumber: { "type": "number", "required": true },
event: {
"type": "string",
"required": true,
enum: ['APPROVE', 'REQUEST_CHANGES', 'COMMENT'],
},
body: { "type": "string", "required": true },
},
handler: async (ctx, params) => {
return ctx.api.run({
"app": "github",
"event": "submit-review",
input: { body: params },
});
},
},
],
humanInLoop: {
"enabled": true,
alwaysRequireApproval: ['submit-review'],
},
});
var codeReviewAgent = await ductape.agents.define({
["tag"] = "code-reviewer",
["name"] = "Code Review Agent",
model: {
["provider"] = "anthropic",
["model"] = "claude-sonnet-4-20250514",
["temperature"] = 0.2,
},
systemPrompt: `You are a senior software engineer performing code reviews.
Review criteria:
- Code quality and readability
- Potential bugs and edge cases
- Performance considerations
- Security vulnerabilities
- Best practices and patterns
- Test coverage suggestions
Provide constructive feedback with specific line references and suggestions.`,
tools: [
{
["tag"] = "get-pr-files",
["description"] = "Get the files changed in a pull request",
parameters: {
prNumber: { ["type"] = "number", ["required"] = true },
},
handler: async (ctx, params) => {
return ctx.api.run({
["app"] = "github",
["event"] = "get-pr-files",
input: { body: { pr: params.prNumber } },
});
},
},
{
["tag"] = "get-file-content",
["description"] = "Get the content of a specific file",
parameters: {
path: { ["type"] = "string", ["required"] = true },
ref: { ["type"] = "string", ["description"] = "Git ref (branch/commit)" },
},
handler: async (ctx, params) => {
return ctx.api.run({
["app"] = "github",
["event"] = "get-file",
input: { body: { path: params.path, ref: params.ref } },
});
},
},
{
["tag"] = "add-review-comment",
["description"] = "Add a review comment to a specific line",
parameters: {
prNumber: { ["type"] = "number", ["required"] = true },
path: { ["type"] = "string", ["required"] = true },
line: { ["type"] = "number", ["required"] = true },
body: { ["type"] = "string", ["required"] = true },
side: { ["type"] = "string", enum: ['LEFT', 'RIGHT'], ["default"] = "RIGHT" },
},
handler: async (ctx, params) => {
return ctx.api.run({
["app"] = "github",
["event"] = "create-review-comment",
input: { body: params },
});
},
},
{
["tag"] = "submit-review",
["description"] = "Submit the code review",
["requiresConfirmation"] = true,
parameters: {
prNumber: { ["type"] = "number", ["required"] = true },
event: {
["type"] = "string",
["required"] = true,
enum: ['APPROVE', 'REQUEST_CHANGES', 'COMMENT'],
},
body: { ["type"] = "string", ["required"] = true },
},
handler: async (ctx, params) => {
return ctx.api.run({
["app"] = "github",
["event"] = "submit-review",
input: { body: params },
});
},
},
],
humanInLoop: {
["enabled"] = true,
alwaysRequireApproval: ['submit-review'],
},
});
Research Agent
An agent that can search and synthesize information:
- TypeScript
- Java
- Go
- .NET
const researchAgent = await ductape.agents.define({
tag: 'research-assistant',
name: 'Research Assistant',
model: {
provider: 'anthropic',
model: 'claude-sonnet-4-20250514',
temperature: 0.4,
},
systemPrompt: `You are a research assistant helping users find and synthesize information.
Your approach:
1. Understand the research question
2. Search for relevant information
3. Evaluate source quality
4. Synthesize findings
5. Present with citations
Always cite your sources and note any limitations in the available information.`,
tools: [
{
tag: 'search-knowledge-base',
description: 'Search the internal knowledge base',
parameters: {
query: { type: 'string', required: true },
category: { type: 'string' },
limit: { type: 'number', default: 10 },
},
handler: async (ctx, params) => {
const results = await ctx.recall({
query: params.query,
topK: params.limit || 10,
filter: params.category ? { category: params.category } : undefined,
minScore: 0.6,
});
return {
results: results.matches.map((m) => ({
title: m.metadata?.title,
content: m.metadata?.content,
source: m.metadata?.source,
date: m.metadata?.date,
relevance: m.score,
})),
};
},
},
{
tag: 'search-web',
description: 'Search the web for information',
parameters: {
query: { type: 'string', required: true },
site: { type: 'string', description: 'Limit search to specific site' },
},
handler: async (ctx, params) => {
return ctx.api.run({
app: 'search-api',
event: 'web-search',
input: {
body: {
q: params.query,
site: params.site,
},
},
});
},
},
{
tag: 'fetch-url',
description: 'Fetch and extract content from a URL',
parameters: {
url: { type: 'string', required: true },
},
handler: async (ctx, params) => {
return ctx.api.run({
app: 'scraping-api',
event: 'extract-content',
input: { body: { url: params.url } },
});
},
},
{
tag: 'save-finding',
description: 'Save a research finding for later reference',
parameters: {
title: { type: 'string', required: true },
content: { type: 'string', required: true },
source: { type: 'string', required: true },
tags: { type: 'array', items: { type: 'string' } },
},
handler: async (ctx, params) => {
await ctx.remember({
content: `${params.title}: ${params.content}`,
metadata: {
type: 'research_finding',
title: params.title,
content: params.content,
source: params.source,
tags: params.tags,
sessionId: ctx.sessionId,
timestamp: new Date().toISOString(),
},
});
return { saved: true };
},
},
],
memory: {
shortTerm: { maxMessages: 40 },
longTerm: {
enabled: true,
vectorStore: 'research-memory',
retrieveTopK: 5,
autoStore: true,
},
},
termination: {
maxIterations: 30,
maxTokens: 50000,
timeout: 600000, // 10 minutes
},
});
Map<String, Object> researchAgent = ductape.agents.define(Map.of(
"tag", "research-assistant",
"name", "Research Assistant",
model: Map.of(
"provider", "anthropic",
"model", "claude-sonnet-4-20250514",
"temperature", 0.4
),
systemPrompt: `You are a research assistant helping users find and synthesize information.
Your "approach", 1. Understand the research question
2. Search for relevant information
3. Evaluate source quality
4. Synthesize findings
5. Present with citations
Always cite your sources and note any limitations in the available information.`,
tools: [
Map.of(
"tag", "search-knowledge-base",
"description", "Search the internal knowledge base",
parameters: Map.of(
query: Map.of( "type", "string", "required", true ),
category: Map.of( "type", "string" ),
limit: Map.of( "type", "number", "default", 10 )
),
handler: async (ctx, params) => Map.of(
Map<String, Object> results = ctx.recall(Map.of(
query: params.query,
topK: params.limit || 10,
filter: params.category ? Map.of( category: params.category ) : undefined,
"minScore", 0.6
));
return Map.of(
results: results.matches.map((m) => (Map.of(
title: m.metadata?.title,
content: m.metadata?.content,
source: m.metadata?.source,
date: m.metadata?.date,
relevance: m.score
)))
);
)
),
Map.of(
"tag", "search-web",
"description", "Search the web for information",
parameters: Map.of(
query: Map.of( "type", "string", "required", true ),
site: Map.of( "type", "string", "description", "Limit search to specific site" )
),
handler: async (ctx, params) => Map.of(
return ctx.api.run(Map.of(
"app", "search-api",
"event", "web-search",
input: Map.of(
body: Map.of(
q: params.query,
site: params.site
)
)
));
)
),
Map.of(
"tag", "fetch-url",
"description", "Fetch and extract content from a URL",
parameters: Map.of(
url: Map.of( "type", "string", "required", true )
),
handler: async (ctx, params) => Map.of(
return ctx.api.run(Map.of(
"app", "scraping-api",
"event", "extract-content",
input: Map.of( body: Map.of( url: params.url ) )
));
)
),
Map.of(
"tag", "save-finding",
"description", "Save a research finding for later reference",
parameters: Map.of(
title: Map.of( "type", "string", "required", true ),
content: Map.of( "type", "string", "required", true ),
source: Map.of( "type", "string", "required", true ),
tags: Map.of( "type", "array", items: Map.of( "type", "string" ) )
),
handler: async (ctx, params) => Map.of(
ctx.remember(Map.of(
content: `$Map.of(params.title): $Map.of(params.content)`,
metadata: Map.of(
"type", "research_finding",
title: params.title,
content: params.content,
source: params.source,
tags: params.tags,
sessionId: ctx.sessionId,
timestamp: Instant.now().toISOString()
)
));
return Map.of( "saved", true );
)
),
],
memory: Map.of(
shortTerm: Map.of( "maxMessages", 40 ),
longTerm: Map.of(
"enabled", true,
"vectorStore", "research-memory",
"retrieveTopK", 5,
"autoStore", true
)
),
termination: Map.of(
"maxIterations", 30,
"maxTokens", 50000,
"timeout", 600000, // 10 minutes
)
));
import "context"
researchAgent := client.agents.define({
"tag": "research-assistant",
"name": "Research Assistant",
model: {
"provider": "anthropic",
"model": "claude-sonnet-4-20250514",
"temperature": 0.4,
},
systemPrompt: `You are a research assistant helping users find and synthesize information.
Your "approach": 1. Understand the research question
2. Search for relevant information
3. Evaluate source quality
4. Synthesize findings
5. Present with citations
Always cite your sources and note any limitations in the available information.`,
tools: [
{
"tag": "search-knowledge-base",
"description": "Search the internal knowledge base",
parameters: {
query: { "type": "string", "required": true },
category: { "type": "string" },
limit: { "type": "number", "default": 10 },
},
handler: async (ctx, params) => {
results := ctx.recall({
query: params.query,
topK: params.limit || 10,
filter: params.category ? { category: params.category } : undefined,
"minScore": 0.6,
});
return {
results: results.matches.map((m) => ({
title: m.metadata?.title,
content: m.metadata?.content,
source: m.metadata?.source,
date: m.metadata?.date,
relevance: m.score,
})),
};
},
},
{
"tag": "search-web",
"description": "Search the web for information",
parameters: {
query: { "type": "string", "required": true },
site: { "type": "string", "description": "Limit search to specific site" },
},
handler: async (ctx, params) => {
return ctx.api.run({
"app": "search-api",
"event": "web-search",
input: {
body: {
q: params.query,
site: params.site,
},
},
});
},
},
{
"tag": "fetch-url",
"description": "Fetch and extract content from a URL",
parameters: {
url: { "type": "string", "required": true },
},
handler: async (ctx, params) => {
return ctx.api.run({
"app": "scraping-api",
"event": "extract-content",
input: { body: { url: params.url } },
});
},
},
{
"tag": "save-finding",
"description": "Save a research finding for later reference",
parameters: {
title: { "type": "string", "required": true },
content: { "type": "string", "required": true },
source: { "type": "string", "required": true },
tags: { "type": "array", items: { "type": "string" } },
},
handler: async (ctx, params) => {
ctx.remember({
content: `${params.title}: ${params.content}`,
metadata: {
"type": "research_finding",
title: params.title,
content: params.content,
source: params.source,
tags: params.tags,
sessionId: ctx.sessionId,
timestamp: new Date().toISOString(),
},
});
return { "saved": true };
},
},
],
memory: {
shortTerm: { "maxMessages": 40 },
longTerm: {
"enabled": true,
"vectorStore": "research-memory",
"retrieveTopK": 5,
"autoStore": true,
},
},
termination: {
"maxIterations": 30,
"maxTokens": 50000,
"timeout": 600000, // 10 minutes
},
});
var researchAgent = await ductape.agents.define({
["tag"] = "research-assistant",
["name"] = "Research Assistant",
model: {
["provider"] = "anthropic",
["model"] = "claude-sonnet-4-20250514",
["temperature"] = 0.4,
},
systemPrompt: `You are a research assistant helping users find and synthesize information.
Your ["approach"] = 1. Understand the research question
2. Search for relevant information
3. Evaluate source quality
4. Synthesize findings
5. Present with citations
Always cite your sources and note any limitations in the available information.`,
tools: [
{
["tag"] = "search-knowledge-base",
["description"] = "Search the internal knowledge base",
parameters: {
query: { ["type"] = "string", ["required"] = true },
category: { ["type"] = "string" },
limit: { ["type"] = "number", ["default"] = 10 },
},
handler: async (ctx, params) => {
var results = await ctx.recall({
query: params.query,
topK: params.limit || 10,
filter: params.category ? { category: params.category } : undefined,
["minScore"] = 0.6,
});
return {
results: results.matches.map((m) => ({
title: m.metadata?.title,
content: m.metadata?.content,
source: m.metadata?.source,
date: m.metadata?.date,
relevance: m.score,
})),
};
},
},
{
["tag"] = "search-web",
["description"] = "Search the web for information",
parameters: {
query: { ["type"] = "string", ["required"] = true },
site: { ["type"] = "string", ["description"] = "Limit search to specific site" },
},
handler: async (ctx, params) => {
return ctx.api.run({
["app"] = "search-api",
["event"] = "web-search",
input: {
body: {
q: params.query,
site: params.site,
},
},
});
},
},
{
["tag"] = "fetch-url",
["description"] = "Fetch and extract content from a URL",
parameters: {
url: { ["type"] = "string", ["required"] = true },
},
handler: async (ctx, params) => {
return ctx.api.run({
["app"] = "scraping-api",
["event"] = "extract-content",
input: { body: { url: params.url } },
});
},
},
{
["tag"] = "save-finding",
["description"] = "Save a research finding for later reference",
parameters: {
title: { ["type"] = "string", ["required"] = true },
content: { ["type"] = "string", ["required"] = true },
source: { ["type"] = "string", ["required"] = true },
tags: { ["type"] = "array", items: { ["type"] = "string" } },
},
handler: async (ctx, params) => {
await ctx.remember({
content: `${params.title}: ${params.content}`,
metadata: {
["type"] = "research_finding",
title: params.title,
content: params.content,
source: params.source,
tags: params.tags,
sessionId: ctx.sessionId,
timestamp: DateTime.UtcNow.toISOString(),
},
});
return { ["saved"] = true };
},
},
],
memory: {
shortTerm: { ["maxMessages"] = 40 },
longTerm: {
["enabled"] = true,
["vectorStore"] = "research-memory",
["retrieveTopK"] = 5,
["autoStore"] = true,
},
},
termination: {
["maxIterations"] = 30,
["maxTokens"] = 50000,
["timeout"] = 600000, // 10 minutes
},
});
Task Automation Agent
An agent that automates features and integrations:
- TypeScript
- Java
- Go
- .NET
const automationAgent = await ductape.agents.define({
tag: 'feature-agent',
name: 'Feature Automation Agent',
model: {
provider: 'anthropic',
model: 'claude-sonnet-4-20250514',
temperature: 0.3,
},
systemPrompt: `You are a feature automation assistant.
You can help users:
- Create and run automated features
- Connect different services
- Schedule recurring tasks
- Monitor feature status
Always confirm before executing features that modify data.`,
tools: [
{
tag: 'list-features',
description: 'List available features',
parameters: {
status: { type: 'string', enum: ['active', 'inactive', 'all'] },
},
handler: async (ctx, params) => {
return ctx.database.query({
database: 'features-db',
event: 'list-features',
params: { status: params.status || 'all' },
});
},
},
{
tag: 'run-feature',
description: 'Execute a feature',
requiresConfirmation: true,
parameters: {
featureTag: { type: 'string', required: true },
input: { type: 'object', description: 'Input parameters for the feature' },
},
handler: async (ctx, params) => {
return ctx.feature.run({
feature: params.featureTag,
input: params.input,
});
},
},
{
tag: 'schedule-feature',
description: 'Schedule a feature to run at a specific time or interval',
requiresConfirmation: true,
parameters: {
featureTag: { type: 'string', required: true },
schedule: { type: 'string', description: 'Cron expression or ISO date' },
input: { type: 'object' },
},
handler: async (ctx, params) => {
return ctx.database.insert({
database: 'schedules-db',
event: 'create-schedule',
data: {
featureTag: params.featureTag,
schedule: params.schedule,
input: params.input,
status: 'active',
createdAt: new Date(),
},
});
},
},
{
tag: 'get-feature-history',
description: 'Get execution history for a feature',
parameters: {
featureTag: { type: 'string', required: true },
limit: { type: 'number', default: 10 },
},
handler: async (ctx, params) => {
return ctx.database.query({
database: 'features-db',
event: 'execution-history',
params: {
featureTag: params.featureTag,
limit: params.limit,
},
});
},
},
{
tag: 'send-notification',
description: 'Send a notification',
parameters: {
type: { type: 'string', required: true, enum: ['email', 'slack', 'sms'] },
recipient: { type: 'string', required: true },
message: { type: 'string', required: true },
subject: { type: 'string' },
},
handler: async (ctx, params) => {
if (params.type === 'email') {
await ctx.notification.email({
notification: 'automation',
event: 'custom-notification',
recipients: [params.recipient],
subject: { text: params.subject || 'Automation Notification' },
template: { message: params.message },
});
} else if (params.type === 'slack') {
await ctx.api.run({
app: 'slack',
event: 'send-message',
input: { body: { channel: params.recipient, text: params.message } },
});
}
return { sent: true };
},
},
],
humanInLoop: {
enabled: true,
alwaysRequireApproval: ['run-feature', 'schedule-feature'],
approvalTimeout: 120000,
},
});
Map<String, Object> automationAgent = ductape.agents.define(Map.of(
"tag", "feature-agent",
"name", "Feature Automation Agent",
model: Map.of(
"provider", "anthropic",
"model", "claude-sonnet-4-20250514",
"temperature", 0.3
),
systemPrompt: `You are a feature automation assistant.
You can help users:
- Create and run automated features
- Connect different services
- Schedule recurring tasks
- Monitor feature status
Always confirm before executing features that modify data.`,
tools: [
Map.of(
"tag", "list-features",
"description", "List available features",
parameters: Map.of(
status: Map.of( "type", "string", enum: ['active', 'inactive', 'all'] )
),
handler: async (ctx, params) => Map.of(
return ctx.database.query(Map.of(
"database", "features-db",
"event", "list-features",
params: Map.of( status: params.status || 'all' )
));
)
),
Map.of(
"tag", "run-feature",
"description", "Execute a feature",
"requiresConfirmation", true,
parameters: Map.of(
featureTag: Map.of( "type", "string", "required", true ),
input: Map.of( "type", "object", "description", "Input parameters for the feature" )
),
handler: async (ctx, params) => Map.of(
return ctx.feature.run(Map.of(
feature: params.featureTag,
input: params.input
));
)
),
Map.of(
"tag", "schedule-feature",
"description", "Schedule a feature to run at a specific time or interval",
"requiresConfirmation", true,
parameters: Map.of(
featureTag: Map.of( "type", "string", "required", true ),
schedule: Map.of( "type", "string", "description", "Cron expression or ISO date" ),
input: Map.of( "type", "object" )
),
handler: async (ctx, params) => Map.of(
return ctx.database.insert(Map.of(
"database", "schedules-db",
"event", "create-schedule",
data: Map.of(
featureTag: params.featureTag,
schedule: params.schedule,
input: params.input,
"status", "active",
createdAt: Instant.now()
)
));
)
),
Map.of(
"tag", "get-feature-history",
"description", "Get execution history for a feature",
parameters: Map.of(
featureTag: Map.of( "type", "string", "required", true ),
limit: Map.of( "type", "number", "default", 10 )
),
handler: async (ctx, params) => Map.of(
return ctx.database.query(Map.of(
"database", "features-db",
"event", "execution-history",
params: Map.of(
featureTag: params.featureTag,
limit: params.limit
)
));
)
),
Map.of(
"tag", "send-notification",
"description", "Send a notification",
parameters: Map.of(
type: Map.of( "type", "string", "required", true, enum: ['email', 'slack', 'sms'] ),
recipient: Map.of( "type", "string", "required", true ),
message: Map.of( "type", "string", "required", true ),
subject: Map.of( "type", "string" )
),
handler: async (ctx, params) => Map.of(
if (params.type === 'email') Map.of(
ctx.notification.email(Map.of(
"notification", "automation",
"event", "custom-notification",
recipients: [params.recipient],
subject: Map.of( text: params.subject || 'Automation Notification' ),
template: Map.of( message: params.message )
));
) else if (params.type === 'slack') Map.of(
ctx.api.run(Map.of(
"app", "slack",
"event", "send-message",
input: Map.of( body: Map.of( channel: params.recipient, text: params.message ) )
));
)
return Map.of( "sent", true );
)
),
],
humanInLoop: Map.of(
"enabled", true,
alwaysRequireApproval: ['run-feature', 'schedule-feature'],
"approvalTimeout", 120000
)
));
import "context"
automationAgent := client.agents.define({
"tag": "feature-agent",
"name": "Feature Automation Agent",
model: {
"provider": "anthropic",
"model": "claude-sonnet-4-20250514",
"temperature": 0.3,
},
systemPrompt: `You are a feature automation assistant.
You can help users:
- Create and run automated features
- Connect different services
- Schedule recurring tasks
- Monitor feature status
Always confirm before executing features that modify data.`,
tools: [
{
"tag": "list-features",
"description": "List available features",
parameters: {
status: { "type": "string", enum: ['active', 'inactive', 'all'] },
},
handler: async (ctx, params) => {
return ctx.database.query({
"database": "features-db",
"event": "list-features",
params: { status: params.status || 'all' },
});
},
},
{
"tag": "run-feature",
"description": "Execute a feature",
"requiresConfirmation": true,
parameters: {
featureTag: { "type": "string", "required": true },
input: { "type": "object", "description": "Input parameters for the feature" },
},
handler: async (ctx, params) => {
return ctx.feature.run({
feature: params.featureTag,
input: params.input,
});
},
},
{
"tag": "schedule-feature",
"description": "Schedule a feature to run at a specific time or interval",
"requiresConfirmation": true,
parameters: {
featureTag: { "type": "string", "required": true },
schedule: { "type": "string", "description": "Cron expression or ISO date" },
input: { "type": "object" },
},
handler: async (ctx, params) => {
return ctx.database.insert({
"database": "schedules-db",
"event": "create-schedule",
data: {
featureTag: params.featureTag,
schedule: params.schedule,
input: params.input,
"status": "active",
createdAt: new Date(),
},
});
},
},
{
"tag": "get-feature-history",
"description": "Get execution history for a feature",
parameters: {
featureTag: { "type": "string", "required": true },
limit: { "type": "number", "default": 10 },
},
handler: async (ctx, params) => {
return ctx.database.query({
"database": "features-db",
"event": "execution-history",
params: {
featureTag: params.featureTag,
limit: params.limit,
},
});
},
},
{
"tag": "send-notification",
"description": "Send a notification",
parameters: {
type: { "type": "string", "required": true, enum: ['email', 'slack', 'sms'] },
recipient: { "type": "string", "required": true },
message: { "type": "string", "required": true },
subject: { "type": "string" },
},
handler: async (ctx, params) => {
if (params.type === 'email') {
ctx.notification.email({
"notification": "automation",
"event": "custom-notification",
recipients: [params.recipient],
subject: { text: params.subject || 'Automation Notification' },
template: { message: params.message },
});
} else if (params.type === 'slack') {
ctx.api.run({
"app": "slack",
"event": "send-message",
input: { body: { channel: params.recipient, text: params.message } },
});
}
return { "sent": true };
},
},
],
humanInLoop: {
"enabled": true,
alwaysRequireApproval: ['run-feature', 'schedule-feature'],
"approvalTimeout": 120000,
},
});
var automationAgent = await ductape.agents.define({
["tag"] = "feature-agent",
["name"] = "Feature Automation Agent",
model: {
["provider"] = "anthropic",
["model"] = "claude-sonnet-4-20250514",
["temperature"] = 0.3,
},
systemPrompt: `You are a feature automation assistant.
You can help users:
- Create and run automated features
- Connect different services
- Schedule recurring tasks
- Monitor feature status
Always confirm before executing features that modify data.`,
tools: [
{
["tag"] = "list-features",
["description"] = "List available features",
parameters: {
status: { ["type"] = "string", enum: ['active', 'inactive', 'all'] },
},
handler: async (ctx, params) => {
return ctx.database.query({
["database"] = "features-db",
["event"] = "list-features",
params: { status: params.status || 'all' },
});
},
},
{
["tag"] = "run-feature",
["description"] = "Execute a feature",
["requiresConfirmation"] = true,
parameters: {
featureTag: { ["type"] = "string", ["required"] = true },
input: { ["type"] = "object", ["description"] = "Input parameters for the feature" },
},
handler: async (ctx, params) => {
return ctx.feature.run({
feature: params.featureTag,
input: params.input,
});
},
},
{
["tag"] = "schedule-feature",
["description"] = "Schedule a feature to run at a specific time or interval",
["requiresConfirmation"] = true,
parameters: {
featureTag: { ["type"] = "string", ["required"] = true },
schedule: { ["type"] = "string", ["description"] = "Cron expression or ISO date" },
input: { ["type"] = "object" },
},
handler: async (ctx, params) => {
return ctx.database.insert({
["database"] = "schedules-db",
["event"] = "create-schedule",
data: {
featureTag: params.featureTag,
schedule: params.schedule,
input: params.input,
["status"] = "active",
createdAt: DateTime.UtcNow,
},
});
},
},
{
["tag"] = "get-feature-history",
["description"] = "Get execution history for a feature",
parameters: {
featureTag: { ["type"] = "string", ["required"] = true },
limit: { ["type"] = "number", ["default"] = 10 },
},
handler: async (ctx, params) => {
return ctx.database.query({
["database"] = "features-db",
["event"] = "execution-history",
params: {
featureTag: params.featureTag,
limit: params.limit,
},
});
},
},
{
["tag"] = "send-notification",
["description"] = "Send a notification",
parameters: {
type: { ["type"] = "string", ["required"] = true, enum: ['email', 'slack', 'sms'] },
recipient: { ["type"] = "string", ["required"] = true },
message: { ["type"] = "string", ["required"] = true },
subject: { ["type"] = "string" },
},
handler: async (ctx, params) => {
if (params.type === 'email') {
await ctx.notification.email({
["notification"] = "automation",
["event"] = "custom-notification",
recipients: [params.recipient],
subject: { text: params.subject || 'Automation Notification' },
template: { message: params.message },
});
} else if (params.type === 'slack') {
await ctx.api.run({
["app"] = "slack",
["event"] = "send-message",
input: { body: { channel: params.recipient, text: params.message } },
});
}
return { ["sent"] = true };
},
},
],
humanInLoop: {
["enabled"] = true,
alwaysRequireApproval: ['run-feature', 'schedule-feature'],
["approvalTimeout"] = 120000,
},
});
Running Examples
- TypeScript
- Java
- Go
- .NET
// Customer Support
const supportResult = await ductape.agents.run({
tag: 'customer-support',
input: 'I need to return an item from order ORD-12345',
sessionId: 'customer-session-abc',
});
// Data Analysis
const analysisResult = await ductape.agents.run({
tag: 'data-analyst',
input: 'What were our top 5 selling products last month?',
});
// Research
const researchResult = await ductape.agents.run({
tag: 'research-assistant',
input: 'Research the latest trends in AI agent architectures',
});
// Customer Support
Map<String, Object> supportResult = ductape.agents().run(Map<String, Object>.of(
"tag", "customer-support",
"input", "I need to return an item from order ORD-12345",
"sessionId", "customer-session-abc"
));
// Data Analysis
Map<String, Object> analysisResult = ductape.agents().run(Map<String, Object>.of(
"tag", "data-analyst",
"input", "What were our top 5 selling products last month?"
));
// Research
Map<String, Object> researchResult = ductape.agents().run(Map<String, Object>.of(
"tag", "research-assistant",
"input", "Research the latest trends in AI agent architectures"
));
// Customer Support
supportResult := client.agents.run({
"tag": "customer-support",
"input": "I need to return an item from order ORD-12345",
"sessionId": "customer-session-abc",
});
// Data Analysis
analysisResult := client.agents.run({
"tag": "data-analyst",
"input": "What were our top 5 selling products last month?",
});
// Research
researchResult := client.agents.run({
"tag": "research-assistant",
"input": "Research the latest trends in AI agent architectures",
});
// Customer Support
var supportResult = await ductape.agents.run({
["tag"] = "customer-support",
["input"] = "I need to return an item from order ORD-12345",
["sessionId"] = "customer-session-abc",
});
// Data Analysis
var analysisResult = await ductape.agents.run({
["tag"] = "data-analyst",
["input"] = "What were our top 5 selling products last month?",
});
// Research
var researchResult = await ductape.agents.run({
["tag"] = "research-assistant",
["input"] = "Research the latest trends in AI agent architectures",
});
Next Steps
- Overview - Agent fundamentals
- Tools - Creating custom tools
- Memory - Configure agent memory
- Human-in-the-Loop - Add approval features