()
| 136 | |
| 137 | |
| 138 | def test_agent_chat_document_link(): |
| 139 | agent = ChatAgent( |
| 140 | ChatAgentConfig(llm=MockLMConfig(default_response="7")) |
| 141 | ) # auto-registered |
| 142 | agent.message_history = [ |
| 143 | LLMMessage(role="system", content="You are helpful"), |
| 144 | LLMMessage(role="user", content="hello"), |
| 145 | LLMMessage(role="assistant", content="hi there"), |
| 146 | ] |
| 147 | response_doc = agent.llm_response("3+4?") |
| 148 | assert response_doc is not None |
| 149 | assert isinstance(response_doc, ChatDocument) |
| 150 | assert response_doc.metadata.agent_id == agent.id |
| 151 | assert response_doc.metadata.msg_idx == 4 |
| 152 | assert ObjectRegistry.get(response_doc.id()) is response_doc |
| 153 | assert ObjectRegistry.get(agent.id) is agent |
| 154 | last_msg = agent.message_history[-1] |
| 155 | assert ( |
| 156 | last_msg.chat_document_id == response_doc.id() |
| 157 | ), "Last message (LLM response) should be linked to the response chat document" |
| 158 | |
| 159 | assert ( |
| 160 | ObjectRegistry.get(last_msg.chat_document_id) is response_doc |
| 161 | ), "Lookup from last message should return the response chat document" |
nothing calls this directly
no test coverage detected
searching dependent graphs…