fix(gateway): restrict ppid==1 systemd detection to Linux only - #25525
fix(gateway): restrict ppid==1 systemd detection to Linux only#25525zccyman wants to merge 1 commit into
Conversation
|
I just closed my own salvage of #25511 (#25687) in favor of this one. While reviewing the same area I rewrote the tests to use |
|
Thanks @wesleysimplicio for closing #25687 in favor of this one — that's a strong endorsement, much appreciated. Your test rewrite suggestion is spot-on — |
|
@wesleysimplicio Good news — the current patch already includes three
Exactly the pattern you described. Let me know if you see anything else. |
0e929da to
a04e6b7
Compare
When the advisor tool is removed from the tools array (e.g. disabled for cost control on follow-up turns), Anthropic rejects requests whose history contains residual server_tool_use(name=advisor) or advisor_tool_result blocks. Added _strip_advisor_blocks() which replaces these blocks with <advisor_feedback> text blocks so the executor retains the semantic context of past advice. Called in build_anthropic_kwargs() when advisor is not active. Inspired by LiteLLM's strip_advisor_blocks_from_messages() (PR NousResearch#25525).
|
Thanks for the focused platform correction. Current main still has the unguarded PPID-1 heuristic at Automated hermes-sweeper review. |
Summary
Fixes #25508
When
shutdown_forensics.pydetectsppid == 1, it assumes the process runs undersystemd. On macOS, PID 1 is launchd (Apple's service manager), not systemd. This causes the gateway to incorrectly use systemd-specific shutdown logic on macOS.Root Cause
In
gateway/shutdown_forensics.pyline 143:The
ppid == 1check is platform-agnostic, but PID 1 only implies systemd on Linux.Fix
Restrict the
ppid == 1heuristic to Linux only:The
INVOCATION_IDenvironment variable check remains platform-independent (it's only set by systemd on Linux, so no false positive on macOS).Test Plan
tests/gateway/test_shutdown_forensics.py:test_under_systemd_false_on_macos_when_ppid_is_one— macOS + ppid==1 →under_systemd=Falsetest_under_systemd_true_on_linux_when_ppid_is_one— Linux + ppid==1 →under_systemd=Truetest_under_systemd_invocation_id_overrides_platform—INVOCATION_IDalways winstest_shutdown_forensics.pypass (30 existing + 3 new)