The CapabilityWorker is the primary SDK interface for building OpenHome Abilities. It provides all I/O operations including text-to-speech, user input, LLM calls, audio playback, file storage, and flow control.
Access CapabilityWorker via self.capability_worker after initializing it in your Ability’s call() method.
import jsonfrom src.agent.capability import MatchingCapabilityfrom src.main import AgentWorkerfrom src.agent.capability_worker import CapabilityWorkerclass WeatherAbility(MatchingCapability): worker: AgentWorker = None capability_worker: CapabilityWorker = None def call(self, worker: AgentWorker): self.worker = worker self.capability_worker = CapabilityWorker(self) self.worker.session_tasks.create(self.run()) async def run(self): try: # Ask for location location = await self.capability_worker.run_io_loop( "What city would you like weather for?" ) # Log the request self.worker.editor_logging_handler.info(f"Weather requested for: {location}") # Get weather (using LLM for demo - use real API in production) prompt = f"What's the weather like in {location}? Respond in one sentence." response = self.capability_worker.text_to_text_response(prompt) # Speak the result await self.capability_worker.speak(response) except Exception as e: self.worker.editor_logging_handler.error(f"Error: {e}") await self.capability_worker.speak("Sorry, something went wrong.") # ALWAYS resume normal flow self.capability_worker.resume_normal_flow()