Implemented the next missing parity slice around clearing session env vars on /clear.

Wires clear_session_env_vars() into LocalCodingAgent.clear_runtime_state so the
/clear slash command now drops session-scoped env vars alongside the rest of the
ephemeral runtime state, matching commands/clear/caches.ts:127.
This commit is contained in:
Abdelrahman Abdallah
2026-04-20 00:52:28 +02:00
parent 72e6fffb34
commit cfd3bb9ca7
3 changed files with 25 additions and 1 deletions
+21
View File
@@ -318,6 +318,27 @@ class AgentRuntimeTests(unittest.TestCase):
self.assertEqual(result.tool_calls, 0)
self.assertIn('# Permissions', result.final_output)
def test_clear_runtime_state_drops_session_env_vars(self) -> None:
from src.session_env_vars import (
clear_session_env_vars,
get_session_env_vars,
set_session_env_var,
)
clear_session_env_vars()
try:
with tempfile.TemporaryDirectory() as tmp_dir:
agent = LocalCodingAgent(
model_config=ModelConfig(model='Qwen/Qwen3-Coder-30B-A3B-Instruct'),
runtime_config=AgentRuntimeConfig(cwd=Path(tmp_dir)),
)
set_session_env_var('CLAW_CLEAR_TEST', 'before')
self.assertEqual(get_session_env_vars()['CLAW_CLEAR_TEST'], 'before')
agent.clear_runtime_state()
self.assertNotIn('CLAW_CLEAR_TEST', get_session_env_vars())
finally:
clear_session_env_vars()
def test_agent_persists_session_and_can_resume(self) -> None:
responses = [
{