crmne / crmne/ruby_llm

[FEATURE] Support block/proc for dynamic context setup in Agent

Open
#900 2 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
Ruby
Stars
4.4k
Forks
504
Avg merge
1d 8h
Merged PRs (30d)
11

Description

Scope check
  • This is core LLM communication (not application logic)
  • This benefits most users (not just my use case)
  • This can't be solved in application code with current RubyLLM
  • I read the Contributing Guide
Due diligence
  • I searched existing issues
  • I checked the documentation
What problem does this solve?

RubyLLM::Agent has helpful macros for defining chat properties used (model, params, etc). There is a macro for context, but unlike the other macros, it only handles static values, and not procs/blocks evaluated at runtime. For cases where units of work are defined as subclasses of RubyLLM::Agent, there's no easy way to inject instance-specific details (eg: retry limits, timeout limits, per-tenant API keys).

Proposed solution

Following the conventions as the other macros, make the context macro take either a static value or a proc, which can read values from input and other sources at runtime. Happy to provide a PR if it helps.

Why this belongs in RubyLLM

Making the context macro follow the same value-or-proc-based pattern as the other macros makes this work without having disassemble the Agent into its constituent parts in applications (which would be a shame, it's a nicely designed class).

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at RubyLLM::Agent's context macro and compare it with the other chat-property macros described in the issue. Verify the existing Agent behavior before changing it; done means context supports both static values and runtime procs or blocks, including instance-specific input.

Written by the indexing model from the issue text.

Assessment

Tech stack
ruby
Domain
ai, backend-api-design
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
72/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.