CtrlK
CommunityDocumentationLog inGet started
Tessl Logo

tessl/maven-com-embabel-agent--embabel-agent-domain

Core domain type definitions for the Embabel Agent Framework, providing foundational data classes and interfaces for agent-based AI workflows including content assets, research entities, and person types with Jackson serialization and PromptContributor capabilities.

Overview
Eval results
Files

news-types.mddocs/

News Types

Domain models for working with news content in agent workflows.

NewsStory

Represents a news story with URL, title, and summary.

open class NewsStory(
    override val url: String,
    val title: String,
    override val summary: String
) : PromptContributor, Page

Properties:

  • url: String - News story URL (from Page)
  • title: String - News story title
  • summary: String - Story summary (from Page)

Interfaces:

  • PromptContributor - Provides contribution(): String for LLM prompts
  • Page - Web page with url and summary

Methods:

  • contribution(): String - Returns formatted news story (Title, Summary, URL)

Note: Open class - can be extended with additional properties.

RelevantNewsStories

Container for multiple news stories.

open class RelevantNewsStories(
    val items: List<NewsStory>
) : PromptContributor

Properties:

  • items: List<NewsStory> - List of news stories

Interfaces:

  • PromptContributor - Provides contribution(): String for LLM prompts

Methods:

  • contribution(): String - Returns joined contributions from all stories, or "No relevant news stories found." if empty

Note: Open class - can be extended.

Basic Usage

Creating NewsStory

import com.embabel.agent.domain.library.NewsStory

val story = NewsStory(
    url = "https://example.com/news/ai-breakthrough",
    title = "Major Breakthrough in AI Agent Planning",
    summary = "Researchers developed a new planning algorithm improving agent decision-making."
)

// Access properties
println(story.url)      // URL
println(story.title)    // Title
println(story.summary)  // Summary

Creating RelevantNewsStories

import com.embabel.agent.domain.library.RelevantNewsStories
import com.embabel.agent.domain.library.NewsStory

val newsStories = RelevantNewsStories(
    items = listOf(
        NewsStory(
            url = "https://example.com/story1",
            title = "AI Agents Transform Enterprise",
            summary = "Companies report efficiency gains..."
        ),
        NewsStory(
            url = "https://example.com/story2",
            title = "New Planning Algorithm Released",
            summary = "GOAP-based planning shows promise..."
        ),
        NewsStory(
            url = "https://example.com/story3",
            title = "Spring AI Integration",
            summary = "Framework integration improves DX..."
        )
    )
)

// Access stories
newsStories.items.forEach { story ->
    println(story.title)
}

LLM Integration

Single Story

val story = NewsStory(
    url = "https://tech.example.com/quantum",
    title = "Quantum Computing Milestone",
    summary = "IBM announces 1000-qubit processor"
)

val contribution = story.contribution()
// Returns:
// Title: Quantum Computing Milestone
// Summary: IBM announces 1000-qubit processor
// URL: https://tech.example.com/quantum

val prompt = """
    Consider this news:
    ${story.contribution()}

    What are the implications?
""".trimIndent()

Multiple Stories

val news = RelevantNewsStories(items = listOf(...))

val allNews = news.contribution()
// Returns:
// Title: AI Agents Transform Enterprise
// Summary: Companies report efficiency gains...
// URL: https://example.com/story1
//
// Title: New Planning Algorithm Released
// Summary: GOAP-based planning shows promise...
// URL: https://example.com/story2
//
// Title: Spring AI Integration
// Summary: Framework integration improves DX...
// URL: https://example.com/story3

Empty Collection

val emptyNews = RelevantNewsStories(items = emptyList())

val contribution = emptyNews.contribution()
// Returns: "No relevant news stories found."

// Use in logic
if (emptyNews.items.isEmpty()) {
    println("No news to report")
} else {
    println(emptyNews.contribution())
}

Filtering and Processing

val allStories = RelevantNewsStories(
    items = listOf(
        NewsStory("https://ex.com/1", "AI Breakthrough", "New algorithm..."),
        NewsStory("https://ex.com/2", "Cloud Security", "Best practices..."),
        NewsStory("https://ex.com/3", "Agent Planning", "GOAP improvements...")
    )
)

// Filter by keyword
val aiStories = RelevantNewsStories(
    items = allStories.items.filter { "AI" in it.title || "Agent" in it.title }
)

// Top N stories
val topStories = RelevantNewsStories(
    items = allStories.items.take(2)
)

// Transform summaries
val enhanced = RelevantNewsStories(
    items = allStories.items.map { story ->
        NewsStory(
            url = story.url,
            title = story.title,
            summary = "${story.summary} [More: ${story.url}]"
        )
    }
)

Extending NewsStory

import java.time.Instant

class CategorizedNewsStory(
    url: String,
    title: String,
    summary: String,
    val category: String,
    val publishDate: Instant,
    val source: String
) : NewsStory(url, title, summary) {

    override fun contribution(): String =
        super.contribution() +
        "\nCategory: $category\nSource: $source\nDate: $publishDate"
}

val story = CategorizedNewsStory(
    url = "https://example.com/tech-news",
    title = "New AI Framework",
    summary = "Framework for building agents...",
    category = "Technology",
    publishDate = Instant.parse("2026-02-06T10:00:00Z"),
    source = "TechCrunch"
)

JSON Serialization

import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper

val mapper = jacksonObjectMapper()

// Single story
val story = NewsStory(
    url = "https://example.com/article",
    title = "Breaking News",
    summary = "Important developments..."
)

val json = mapper.writeValueAsString(story)
val deserialized = mapper.readValue(json, NewsStory::class.java)

NewsStory JSON Format:

{
  "url": "https://example.com/article",
  "title": "Breaking News",
  "summary": "Important developments..."
}

RelevantNewsStories JSON Format:

{
  "items": [
    {
      "url": "https://ex.com/1",
      "title": "Title 1",
      "summary": "Summary 1"
    },
    {
      "url": "https://ex.com/2",
      "title": "Title 2",
      "summary": "Summary 2"
    }
  ]
}

Complete Workflow

import com.embabel.agent.domain.library.*

// Agent finds news stories
fun findNewsStories(topic: String, count: Int): RelevantNewsStories {
    // Real agent would use web search
    val stories = listOf(
        NewsStory(
            url = "https://example.com/news1",
            title = "Latest in $topic",
            summary = "Recent developments..."
        ),
        NewsStory(
            url = "https://example.com/news2",
            title = "$topic Trends",
            summary = "Industry experts predict..."
        )
    ).take(count)

    return RelevantNewsStories(items = stories)
}

// Use in agent
val aiNews = findNewsStories("AI Agents", 5)

// Generate summary with LLM
val prompt = """
    Based on these news stories:
    ${aiNews.contribution()}

    Summarize key trends.
""".trimIndent()

// Process result
if (aiNews.items.isNotEmpty()) {
    // Process with LLM...
} else {
    println("No news found")
}

Integration with Other Types

Blog from News

fun createBlogFromNews(
    news: RelevantNewsStories,
    author: String
): Blog {
    val content = news.items.joinToString("\n\n") { story ->
        "## ${story.title}\n\n${story.summary}\n\n[Read more](${story.url})"
    }

    return Blog(
        title = "This Week in AI",
        author = author,
        content = "# Latest News\n\n$content",
        keywords = setOf("news", "ai", "weekly")
    )
}

Research with News

fun enrichResearchWithNews(
    report: ResearchReport,
    news: RelevantNewsStories
): String {
    return """
        ${report.contribution()}

        ## Recent News
        ${news.contribution()}
    """.trimIndent()
}

News Summary

fun summarizeNews(stories: RelevantNewsStories): Summary {
    if (stories.items.isEmpty()) {
        return Summary("No news available")
    }
    val topics = stories.items.joinToString(", ") { it.title }
    return Summary("News covering ${stories.items.size} stories: $topics")
}
tessl i tessl/maven-com-embabel-agent--embabel-agent-domain@0.3.0

docs

content-types.md

core-concepts.md

external-types.md

index.md

installation.md

integration-patterns.md

json-serialization.md

news-types.md

person-types.md

quick-reference.md

research-types.md

summary-type.md

tile.json