Repository navigation
fix(logging): keep stdout clean and respect the configured log level - #9
Merged
Jeomon merged 2 commits intoOct 27, 2026
Merged
Conversation
The focus, structure and property event handlers printed their exceptions straight to stdout. stdout is the transport for newline delimited JSON-RPC, so a callback that raised while windows-use was embedded in an MCP server injected a bare sentence into the middle of the protocol stream and killed the connection. Log through the module logger instead, and add a regression test asserting that the handlers never write to stdout.
agent/service.py configures the "windows_use" logger at INFO, but agent/desktop/service.py set its own child logger to DEBUG, which overrode that. Every step therefore dumped the full window list - name, status, bounding box and handle for each window - to the console. Drop the explicit setLevel so the module inherits the package level. Set "windows_use" to DEBUG to get the verbose output back.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Two logging problems that bite anyone embedding windows-use in a stdout based protocol server (MCP servers, JSON-RPC agent harnesses,
| jqpipelines).1. The UIA watchdog printed to stdout
windows_use/agent/watchdog/event_handlers.pyprinted callback exceptions straight to stdout:Those handlers fire on every focus change, so a callback that raised injected a bare sentence into the middle of the protocol stream and the client disconnected.
They now log through the module logger, which the package already routes to stderr.
tests/test_watchdog_stdout_safety.pyasserts that none of the three handlers write to stdout; it fails on the current code and passes with this change.2. The desktop service forced DEBUG
agent/service.pyconfigures thewindows_uselogger at INFO, butagent/desktop/service.pyset its child logger to DEBUG, overriding it. Every step dumped the whole window list - name, status, bounding box and handle per window - to the console.Removing the explicit
setLevellets the module inherit the package level.logging.getLogger("windows_use").setLevel(logging.DEBUG)brings the verbose output back for anyone who wants it.Testing
pytest tests/- 124 passed, 5 skipped (4 of the passed are the new ones)ruff checkandruff format --checkare clean on the changed files