AutoGPT is the vision of accessible AI for everyone, to use and to build on. Our mission is to provide the tools, so that you can focus on what matters.
feat(backend/copilot): tell Otto and the experts that formulas render (#14807)
Reinier van der Leer7b421d698452
diff --git a/autogpt_platform/backend/backend/copilot/baseline/system_prompt_test.py b/autogpt_platform/backend/backend/copilot/baseline/system_prompt_test.pynew file mode 100644index 0000000000..75c1ba54d0--- /dev/null+++ b/autogpt_platform/backend/backend/copilot/baseline/system_prompt_test.py@@ -0,0 +1,38 @@+"""The system message the baseline engine sends carries the shared workflow notes."""++import asyncio+from unittest.mock import AsyncMock, MagicMock++import pytest++from backend.copilot.baseline import service+from backend.copilot.baseline.service_cancellation_test import baseline_io+from backend.copilot.model import ChatMessage, ChatSession++__all__ = ["baseline_io"]+++async def test_system_message_tells_the_model_formulas_render(+ monkeypatch: pytest.MonkeyPatch, baseline_io: list[ChatSession]+) -> None:+ session = ChatSession.new("user-1", dry_run=False)+ session.title = "Math"+ session.messages.append(ChatMessage(role="user", content="Derive it"))+ stream = MagicMock()+ stream.__aiter__.return_value = []+ stream.close = AsyncMock()+ provider = AsyncMock(return_value=stream)+ monkeypatch.setattr(service, "call_provider_stream", provider)++ async with asyncio.timeout(5):+ async for _ in service.stream_chat_completion_baseline(+ session.session_id, user_id="user-1", session=session, is_user_message=False+ ):+ pass++ assert provider.await_args is not None+ [system] = [+ m for m in provider.await_args.kwargs["messages"] if m["role"] == "system"+ ]+ assert "`$…$` inline, `$$…$$` for display" in str(system["content"])diff --git a/autogpt_platform/backend/backend/copilot/prompting.py b/autogpt_platform/backend/backend/copilot/prompting.pyindex 7baf594a13..f58d3b7f6f 100644--- a/autogpt_platform/backend/backend/copilot/prompting.py+++ b/autogpt_platform/backend/backend/copilot/prompting.py@@ -15,6 +15,9 @@ from functools import cache# individual tool schema.SHARED_TOOL_NOTES = """\+### Math+Formulas render as LaTeX in replies and `.md` files: `$…$` inline, `$$…$$` for display; a plain price like `$5` stays text.+### Sharing filesAfter `write_workspace_file`, embed the `download_url` in Markdown:- File: `[report.csv](workspace://file_id#text/csv)`diff --git a/autogpt_platform/backend/backend/copilot/prompting_test.py b/autogpt_platform/backend/backend/copilot/prompting_test.pyindex 2c043f77d1..d8a9cf8cda 100644--- a/autogpt_platform/backend/backend/copilot/prompting_test.py+++ b/autogpt_platform/backend/backend/copilot/prompting_test.py@@ -2,6 +2,8 @@import importlib+import pytest+from backend.copilot import prompting@@ -246,3 +248,10 @@ class TestSchedulingGuidance:# SHARED_TOOL_NOTES feeds both the SDK supplement and baseline's# system prompt; the rule is useless if it only reaches one mode.assert "### Scheduling future work" in prompting.SHARED_TOOL_NOTES+++class TestMathGuidance:+ @pytest.mark.parametrize("use_e2b", [False, True])+ def test_sdk_supplement_tells_the_model_formulas_render(self, use_e2b):+ result = prompting.get_sdk_supplement(use_e2b=use_e2b)+ assert "`$…$` inline, `$$…$$` for display" in result