What happened?
Running agents-cli run on Windows fails during both startup and shutdown phases due to platform-specific subprocess creation and OS-level API incompatibilities.
Visual Reference attached:
Steps to Reproduce
- Create and install a standard agent project on Windows.
- Run
agents-cli run "any query" from the terminal.
- Observe the OS-level
uv.exe application crash (0xc0000142) dialog on startup.
- If bypassed, observe the AttributeError: module 'os' has no attribute 'WNOHANG' traceback on exit.
What did you expect to happen?
The CLI runs the query, executes the agent, streams the output, and terminates the background server cleanly without any popups or traceback crashes.
Client information
CLI version: 0.5.0
CLI install path: C:\Users\abdul\AppData\Roaming\uv\tools\google-agents-cli\Lib\site-packages\google\agents\cli
OS info: Windows-11-10.0.26200-SP0
Installed skills: none
Project root: C:\Users\abdul\OneDrive\Desktop\Comp Lang NEW\Antigravity - agy-cli-projects\weather-assistant
Project name: weather-assistant
Deployment target: none
Agent directory: app
Region: us-east1
Command Output / Logs
AttributeError: module 'os' has no attribute 'WNOHANG'
Traceback (most recent call last):
File "...\google\agents\cli\main.py", line 58, in invoke
super().invoke(ctx)
...
File "...\google\agents\cli\run_local_server.py", line 340, in _cleanup
os.waitpid(pid, os.WNOHANG)
AttributeError: module 'os' has no attribute 'WNOHANG'
Anything else we need to know?
Visual Evidence:
Cause:
- Startup Crash (
0xc0000142): Spawning the background server with start_new_session=True without redirecting stdin results in invalid console handle inheritance on Windows. This causes uv.exe to fail to initialize.
- Shutdown Crash (
AttributeError): The os.WNOHANG constant is not defined or supported on the Windows platform.
Proposed Combined Fix in google/agents/cli/run/_local_server.py:
@@ -195,14 +195,24 @@
log_file = open(log_path, "a", encoding="utf-8")
try:
+ import subprocess as sp
+ import sys
+
+ popen_kwargs = {
+ "cwd": str(project_root),
+ "stdout": log_file,
+ "stderr": log_file,
+ "env": env,
+ }
+ if sys.platform == "win32":
+ popen_kwargs["creationflags"] = sp.CREATE_NO_WINDOW | sp.CREATE_NEW_PROCESS_GROUP
+ popen_kwargs["stdin"] = sp.DEVNULL
+ else:
+ popen_kwargs["start_new_session"] = True
+
proc = popen_resolved(
cmd,
- cwd=str(project_root),
- stdout=log_file,
- stderr=log_file,
- env=env,
- # Detach from the CLI process so the server survives after exit.
- start_new_session=True,
+ **popen_kwargs
)
finally:
# Close the parent's copy of the fd — the child inherits its own.
@@ -336,11 +336,15 @@
pass
else:
# Wait briefly for the process to release its port.
- try:
- os.waitpid(pid, os.WNOHANG)
- except ChildProcessError:
- # Not a direct child — fall back to a short sleep so the
- # port is freed before we attempt to bind a new one.
+ import sys
+ if sys.platform != "win32":
+ try:
+ os.waitpid(pid, os.WNOHANG)
+ except ChildProcessError:
+ # Not a direct child — fall back to a short sleep so the
+ # port is freed before we attempt to bind a new one.
+ time.sleep(0.3)
+ else:
time.sleep(0.3)
path = _pid_file_path(project_root)
try:
---
### Contribution & Recognition
* CLA Status: I have signed the Google Individual CLA (under the name Abdullah).
* Credit: Since this fix resolves multiple blockers for Windows users, I would appreciate being credited for this contribution when these fixes are applied.
* Peer Bonus: Once merged, I would love to be nominated for the Google Open Source Peer Bonus program.
What happened?
Running
agents-cli runon Windows fails during both startup and shutdown phases due to platform-specific subprocess creation and OS-level API incompatibilities.Visual Reference attached:
Steps to Reproduce
agents-cli run "any query"from the terminal.uv.exeapplication crash (0xc0000142) dialog on startup.What did you expect to happen?
The CLI runs the query, executes the agent, streams the output, and terminates the background server cleanly without any popups or traceback crashes.
Client information
CLI version: 0.5.0
CLI install path: C:\Users\abdul\AppData\Roaming\uv\tools\google-agents-cli\Lib\site-packages\google\agents\cli
OS info: Windows-11-10.0.26200-SP0
Installed skills: none
Project root: C:\Users\abdul\OneDrive\Desktop\Comp Lang NEW\Antigravity - agy-cli-projects\weather-assistant
Project name: weather-assistant
Deployment target: none
Agent directory: app
Region: us-east1
Command Output / Logs
AttributeError: module 'os' has no attribute 'WNOHANG'
Traceback (most recent call last):
File "...\google\agents\cli\main.py", line 58, in invoke
super().invoke(ctx)
...
File "...\google\agents\cli\run_local_server.py", line 340, in _cleanup
os.waitpid(pid, os.WNOHANG)
AttributeError: module 'os' has no attribute 'WNOHANG'
Anything else we need to know?
Visual Evidence:
Cause:
0xc0000142): Spawning the background server withstart_new_session=Truewithout redirectingstdinresults in invalid console handle inheritance on Windows. This causesuv.exeto fail to initialize.AttributeError): Theos.WNOHANGconstant is not defined or supported on the Windows platform.Proposed Combined Fix in
google/agents/cli/run/_local_server.py: