Skip to content

Add LLM::Agent#113

Merged
0x1eef merged 2 commits intomainfrom
agent
Feb 15, 2026
Merged

Add LLM::Agent#113
0x1eef merged 2 commits intomainfrom
agent

Conversation

@0x1eef
Copy link
Member

@0x1eef 0x1eef commented Feb 14, 2026

The LLM::Agent class provides a class-level DSL for defining reusable,
preconfigured assistants with defaults for model, tools, schema, and
instructions. Instructions are injected only on the first request.

This idea originally came from RubyLLM and was adapted to llm.rb.

@0x1eef 0x1eef force-pushed the agent branch 3 times, most recently from 8dab031 to e20f457 Compare February 15, 2026 00:20
The LLM::Agent class provides a class-level DSL for defining reusable,
preconfigured assistants with defaults for model, tools, schema, and
instructions. Instructions are injected only on the first request.

This idea originally came from RubyLLM and was adapted to llm.rb.
if LLM::Builder === prompt
messages = prompt.to_a
builder = LLM::Builder.new do |builder|
builder.system instr unless @instructions_applied
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Won't work with Gemini.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed by 3291f3a

builder.tap(&:call)
else
build_prompt do
_1.system instr unless @instructions_applied
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Won't work with Gemini.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed by 3291f3a

Gemini does not support the 'system' role so the
prompt builder will map it to the 'user' role
instead.

This allows us to write the same code for Gemini,
OpenAI, etc. without worrying about the underlying
differences between the two.

Ref #111
@0x1eef 0x1eef merged commit 20660da into main Feb 15, 2026
12 checks passed
@0x1eef 0x1eef deleted the agent branch February 15, 2026 01:45
@antaz
Copy link
Collaborator

antaz commented Feb 16, 2026

@0x1eef This is great 🔥

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.

2 participants

Comments