Co-authored-by: Albert Jiang <aj@mistral.ai>
Co-authored-by: Clément Drouin <clement.drouin@mistral.ai>
Co-authored-by: Laure Hugo <201583486+laure0303@users.noreply.github.com>
Co-authored-by: Mathias Gesbert <mathias.gesbert@mistral.ai>
Co-authored-by: Mert Unsal <mert.unsal@mistral.ai>
Co-authored-by: Michel Thomazo <51709227+michelTho@users.noreply.github.com>
Co-authored-by: Paul VEZIA <166131032+le-codeur-rapide@users.noreply.github.com>
Co-authored-by: Pierre Rossinès <pierre.rossines@mistral.ai>
Co-authored-by: Quentin <quentin.torroba@mistral.ai>
Co-authored-by: Mistral Vibe <vibe@mistral.ai>
This commit is contained in:
maiengineering 2026-07-01 19:03:09 +02:00 committed by GitHub
parent 4e495f658d
commit ac8f1a09fd
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
83 changed files with 1979 additions and 572 deletions

View file

@ -40,6 +40,18 @@ def _get_auto_compact_properties(
return cast(dict[str, object], auto_compact[0]["properties"])
def _get_compaction_failed_properties(
telemetry_events: list[dict[str, object]],
) -> dict[str, object]:
failed = [
event
for event in telemetry_events
if event.get("event_name") == "vibe.compaction_failed"
]
assert len(failed) == 1
return cast(dict[str, object], failed[0]["properties"])
@pytest.mark.asyncio
async def test_auto_compact_emits_correct_events(telemetry_events: list[dict]) -> None:
backend = FakeBackend([
@ -306,7 +318,9 @@ async def test_compact_without_extra_instructions_has_no_additional_section() ->
@pytest.mark.asyncio
async def test_compact_raises_on_tool_call_when_flag_enabled() -> None:
async def test_compact_raises_on_tool_call_when_flag_enabled(
telemetry_events: list[dict],
) -> None:
"""With the flag on, a compaction that returns a tool call raises."""
backend = FakeBackend([
[
@ -333,10 +347,13 @@ async def test_compact_raises_on_tool_call_when_flag_enabled() -> None:
with pytest.raises(CompactionFailedError) as exc_info:
await agent.compact()
assert exc_info.value.reason == "tool_call"
assert _get_compaction_failed_properties(telemetry_events)["reason"] == "tool_call"
@pytest.mark.asyncio
async def test_compact_raises_on_empty_summary_when_flag_enabled() -> None:
async def test_compact_raises_on_empty_summary_when_flag_enabled(
telemetry_events: list[dict],
) -> None:
"""With the flag on, a compaction with empty content raises."""
backend = FakeBackend([[mock_llm_chunk(content=" ")]])
cfg = build_test_vibe_config(
@ -350,11 +367,20 @@ async def test_compact_raises_on_empty_summary_when_flag_enabled() -> None:
with pytest.raises(CompactionFailedError) as exc_info:
await agent.compact()
assert exc_info.value.reason == "empty_summary"
assert (
_get_compaction_failed_properties(telemetry_events)["reason"] == "empty_summary"
)
@pytest.mark.asyncio
async def test_compact_falls_back_when_flag_disabled() -> None:
"""With the flag off (default), empty content uses the legacy fallback."""
async def test_compact_falls_back_when_flag_disabled(
telemetry_events: list[dict],
) -> None:
"""With the flag off (default), empty content uses the legacy fallback.
The compaction failure telemetry event must still be sent even though the
flag is off and compact() returns normally.
"""
backend = FakeBackend([[mock_llm_chunk(content="")]])
cfg = build_test_vibe_config(models=make_test_models(auto_compact_threshold=999))
agent = build_test_agent_loop(config=cfg, backend=backend)
@ -363,6 +389,9 @@ async def test_compact_falls_back_when_flag_disabled() -> None:
summary = await agent.compact()
assert summary == "(no summary available)"
assert (
_get_compaction_failed_properties(telemetry_events)["reason"] == "empty_summary"
)
@pytest.mark.asyncio