fix: harden salvaged session and browser improvements
Polish salvaged contributor work before PR review: - read browser inactivity timeout from config with documented fallback - skip redundant v10 trigram backfill before v11 FTS rebuild - show delegate_task goals safely in progress previews - show gateway status model/context without redundant token wording - wire gateway /sessions to shared session-listing helpers - map Ravenwolf author emails for release attribution Co-authored-by: Wolfram Ravenwolf <github.com@wolfram.ravenwolf.de> Co-authored-by: Amy Ravenwolf <amy@ravenwolf.de>
This commit is contained in:
co-authored by
Wolfram Ravenwolf
Amy Ravenwolf
parent
ead38107a2
commit
3e7e9b24d4
@@ -61,6 +61,8 @@ def _make_runner(session_entry: SessionEntry, *, platform: Platform = Platform.T
|
||||
runner._reasoning_config = None
|
||||
runner._provider_routing = {}
|
||||
runner._fallback_model = None
|
||||
runner._agent_cache = {}
|
||||
runner._agent_cache_lock = MagicMock()
|
||||
runner._show_reasoning = False
|
||||
runner._is_user_authorized = lambda _source: True
|
||||
runner._set_session_env = lambda _context: None
|
||||
@@ -209,7 +211,8 @@ async def test_status_command_includes_live_agent_model_and_context():
|
||||
|
||||
assert "**Model:** `openai/gpt-test` (openai)" in result
|
||||
assert "**Context:** 12,345 / 100,000 (12%)" in result
|
||||
assert "**Cumulative API tokens (re-sent each call):** 1,250 (cumulative)" in result
|
||||
assert "**Cumulative API tokens (re-sent each call):** 1,250" in result
|
||||
assert "1,250 (cumulative)" not in result
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@@ -235,16 +238,41 @@ async def test_status_command_includes_persisted_model_and_context_when_agent_no
|
||||
"billing_provider": "openai-codex",
|
||||
"billing_base_url": "https://example.invalid/v1",
|
||||
}
|
||||
monkeypatch.setattr(
|
||||
"agent.model_metadata.get_model_context_length",
|
||||
lambda *_args, **_kwargs: 272_000,
|
||||
)
|
||||
monkeypatch.setattr("gateway.run._load_gateway_config", lambda: {"model": {"context_length": 272_000}})
|
||||
|
||||
result = await runner._handle_message(_make_event("/status"))
|
||||
|
||||
assert "**Model:** `openai/gpt-persisted` (openai-codex)" in result
|
||||
assert "**Context:** 24,000 / 272,000 (9%)" in result
|
||||
assert "**Cumulative API tokens (re-sent each call):** 2,500 (cumulative)" in result
|
||||
assert "**Cumulative API tokens (re-sent each call):** 2,500" in result
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_status_command_includes_cached_agent_model_and_context():
|
||||
session_entry = SessionEntry(
|
||||
session_key=build_session_key(_make_source()),
|
||||
session_id="sess-1",
|
||||
created_at=datetime.now(),
|
||||
updated_at=datetime.now(),
|
||||
platform=Platform.TELEGRAM,
|
||||
chat_type="dm",
|
||||
total_tokens=0,
|
||||
)
|
||||
runner = _make_runner(session_entry)
|
||||
cached_agent = SimpleNamespace(
|
||||
model="anthropic/claude-sonnet-test",
|
||||
provider="openrouter",
|
||||
context_compressor=SimpleNamespace(
|
||||
last_prompt_tokens=10_000,
|
||||
context_length=200_000,
|
||||
),
|
||||
)
|
||||
runner._agent_cache = {session_entry.session_key: (cached_agent, time.time())}
|
||||
|
||||
result = await runner._handle_message(_make_event("/status"))
|
||||
|
||||
assert "**Model:** `anthropic/claude-sonnet-test` (openrouter)" in result
|
||||
assert "**Context:** 10,000 / 200,000 (5%)" in result
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
|
||||
Reference in New Issue
Block a user