MCPcopy
hub / github.com/HKUDS/DeepCode / run

Method run

nanobot/nanobot/agent/loop.py:128–154  ·  view source on GitHub ↗

Run the agent loop, processing messages from the bus.

(self)

Source from the content-addressed store, hash-verified

126 logger.info(f"DeepCode tools registered (API: {deepcode_url})")
127
128 async def run(self) -> None:
129 """Run the agent loop, processing messages from the bus."""
130 self._running = True
131 logger.info("Agent loop started")
132
133 while self._running:
134 try:
135 # Wait for next message
136 msg = await asyncio.wait_for(self.bus.consume_inbound(), timeout=1.0)
137
138 # Process it
139 try:
140 response = await self._process_message(msg)
141 if response:
142 await self.bus.publish_outbound(response)
143 except Exception as e:
144 logger.error(f"Error processing message: {e}")
145 # Send error response
146 await self.bus.publish_outbound(
147 OutboundMessage(
148 channel=msg.channel,
149 chat_id=msg.chat_id,
150 content=f"Sorry, I encountered an error: {str(e)}",
151 )
152 )
153 except asyncio.TimeoutError:
154 continue
155
156 def stop(self) -> None:
157 """Stop the agent loop."""

Callers 15

check_dependenciesFunction · 0.80
kill_process_on_portFunction · 0.80
install_backend_depsFunction · 0.80
install_frontend_depsFunction · 0.80
cleanup_processesFunction · 0.80
launch_classic_uiFunction · 0.80
launch_dockerFunction · 0.80
launch_docker_cliFunction · 0.80
launch_paper_testFunction · 0.80
mainFunction · 0.80
convert_office_to_pdfMethod · 0.80

Calls 4

_process_messageMethod · 0.95
OutboundMessageClass · 0.90
consume_inboundMethod · 0.80
publish_outboundMethod · 0.80

Tested by

no test coverage detected