In the presentation An Algebra of Thoughts: When Kyo effects meet LLMs, Flavio Brasil discusses his innovative work with the Kyo Scala library, designed to streamline the interaction between functional programming and large language models (LLMs). The presentation covers the innovative features of Kyo, which aims to simplify API usability while enhancing performance through composable effects and improved type inference. Flavio emphasizes the importance of managing various computational effects, such as IO and asynchronous operations, while ensuring the concepts remain accessible to newcomers. He details new primitives aimed at facilitating interactions with LLMs, including structured inputs and dynamic prompts, ultimately advocating for a careful approach to effect management for creating advanced AI applications. The talk concludes with Flavio’s reflections on the ongoing development of Kyo and plans for future enhancements, as well as a commitment to shared resources for community learning.
An Algebra of Thoughts: When Kyo effects meet LLMs: A comprehensive overview
AI needs effects, too
Working with LLMs is inherently messy. Code often becomes monolithic and experimental tweaks are hard to manage. Flavio Brasil proposes a better alternative: using algebraic effects to break down AI interactions into composable, testable units.
Here’s what that looks like in practice:
- AI Effects: Specialized building blocks for prompt generation, context management, and streaming responses.
- Composable prompts: Instead of writing one giant string, prompts are built and transformed dynamically with logic.
- Structured thinking: Injecting planning steps into LLM behavior, such as “opening thoughts” and “closing thoughts” that guide and validate the output.
- Parallel sampling: Running multiple generations concurrently and combining them (e.g., to synthesize reviews or plans).
- Reminders & tools: Injecting summarized context or dynamic tools into prompts without rewriting everything.
In essence, he’s treating AI workflows like software, applying the same rigor and modularity you’d find in a production backend system.
Real-world capabilities
Flavio showcases some real-world capabilities built on this system:
- Recipe generation: Building recipes from structured user input, including ingredients, with parallel review generation and summary synthesis.
- Prompt interceptors: Customizing how prompts are formatted or intercepted, allowing domain-specific overrides.
- Forgetfulness and isolation: Context can be “forgotten” to avoid bleeding information between tasks — like a transactional reset.
- Tool-based agents: LLM agents enhanced by tools like web browsing, graph databases (Neo4j), and context-aware instructions.
He also introduces a prototype MCP (multi-component platform) server that hosts these LLM tools in isolation using containerized environments — ensuring safety and flexibility at scale.
From Scala to Co-pilot
Flavio also shares his side project: a Scala-specific co-pilot tool that uses Kyo’s principles to build domain-aware LLM interactions. Think of it as GitHub Copilot meets Scala’s type system, optimized for developer workflows.
Looking ahead, he envisions a stable Kyo 1.0 release, better integration with LLMs, and a smoother learning path for developers. He’s also releasing a new educational repository to help onboard users with progressive complexity.
Key takeaways
- Composable effects make LLM programming easier to scale, test, and evolve.
- Kyo abstracts functional complexity while preserving the benefits of type safety and performance.
- Structured prompt engineering — with planning, validation, and modularity — is a major leap forward in controlling LLM behavior.
- LLM workflows deserve the same software engineering rigor as any other backend system.
Flavio closes with a reflection on his journey — from Smalltalk to Java, then Scala, and now building open-source tooling to help AI practitioners apply FP principles without the overhead. Kyo is his passion project, and “An Algebra of Thoughts” is both a philosophy and a working toolkit for the next generation of AI systems.