MCPcopy
hub / github.com/langroid/langroid / test_agent_chat_document_link

Function test_agent_chat_document_link

tests/main/test_object_registry.py:138–161  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

136
137
138def 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"

Callers

nothing calls this directly

Calls 7

llm_responseMethod · 0.95
ChatAgentClass · 0.90
ChatAgentConfigClass · 0.90
MockLMConfigClass · 0.90
LLMMessageClass · 0.90
getMethod · 0.80
idMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…