@AigenticParameter
data class Document(val content: String)
@AigenticParameter
data class ProcessedDoc(val cleanedContent: String)
@AigenticParameter
data class AnalyzedDoc(val content: String, val keyTopics: List<String>, val sentiment: String)
@AigenticParameter
data class Summary(val summary: String)
val cleaner = agent<Document, ProcessedDoc> {
geminiModel { /* config */ }
task("Clean and format document") { addInstruction("Remove formatting artifacts") }
}
val analyzer = agent<ProcessedDoc, AnalyzedDoc> {
geminiModel { /* config */ }
task("Analyze document content") { addInstruction("Identify key topics") }
}
val summarizer = agent<AnalyzedDoc, Summary> {
geminiModel { /* config */ }
task("Create concise summary") { addInstruction("Keep under 100 words") }
}
// Chain agents into a type-safe workflow
val workflow = cleaner thenProcess analyzer thenProcess summarizer
// Execute the workflow
val run = workflow.start(Document("Raw document text..."))
when (val outcome = run.outcome) {
is Outcome.Finished -> println(outcome.response?.summary)
is Outcome.Stuck -> println("Workflow stuck: ${outcome.reason}")
is Outcome.Fatal -> println("Error: ${outcome.message}")
}