Skip to content

Ruby SDK #55

Open
Open

Description

@zlareb1

We'd like a Ruby gem for Loom, so Rails apps adding agent features can use it directly, whether they build on RubyLLM, langchainrb or plain model calls from background jobs.

Scope:

  • gem "clickhouse-loom", Ruby 3.1+
  • Methods generated from the op registry (client.memory.set(...), client.memory.search(...)), so new ops show up without being written by hand
  • Config via Loom.configure or LOOM_BASE_URL / LOOM_API_KEY
  • Org / namespace / agent bound once, with per-call overrides
  • The same retry and idempotency behavior as the other SDKs (Idempotency-Key, honor Retry-After), and an error class per server code (Loom::PinnedConflict, Loom::RateLimited, ...)
  • Minimal dependencies: Faraday or net/http only

We'll also ship a small Rails example: per-user memory written from a Sidekiq job.

Activity

  1. added
    enhancement
    on Oct 16, 2026
  2. rahulsjha commented on Nov 21, 2026

    @rahulsjha
    Contributor

    Hi @zlareb1, I'd like to work on this. I'd build the clickhouse-loom Ruby gem with methods generated from the op registry, Loom.configure / env config, and org, namespace and agent binding, with specs against a local Loom. Okay if I pick it up?

  3. zlareb1 commented on Nov 22, 2026

    @zlareb1
    MemberAuthor

    @rahulsjha since this is a big task and requires 100% match with Python and TS SDKs lets break it down into multiple small PRs

  4. rahulsjha commented on Nov 22, 2026

    @rahulsjha
    Contributor

    Thanks @zlareb1, agreed. #1127 (now merged) is the first slice: the op table and error classes generated from the registry, Loom.configure / LOOM_BASE_URL / LOOM_API_KEY, org / namespace / agent bound once with per-call overrides, and retries with Idempotency-Key and Retry-After.

    Comparing sdk/ruby with sdk/typescript/src and sdk/python/loom, this is what is still missing for a full match. I'd send it as one small PR per line, each with its own tests that mirror the TS and Python ones:

    1. Pagination: client.paginate / an Enumerator over the rows / results + next_cursor pages, with max_pages, the same as pagination.ts.
    2. Logging: an opt-in logger with the same redaction rules as logging.ts and _logging.py (API key and tokens never logged).
    3. Credentials and tokens: the token and credential handling from token.ts / credentials.py, beyond the static API key.
    4. Sessions and session protection: session.ts / session-protection.ts and the protected stream they use.
    5. Parity check: a codegen unit test that fails when the Ruby op table or error codes drift from the registry the Python and TS SDKs use, so "100% match" stays checked rather than reviewed by eye.
    6. Ruby CI job: run sdk/ruby tests on Ruby 3.1 and 3.3 in ci.yml (today they only run locally).
    7. Rails example: per-user memory written from a Sidekiq job, as the issue describes.
    8. Framework integrations: RubyLLM, then langchainrb, one PR each, after the core above is in.

    I'd start with 1 (pagination), since 4 and the examples build on it. If you'd rather a different order, or want any line dropped or split further, say so and I'll follow that.

  5. rahulsjha commented on Nov 24, 2026

    @rahulsjha
    Contributor

    @zlareb1 the first item of the list is up: #1296 adds cursor pagination to the Ruby SDK (client.paginate { |cursor| ... }, a lazy Enumerator, as paginate in pagination.ts), with 8 tests. Could you take a look when you have time? Next I'll do the opt-in logger with the same redaction rules as logging.ts.

  6. zlareb1 commented on Nov 27, 2026

    @zlareb1
    MemberAuthor

    @rahulsjha are you working on remaining items here?

  7. rahulsjha commented on Nov 27, 2026

    @rahulsjha
    Contributor

    @zlareb1 yes, I'm still on it. Pagination (#1296) is merged, and I'm starting item 2 now: the opt-in logger, with the same redaction rules as logging.ts and _logging.py. I'll post the PR here when it's up, then continue down the list in order (credentials and tokens, then sessions).

  8. rahulsjha commented on Nov 27, 2026

    @rahulsjha
    Contributor

    @zlareb1 item 2 is up: #1624 adds opt-in logging to the Ruby SDK, with the same lines, levels and API-key redaction as logging.ts and _logging.py. Could you take a look when you have time? Next is item 3, credentials and tokens.

  9. rahulsjha commented on Nov 28, 2026

    @rahulsjha
    Contributor

    @zlareb1 the first half of item 3 is up: #1697 adds a token_provider (asked on every request, and resent once on a 401) and the ~/.loom/token fallback to the Ruby SDK. The stored loom login session, refreshed under the lock the Python and TS SDKs share, comes next as its own PR on top of it.

  10. zlareb1 commented on Dec 3, 2026

    @zlareb1
    MemberAuthor

    @rahulsjha what else is pending in SDK to bring it to 100% parity with other SDKs?

  11. rahulsjha commented on Dec 3, 2026

    @rahulsjha
    Contributor

    @zlareb1 I compared sdk/ruby with the TypeScript SDK's exports on main. The Ruby gem has the generated ops and error classes, the client-bound identity, retries with Idempotency-Key and Retry-After, pagination, logging, a token provider and ~/.loom/token. Still missing for parity, roughly in the order I'd do them:

    Credentials

    1. Stored loom login session: login, logout, whoami, and the refresh under the lock the Python and TS SDKs share (next PR, on top of Ruby SDK: a token provider resent once on a 401, and ~/.loom/token #1697).
    2. Machine login for bots and CI (loom bot create, LOOM_CLIENT_ID) as a token provider, like MachineLogin.
    3. Token claims: decode the JWT payload and role_on / role_satisfies for scoped tokens.
    4. The account's own tokens (list, create, revoke), as account.ts does.

    Transport

    1. The X-Loom-Runtime header (ruby/3.3.6 x86_64-linux).
    2. A capabilities probe over ops.capabilities, so an app can check the ops and fields it needs before calling.

    Higher-level helpers

    1. Agent / Datapack, the identity-bound entry points.
    2. Session: resume, append turns, offload a large tool result and fetch it back.
    3. Knowledge files: knowledge.upload with the raw bytes, then knowledge.ingest and a wait for the revision.
    4. Assistant streaming over POST /v1/assistant/chat/completions.
    5. Loom as model tools (remember, recall, ask, offload, fetch) in the shapes RubyLLM and langchainrb expect, plus the code pointer block for task prompts.

    From the issue scope

    1. The Rails example: per-user memory written from a Sidekiq job.

    The TS SDK's framework integrations (LangChain, Mastra, ADK and so on) have no direct Ruby counterparts, so I'd cover RubyLLM and langchainrb through item 11 and not port those. Shall I go in this order, one PR each?

  12. rahulsjha commented on Dec 3, 2026

    @rahulsjha
    Contributor

    @zlareb1 a correction to my list above: I won't be able to pick up the remaining Ruby SDK items for now, so please treat them as open. The list should still work as a checklist for whoever takes them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions