agent: look at current info, its aUEC, feat: pull up notifcations.

This commit is contained in:
2026-05-05 20:05:33 -04:00
parent f7ac45ddd8
commit 761eda6155
11 changed files with 198 additions and 8 deletions
+14 -1
View File
@@ -1,6 +1,6 @@
import pytest
from traderai.agent import OllamaAgent
from traderai.agent import OllamaAgent, SYSTEM_PROMPT
from traderai.memory import MemoryStore
@@ -77,3 +77,16 @@ def test_stream_metrics_include_reading_and_writing_rates():
assert metrics["reading_tokens_per_second"] == 10
assert metrics["writing_tokens"] == 30
assert metrics["writing_tokens_per_second"] == 10
def test_system_prompt_prefers_current_marketplace_data():
assert "open/current" in SYSTEM_PROMPT
assert "Do not use historical sale data" in SYSTEM_PROMPT
assert "aUEC/UEC credits" in SYSTEM_PROMPT
assert "never real-world dollars" in SYSTEM_PROMPT
def test_ollama_options_include_num_ctx():
agent = OllamaAgent("http://127.0.0.1:1", "missing-model", EmptyTools(), num_ctx=64000)
assert agent._ollama_options() == {"num_ctx": 64000}
+47
View File
@@ -0,0 +1,47 @@
import pytest
from traderai.memory import MemoryStore
from traderai.scheduler import WakeScheduler
class FakeUEXNotifications:
def __init__(self):
self.calls = 0
async def get_user_notifications(self):
self.calls += 1
return {
"status": "ok",
"notifications": [
{
"id": 10,
"message": "A buyer replied to your listing.",
"redir": "/marketplace/negotiations/abc",
"code": "negotiation_reply",
"date_added": 123,
"date_read": 0,
},
{
"id": 11,
"message": "Already read.",
"date_added": 122,
"date_read": 123,
},
],
}
@pytest.mark.asyncio
async def test_poll_uex_notifications_adds_unread_once(tmp_path):
memory = MemoryStore(str(tmp_path / "memory.sqlite3"))
scheduler = WakeScheduler(memory)
scheduler.bind_uex_notifications(FakeUEXNotifications())
first = await scheduler.poll_uex_notifications()
second = await scheduler.poll_uex_notifications()
outbox = memory.inspect()["outbox"]
assert len(first) == 1
assert second == []
assert len(outbox) == 1
assert "A buyer replied to your listing." in outbox[0]["content"]
+13
View File
@@ -81,3 +81,16 @@ async def test_uex_client_get_user_normalizes_user_payload():
result = await client.get_user(authenticated=True)
assert result == {"status": "ok", "user": {"username": "pilot_hudson"}}
@pytest.mark.asyncio
@respx.mock
async def test_uex_client_get_user_notifications_normalizes_payload():
respx.get("https://api.uexcorp.space/2.0/user_notifications/").mock(
return_value=Response(200, json={"status": "ok", "data": {"id": 7, "message": "Reply waiting", "date_read": 0}})
)
client = UEXClient("https://api.uexcorp.space/2.0", bearer_token="bearer")
result = await client.get_user_notifications()
assert result == {"status": "ok", "notifications": [{"id": 7, "message": "Reply waiting", "date_read": 0}]}