MCPcopy Create free account
hub / github.com/anthropics/anthropic-sdk-python / assert_sends_conversation

Function assert_sends_conversation

tests/lib/threads/helpers.py:652–666  ·  view source on GitHub ↗

Assert that `request`, which follows the `toolu_a` reply `msg_a` to the weather question, shows the model `conversation`. With default settings it leaves out the question and the reply when `conversation` starts with them, and sends all of any other.

(
    request: dict[str, Any], mode: dict[str, Any], conversation: list[BetaMessageParam]
)

Source from the content-addressed store, hash-verified

650
651
652def assert_sends_conversation(
653 request: dict[str, Any], mode: dict[str, Any], conversation: list[BetaMessageParam]
654) -> None:
655 """Assert that `request`, which follows the `toolu_a` reply `msg_a` to the weather question, shows the model
656 `conversation`. With default settings it leaves out the question and the reply when `conversation` starts with
657 them, and sends all of any other."""
658 if mode:
659 assert "thread" not in request
660 assert request["messages"] == conversation
661 elif conversation[:2] == [WEATHER_QUESTION, tool_use("toolu_a")]:
662 assert request["thread"] == continue_from("msg_a")
663 assert request["messages"] == conversation[2:]
664 else:
665 assert request["thread"] == CREATE
666 assert request["messages"] == conversation
667
668
669def two_tool_uses_response(id: str) -> httpx2.Response:

Calls 2

tool_useFunction · 0.85
continue_fromFunction · 0.85