Metacognitive AI,
block by block
the Xemantic open-source
Kotlin ecosystem
Idiomatic Kotlin expresses meaning close to natural language —
our mission is to make it a fundamental language of AI development.
https://xemantic.com/ai
Kazik Pogoda
email
- applied philosophy
- AI research
- harness engineering
- humanistic computation
we code a lot, but focus on meanings much more than on words
https://xemantic.com
From words to deeds
A language model alone can only speak. Everything that follows exists to let it act.
Small building blocks — each open source, written in Kotlin, and built upon the previous ones.
A grammar of truth
message should {
have(id == 42)
content[0] should {
be<Text>()
have("Hello" in text)
}
}
before we trust a machine's work, we must agree on what "correct" means — a test that reads like a sentence
https://github.com/xemantic/xemantic-kotlin-test
When a test fails, it explains itself
MediaType(type=image/jpeg)
should:
have(type == "image/png")
| |
| false
image/jpeg
the failure is a diagram, not a riddle — readable by humans, and by AI agents fixing their own code
Comparing meaning, not characters
"""{"foo":"bar","baz":42}""" sameAsJson """
{
"foo": "bar",
"baz": 42
}
"""
this assertion passes — the two documents differ in every byte, yet carry the same JSON semantics
A failure the agent can comprehend
<test-failure
test="JsonTest.foo sameAsJson bar()"
platform="jvm">
<message>
--- expected
+++ actual
@@ -1,4 +1,4 @@
{
- "foo": "bar",
+ "foo": "qux",
"baz": 42
}
</message>
<stacktrace>…redacted…</stacktrace>
</test-failure>
what should your coding AI agent see when this assertion fails? precision reduces cognitive load and token costs — improving speed and quality of reasoning
AX — Agent Experience
- DX designed libraries for developers
- AX designs them for AI agents as first-class users
- the agent writes code, runs the test, reads the failure, corrects itself
the clearer the error speaks, the shorter the loop
Teaching machines to fill forms
@Serializable
@Title("The full address")
data class Address(
val street: String,
val city: String,
val postalCode: String
)
val schema = jsonSchemaOf<Address>()
a Kotlin class becomes a form the model knows how to fill — no hand-written JSON Schema
https://github.com/xemantic/xemantic-ai-tool-schema
Hello, Claude
val anthropic = Anthropic()
val response = anthropic.messages.create {
+"Hello, Claude"
}
println(response)
one codebase talks to Claude from servers, browsers, phones and robots — JVM, JS, WebAssembly, Android, iOS, Linux, macOS, Windows
https://github.com/xemantic/anthropic-sdk-kotlin
Your own claude.ai
val anthropic = Anthropic()
val context = mutableListOf<Message>()
while (true) {
print("[user]> ")
val input = readln()
if (input == "exit") break
context += Message { +input }
println("...Thinking...")
val response = anthropic.messages.create {
messages = context
}
context += response
println("[assistant]> ${response.text}")
}
simpler than Python — this is why Xemantic is using Kotlin for teaching AI development
Giving the model hands
@Description("Get the weather for a location")
data class GetWeather(val location: String)
val toolbox = Toolbox {
tool<GetWeather> {
"The weather in $location is 23°C"
}
}
the schema block from three slides ago is quietly at work here — blocks building upon blocks
Machines think in streams
flowOf(llmOutput)
.parse()
.transform {
match("h1") { "h2" { children() } } // demote headings
passthrough()
}
.render()
markanywhere turns Markdown into a stream of semantic events — rendered live, while the model is still speaking
https://github.com/xemantic/markanywhere
Full circle
flowOf("# Hello, *world*\n")
.parse()
.render() sameAs """
<h1>Hello, <em>world</em></h1>
"""
the assertion DSL from the first block now tests the streaming engine — and this very website is rendered by it
Documents as semantic events
val page = semanticEvents(tagged = true) {
"body" {
"h1" { +"Weather" }
"p" {
"i"("class" to "fa-solid fa-sun") { }
+" Sunny and "
"strong" { +"warm" }
+" today — see the "
"a"("href" to "https://example.com/forecast") { +"forecast" }
}
"script" { +"track('view')" }
}
}
println(page.transformHtmlToMarkdown().renderMarkdown())
# Weather
☀️ Sunny and **warm** today — see the [forecast](https://example.com/forecast)
the icon becomes an emoji, the script disappears — meaning survives, noise does not
Umwelt
The web as your AI agent's Umwelt — every page transduced into the language a model natively perceives.
Let your AI agent fill in your tax forms on the web — without taking a single screenshot, with real browser instances behind, rendering JavaScript.
markanywhere at full power — coming soon at umwe.lt, together with an Agent Skill
https://github.com/xemantic/umwelt
Memory needs a graph
neo4j.flow(
"MATCH (p:Person) RETURN p ORDER BY p.name"
).collect {
println(it["p"]["name"].asString())
}
a coroutines adapter for the Neo4j graph database — knowledge streams out of memory the same way it streams out of models
https://github.com/xemantic/xemantic-neo4j-kotlin-driver
Claudine
the blocks become an agent
The older sister of Claude Code, which won AI Hack Berlin 2024 at Google — your machine as its window to the world, five tools suffice.
today used purely for teaching harness engineering — the whole agent is a single Kotlin file of 229 lines
https://github.com/xemantic/claudine
Golem XIV
The ecosystem
plus supporting cast: xemantic-ai-money, xemantic-ai-file-magic, and more
https://github.com/xemantic
Why Kotlin?
- one codebase — every platform, from server to wristwatch
- coroutines & flows — streams of thought, natively
- DSLs that read like the tale itself, to humans and models alike
- a type system that keeps code-writing machines honest
Built to last
- continuous integration across all platforms
- binary-compatibility guarded releases
- semantic versioning to Maven Central
- permissive open-source licenses
- AX — agents co-maintain the code they are made of
The road ahead
- markanywhere 1.0 — streaming Markdown for every LLM interface
- Umwelt at umwe.lt — the whole web transduced for machines
- Golem XIV — open research into metacognitive harnesses
- workshops & science hackathons — teaching with these very blocks in the Claude Ambassador role
https://xemantic.com/ai/workshops/
Blocks all the way up
From a one-line assertion to a harness that reflects on its own reasoning — every block open, every block composable.
Open source, open ended — fork it.
https://github.com/xemantic
Kazik Pogoda ·
email
with the assistance of Claude