diff --git a/tests/test_agent.py b/tests/test_agent.py index 271e627..1ed0ebd 100644 --- a/tests/test_agent.py +++ b/tests/test_agent.py @@ -1,13 +1,14 @@ -from agt.agent import Agent, Tool, echo_tool +from agt.agent import Agent, FakeLLMClient, Tool, echo_tool -def test_agent_returns_default_message() -> None: - agent = Agent() +def test_agent_returns_fake_llm_message() -> None: + agent = Agent(llm=FakeLLMClient()) agent.register_tool(Tool("echo", "Echo input text", echo_tool)) result = agent.run("hello") - assert "教学用 Agent 骨架" in result + assert "[fake-llm]" in result + assert "hello" in result assert agent.messages[0].role == "user" assert agent.messages[-1].role == "assistant" @@ -21,3 +22,13 @@ def test_load_skills_finds_skill_md(tmp_path) -> None: skills = agent.load_skills(tmp_path / "skills") assert skills == ["writing"] + + +def test_fake_llm_streams_multiple_chunks() -> None: + llm = FakeLLMClient() + from agt.agent import Message + + chunks = list(llm.stream_text([Message(role="user", content="x")])) + + assert len(chunks) >= 2 + assert "".join(chunks).startswith("[fake-llm]")