beginnertypescript
Basic Delegation Contract
Delegate a task to a subagent with typed inputs and structured output using the DCYFR agent harness.
Code
import { delegate } from '@dcyfr/ai';
interface SummarizeInput {
text: string;
maxWords: number;
}
interface SummarizeOutput {
summary: string;
wordCount: number;
}
const result = await delegate<SummarizeInput, SummarizeOutput>({
agent: 'summarizer',
input: { text: 'Your long article here...', maxWords: 100 },
});
console.log(result.summary);How it works
Use `delegate` to hand off work to a named subagent. The generics enforce type safety on both the input and output, making delegation contracts explicit and refactor-safe.