Skip to content

Lesson 04 agent loop - #6

Merged
mjesar merged 10 commits into
masterfrom
lesson-04-agent-loop
Oct 12, 2026
Merged

mjesar merged 10 commits into
masterfrom
lesson-04-agent-loop

Conversation

@mjesar

@mjesar mjesar commented Oct 12, 2026

Copy link
Copy Markdown
Owner

Lesson 4 writes the agent loop by hand so I understand what RubyLLM's chat.ask does inside. It is a small loop: ask the model, run the tools it asks for, add the results, repeat until it answers. It has a step limit, handles unknown tools and bad JSON arguments, and keeps a trace of each run.

To check it, I asked the same question through this loop and through SupportAgent, and both made the same tool call. The app keeps using RubyLLM from here on, and the hand-written version stays as a documented lesson.

Tests use a fake client for the loop logic, plus one recorded run against the real model.

@mjesar mjesar self-assigned this Oct 12, 2026
@mjesar
mjesar merged commit d310730 into master Oct 12, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant