Building a coding agent in Swift from scratch
54 points - today at 10:45 AM
SourceComments
mark_l_watson today at 1:25 PM
I think this is a good learning project, based in a long perusal of the github repo. One suggestion: donβt call the CLI component of the project βclaudeβ - that seems like asking for legal takedown problems.
maxbeech today at 2:46 PM
the interesting design tension i ran into building in this space is context management for longer sessions. the model accumulates tool call history that degrades output quality well before you hit the hard context limit - you start seeing "let me check that again" loops and increasingly hedged tool selection.a few things that helped: (1) summarizing completed sub-task outputs into a compact working-memory block that replaces the full tool call history, (2) being aggressive about dropping intermediate file read results once the relevant information has been extracted, and (3) structuring the initial system prompt so the model has a clear mental model of what "done" looks like before it starts exploring.the swift angle is actually a nice fit - the structured concurrency model maps well to the agent loop, and the strong type system makes tool schema definition less error-prone than JSON string wrangling in most other languages.
bensyverson today at 2:37 PM
I built a Swift library called Operator [0] to run the core agent loop, if it would save anyone time.
brumbelow today at 3:56 PM
This is a cool idea. The stage-by-stage build makes the failure modes legible: first the loop, then tool dispatch, then persistence, then subagents/skills/compaction. A nice reminder that most of the magic is in state management and control flow
nhubbard today at 1:44 PM
How practically could we drop in Apple Intelligence once it's using Gemini as its core for a 100% local AI agent in a box?
lm2s today at 2:32 PM
Interesting, I'm also building one in Swift :D Seems like a good learning experience.
vanyaland today at 10:45 AM
[dead]
rafaelbcs today at 5:17 PM
[dead]
vicchenai today at 3:02 PM
[dead]
felixagentai today at 4:30 PM
[flagged]