AI Agent as a Function
summary
Live coding builds an AI agent from scratch using Kotlin, http4k, and Claude API, starting from a simple API call and adding prompts, conversation memory, and tools. Implements caching and request streaming (a two‑line cache filter), a message‑completion loop that detects tool_use events, tools to read/list/write files and run Gradle tests, an NDJSON message store for session memory, auto‑commit and a Gradle run tests tool; refactors the loop into an agent function with composable filters and the tool‑call loop, and the features execute end‑to‑end.
AI-written summary · about
chapters (16)
- 0:00Introduction to AI agents
- 1:06H24K basics and setup
- 4:13Anthropic API integration
- 8:04Message completion loop
- 10:08Defining tools for agents
- 12:34Tool calling workflow
- 17:27Creating the agent loop
- 22:07Adding Gradle test tool
- 24:36Rendering agent outputs
- 26:04Implementing session memory
- 29:09Refactoring to agent as function
- 32:18Adding skill support
- 35:09Auto-committing agent
- 36:57Memory tools implementation
- 38:22Self-improving agent filter
- 39:27Summary and key takeaways
