The Kotlin-native AI agent harness for the JVM.
Bring your own LLM. Ship an agent in a few lines, not three weeks.
suspend fun main() {
val runtime = Sophi.runtime {
provider = buildOpenAiCompatProvider(
baseUrl = "http://localhost:11434/v1",
apiKey = null, model = "qwen3:8b")
}
println(runtime.turn(runtime.newSession(), "What changed since the last tag?"))
}
Apache 2.0 · Kotlin on JDK 21+ · 19 Maven modules · Any LLM provider
- sophi-core
- sophi-ai
- sophi-sdk
- sophi-skills
- sophi-extensions
- sophi-learning
- sophi-store
- sophi-versioning
- sophi-memory
- sophi-context
- sophi-mcp
- sophi-hub
- sophi-gateway
- sophi-gateway-discord · new
- sophi-schedule
- sophi-calendar · new
- sophi-cli
- sophi-web
- sophi-infra
What you get that a plain LLM client doesn't.
One agent loop, with the parts real agents need already built in. Each is a line in the builder.
Any model, local or cloud
Claude, or any OpenAI-compatible server, including local ones like Ollama and LM Studio. Switching is one line, not a rewrite.
- No framework lock-in: one small provider interface
- Run fully offline against a local model
- You state the context window; SoPhi compacts at 80%
val runtime = Sophi.runtime {
provider = buildOpenAiCompatProvider(
baseUrl = "http://localhost:11434/v1",
apiKey = null,
model = "qwen3:14b",
)
contextWindowTokens(32_768)
}
Learns from use, plans and replans
Tool reliability stats and lessons distilled at the end of each session. Explicit multi-step goals, with every plan version logged.
- Lessons recalled in the next session
- /good and /bad feedback that sticks
- Plan progress as events your UI can draw
val runtime = Sophi.runtime {
// provider, contextWindowTokens …
learning(LearningConfig())
goalDecomposition(Path.of(".sophi/plans")) { event ->
println(event)
}
}
Your tools, MCP and skills
Implement one interface for your own tools, call any MCP server, and load capabilities from plain Markdown skill files.
- Risk levels and confirmation built in
- MCP servers connect and disconnect at runtime
- Skills the agent can install, and write itself
val runtime = Sophi.runtime {
// provider, contextWindowTokens …
tool(WeatherTool())
mcpConfig(Path.of("mcp.json"))
skillTools()
}
It knows your schedule
Six calendar tools on your system calendar: list calendars, list, read, create, update and delete events. Attendees and call links come with each event.
- Add them with one line in the builder
- Changes go through the same confirmation as every tool
- Recurring events understood
val runtime = Sophi.runtime {
// provider, contextWindowTokens …
calendarTools(buildCalendarProvider()).forEach { tool(it) }
}
runtime.turn(session, "Move my 3pm with Ana to Friday")
Reach your agent from Discord
A gateway module pairs one Discord user with your agent. Their DMs become turns; permissions, questions and plans come back as buttons. Voice notes and photos work too.
- Pairing by a one-time code
- Only the paired user is heard
- The gateway knows nothing of your host: bind it to any agent
An agent you can leave running.
Three guards in the loop itself, not bolted on. Pick one to watch it work.
Everything else an agent needs.
- MemoryLong-term memory in threads, places and a profile.
- Crash-safe sessionsAppend-only, branchable session files. Resume anywhere.
- Streaming eventsTokens, tool calls and confirmations as they happen.
- SubagentsDelegate work to agents you define in plain files.
- SchedulesGoals that run on a timer, unattended and guarded.
- ContextCompaction and recall that keep long sessions sharp.
- VersioningWhat the agent produces keeps its history, with revert.
- RedactionSecrets stripped from logs and reports.
Three ways to run it.
Same core every time, so switching later is a one-line change, not a rewrite.
val runtime = Sophi.runtime {
provider = buildClaudeProvider(System.getenv("ANTHROPIC_API_KEY"), model = System.getenv("SOPHI_MODEL"))
contextWindowTokens(200_000)
tool(MyCustomTool())
}
val reply = runtime.turn(runtime.newSession(title = "release-check"), "What changed since the last tag?")
mvn -pl sophi-cli -am package
sophi --provider openai-compat --base-url http://localhost:11434/v1 --model qwen3:14b --context-window-tokens 32768
/goal --check "mvn test" fix the failing build
mvn -pl sophi-web -am spring-boot:run
curl -X POST localhost:8080/api/sessions
curl -N "localhost:8080/api/sessions/<id>/stream?input=hello" # SSE
Build it from source.
Needs JDK 21+ and Maven. Maven Central coming soon.
git clone https://github.com/shukriev/SoPhi
cd SoPhi
mvn -q -DskipTests install
Your meetings, your day, your home. Handled.
SophiLoop is the private assistant built on this harness. It sits in on your calls, keeps your promises, brings you your day and runs your devices, with everything stored on your machine.
Meeting notesMorning briefHome devicesPromisesThe engineering, one decision at a time.
- Why we built a Kotlin agent harness instead of using oneThe case for owning the loop on the JVM.
- The agent loop: a first-principles designThe core every other module builds on.
- From inert files to self-writing skills: evolving an AI agent's skill systemSkills that start as Markdown and end up writing themselves.
All articles → How SoPhi compares to Koog, LangChain4j and Spring AI →