Repository navigation
feat(rlm): allow for passing pydantic models inside an RLM - #9306
Closed
isaacbmiller wants to merge 8 commits into
Closed
isaacbmiller wants to merge 8 commits into
isaacbmiller wants to merge 8 commits into
Conversation
…references. Introduce error handling for unresolved forward references and improve tool registration with TypeAdapters for parameter validation. Update tests to cover Pydantic model integration and error scenarios.
… serialize Pydantic models to JSON. Add tests to verify behavior for tools returning falsy values and Pydantic model outputs.
Collaborator
|
Nice :D |
…on, including improved handling of model types in tool parameters and outputs. Update JSON schema generation and add tests for model serialization and attribute access in the sandbox environment.
Collaborator
Author
|
Closing in favor of smaller PRs |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
RLM executes LLM-generated Python code in a sandboxed Deno/Pyodide interpreter. Host-side "tools" (Python functions) can be called from sandbox code, but arguments and return values cross a JSON serialization boundary. Previously, only simple types (str, int, float, bool) were handled — complex types like Pydantic models were silently ignored.
This PR adds first-class Pydantic model support across the full pipeline:
Tool parameters: dicts from the sandbox are coerced into Pydantic models before the tool is called, via pydantic.TypeAdapter python_interpreter.py:345-347
Tool returns: Pydantic model return values are serialized to JSON dicts before crossing back to the sandbox python_interpreter.py:349-350
Input variables: Pydantic model instances are serialized via model_dump(mode="json") for injection into sandbox code python_interpreter.py:475-476
Output fields: JSON schema metadata is attached to complex output types so the sandbox's SUBMIT() gets proper type hints rlm.py:327-337
Prompt metadata: REPLVariable now includes JSON schema for Pydantic inputs so the LLM understands their structure repl_types.py:77-83
Additionally, tool calls are now kwargs-only (no positional args), variadic tool signatures are rejected, and tool bridge errors in runner.js are returned as structured payloads instead of thrown exceptions (preventing Deno crashes from unhandled rejections).