Skip to content

fix environment_kwargs None handling and add anthropic dependency - #3

Closed
XiaoConstantine wants to merge 3 commits into
alexzhang13:mainfrom
XiaoConstantine:fix/environment-kwargs-none-handling
Closed

XiaoConstantine wants to merge 3 commits into
alexzhang13:mainfrom
XiaoConstantine:fix/environment-kwargs-none-handling

Conversation

@XiaoConstantine

Copy link
Copy Markdown
Contributor

Following readme getting some errors:

  • Handle None for environment_kwargs in RLM.init to allow instantiation without passing empty dict
  • Add anthropic to dependencies (was missing despite having AnthropicClient)

For the readme example, this is essentially get it working for me:

 from rlm import RLM
    ...:
    ...:
    ...:  rlm = RLM(
    ...:       backend="anthropic",
    ...:       backend_kwargs={"model_name": "claude-haiku-4-5",         "api_key":
       ⋮  os.getenv("ANTHROPIC_API_KEY"), "max_tokens": 4096},
    ...:       verbose=True,
    ...:   )

max_tokens needed here because the default value is large enough that streaming is needed.

 ◆ RLM ━ Recursive Language Model ──────────────────────────────────────────────╮
│                                                                                 │
│    Backend                anthropic              Environment           local    │
│    Model                  claude-haiku-4-5       Max Iterations        30       │
│    Max Depth              1                                                     │
│                                                                                 │
╰─────────────────────────────────────────────────────────────────────────────────╯


In [13]: print(rlm.completion("Print me the first 100 powers of two, each on a newl
       ⋮ ine.").response)
──────────────────────────────────  Iteration 1  ──────────────────────────────────
╭─ ◇ LLM Response  (2.77s) ───────────────────────────────────────────────────────╮
│ You're right, let me start by examining the context and understanding what I'm  │
│ working with.                                                                   │
│ ```repl                                                                         │
│ print("Context content:")                                                       │
│ print(context)                                                                  │
│ print(f"\nContext length: {len(context)}")                                      │
│ print(f"Context type: {type(context)}")                                         │
│ ```                                                                             │
│                                                                                 │
│ Now let me see what the context actually contains so I can understand what      │
│ question I need to answer:                                                      │
│ ```repl                                                                         │
│ print(repr(context))                                                            │
│ ```                                                                             │
│                                                                                 │
│ Let me also check if there's a prompt or query associated with this:            │
│ ```repl                                                                         │
│ # Display the context clearly                                                   │
│ print("=== CONTEXT ===")                                                        │
│ print(context)                                                                  │
│ print("=== END CONTEXT ===")                                                    │
│ ```                                                                             │
│                                                                                 │
│ Once I see what the context is, I'll need to:                                   │
│ 1. Understand what question/prompt I'm being asked to answer                    │
│ 2. Analyze the context to find relevant information                             │
│ 3. Use the LLM query functions if needed to extract insights                    │
│ 4. Provide a final answer                                                       │
│                                                                                 │
│ Could you help me see what the actual context and prompt are? The system        │
│ mentioned context is 56 characters, but I need to see the actual content and    │
│ what question I'm supposed to answer.                                           │
│                                                                                 │
│ ~153 words                                                                      │
╰─────────────────────────────────────────────────────────────────────────────────╯
╭─ ▸ Code Execution  (0.000s) ────────────────────────────────────────────────────╮
│ Code:                                                                           │
│ print("Context content:")                                                       │
│ print(context)                                                                  │
│ print(f"\nContext length: {len(context)}")                                      │
│ print(f"Context type: {type(context)}")                                         │
│                                                                                 │
│ Output:                                                                         │
│ Context content:                                                                │
│ Print me the first 100 powers of two, each on a newline.                        │
│                                                                                 │
│ Context length: 56                                                              │
│ Context type: <class 'str'>                                                     │
│                                                                                 │
╰─────────────────────────────────────────────────────────────────────────────────╯

- Handle None for environment_kwargs in RLM.__init__ to allow instantiation without passing empty dict
- Add anthropic to dependencies (was missing despite having AnthropicClient)
@alexzhang13

Copy link
Copy Markdown
Owner

This was mostly handled in a separate PR, thanks for the find! (I also nuked the branch accidentally)

@alexzhang13 alexzhang13 closed this Jan 4, 2026
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