You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit cb9cab7
Browse filesBrowse the repository at this point in the historyBrowse files
proposal(environments): SupportsPersistence Protocol for multi-turn sessions (#40)
* feat(local-repl): add multi-context support for persistent REPL
* feat(core): add persistent flag for multi-turn REPL conversations
Add persistent=True option to RLM that reuses the environment across
completion() calls instead of creating/destroying for each call. This
enables multi-turn conversations where variables and contexts persist.
- Add persistent parameter to RLM constructor
- Reuse environment when persistent=True, store as _persistent_env
- Add close() method and context manager support (__enter__/__exit__)
- Environment cleanup only on explicit close() when persistent
* feat(prompts): inform model about multiple contexts in multi-turn sessions
Add context_count parameter to build_user_prompt() so the model knows
when multiple contexts are available (context_0, context_1, etc.) during
persistent REPL sessions.
* fix(core): validate environment supports persistent mode before use
Add validation to prevent AttributeError when persistent=True is used
with environments that don't implement the required methods
(update_handler_address, add_context, get_context_count).
- Add _validate_persistent_environment_support() called at init time
- Add _env_supports_persistence() for runtime capability checking
- Add defensive runtime check before calling persistence methods
- Raise clear ValueError if unsupported environment is configured
* feat(local-repl): add message history storage for multi-turn sessions
Store conversation histories as versioned variables (history_0, history_1, etc.)
in the REPL environment, making them accessible for subsequent queries. This
enables models to reference prior conversation context in persistent sessions.
* feat(environments): add persistent parameter to all REPL classes
Add persistent parameter to BaseEnv, IsolatedEnv, and NonIsolatedEnv.
DockerREPL, ModalREPL, and PrimeREPL raise NotImplementedError when
persistent=True since they don't yet support it. LocalREPL passes
the parameter through to the base class.
Also makes DockerREPL cleanup more defensive with hasattr checks.
* test(local-repl): replace multi-context tests with non-persistent simulation tests
Replace TestLocalREPLMultiContext and TestLocalREPLHistory with
TestLocalREPLSimulatingRLMNoPersistence. New tests verify that
environments reset between RLM completions when persistent=False.
* test(local-repl): add persistent mode unit tests
Add TestLocalREPLMultiContext, TestLocalREPLHistory, and
TestLocalREPLPersistentState test classes for LocalREPL's
persistent mode features including multi-context versioning
and message history storage.
* test(rlm): add multi-turn integration tests
Add comprehensive integration tests for persistent RLM sessions:
- Environment reuse across completion calls
- Context and history accumulation
- Variable persistence between completions
- Prompt awareness of contexts/histories
- Resource cleanup on close
- Validation of unsupported environments
* refactor(tests): replace ScriptedMockLM with standard unittest.mock
Remove custom ScriptedMockLM class (58 lines) and replace with
create_mock_lm() helper (14 lines) using standard Mock patterns.
* refactor(environments): add SupportsPersistence Protocol
Replace scattered hasattr checks with a runtime-checkable Protocol
that defines the persistence capability contract. This provides
type checker enforcement and IDE autocomplete support.
* docs(environments): add comprehensive SupportsPersistence Protocol docs
Document expected behavior to implement persistence:
- Versioning behavior (context_0, context_1, ...)
- Aliasing behavior (context -> context_0)
- Method contracts with detailed docstrings
- References to tests and example implementation
* add ruff lint on test
* fix linting on tests
---------
Co-authored-by: Alex Zhang <alex.lx.zhang@gmail.com>
0 commit comments