Home / Function/ test_cannot_set_both_system_prompt_and_system_message() — langchain Function Reference

test_cannot_set_both_system_prompt_and_system_message() — langchain Function Reference

Architecture documentation for the test_cannot_set_both_system_prompt_and_system_message() function in test_system_message.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  6603af87_954d_6b41_fc20_1a650f2d3dc0["test_cannot_set_both_system_prompt_and_system_message()"]
  fdcac224_4658_3042_d41f_938e751993a3["TestModelRequestSystemMessage"]
  6603af87_954d_6b41_fc20_1a650f2d3dc0 -->|defined in| fdcac224_4658_3042_d41f_938e751993a3
  style 6603af87_954d_6b41_fc20_1a650f2d3dc0 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/langchain_v1/tests/unit_tests/agents/test_system_message.py lines 180–215

    def test_cannot_set_both_system_prompt_and_system_message(
        self, *, use_constructor: bool
    ) -> None:
        """Test that setting both system_prompt and system_message raises error."""
        model = GenericFakeChatModel(messages=iter([AIMessage(content="Hello")]))

        if use_constructor:
            with pytest.raises(ValueError, match="Cannot specify both"):
                ModelRequest(
                    model=model,
                    system_prompt="String prompt",
                    system_message=SystemMessage(content="Message prompt"),
                    messages=[],
                    tool_choice=None,
                    tools=[],
                    response_format=None,
                    state=AgentState(messages=[]),
                    runtime=None,
                )
        else:
            request = ModelRequest(
                model=model,
                system_message=None,
                messages=[],
                tool_choice=None,
                tools=[],
                response_format=None,
                state=AgentState(messages=[]),
                runtime=None,
            )
            with pytest.raises(ValueError, match="Cannot specify both"):
                # system_prompt is deprecated but supported at runtime for backward compatibility
                request.override(  # type: ignore[call-arg]
                    system_prompt="String prompt",
                    system_message=SystemMessage(content="Message prompt"),
                )

Domain

Subdomains

Frequently Asked Questions

What does test_cannot_set_both_system_prompt_and_system_message() do?
test_cannot_set_both_system_prompt_and_system_message() is a function in the langchain codebase, defined in libs/langchain_v1/tests/unit_tests/agents/test_system_message.py.
Where is test_cannot_set_both_system_prompt_and_system_message() defined?
test_cannot_set_both_system_prompt_and_system_message() is defined in libs/langchain_v1/tests/unit_tests/agents/test_system_message.py at line 180.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free