Conversation
1e217a5 to
11801ac
Compare
teknium1
left a comment
There was a problem hiding this comment.
Thanks for re-scoping the prior Z.AI concurrency work to profile-safe config.yaml; that matches the direction recorded on #55037. The premise is still present on current main: agent/conversation_loop.py:1351-1362 sends direct calls without a Z.AI gate, while agent/moa_loop.py:407-428 fans references out concurrently.
Problems
agent/agent_init.py:895passes the new interrupt callback only for initial construction.agent/agent_runtime_helpers.py:1915-1934reconstructsMoAClientduringswitch_model()withoutinterrupt_check. After switching to an MoA preset, a saturated zero-timeout Z.AI gate cannot observeagent._interrupt_requested, contrary to the PR's interruptible-wait contract.
Suggested changes
- Pass the same callback in
agent_runtime_helpers.py:1934, and add a switch-to-MoA regression test that verifies a queued Z.AI slot wait interrupts.
Automated hermes-sweeper review.
11801ac to
98f01c8
Compare
|
Addressed in
Validation completed:
The branch is rebased on current |
fb1c144 to
8bf1fd5
Compare
|
Final follow-up is complete in The branch was rebased through current upstream movement and the PR description now matches the actual diff. Final evidence includes 37 focused tests on the final head, a 942-test related audit, 52 directly affected Z.AI/MoA/portal-context tests after the later MoA upstream change, Ruff, Python compilation, Windows-footgun and whitespace checks, a 200-thread peak-cap stress test, and a privacy scan. |
Add a process-local semaphore for resolved Z.AI calls across the direct agent and MoA references and aggregators. Streaming calls retain their slot for the iterator lifetime, and interactive waits remain interruptible. Read max_concurrent and acquire_timeout_seconds from providers.zai in the active profile config. Zero disables the gate; saturation waits or raises locally and never bypasses the cap. No user-facing environment controls are added. Cover direct runtime wiring, MoA fan-out and streaming, profile-scoped config-set behavior, timeouts, interrupts, and strict concurrency bounds. Detection is host-first: a resolvable base-URL host is authoritative and the provider name is consulted only when no host parses, so a zai/glm provider whose GLM_BASE_URL is overridden to a local or third-party endpoint is not throttled while real Z.AI destinations stay gated. The URL grammar covers protocol-relative (//host), schemeless URLs whose path or query embeds '://', and opaque 'https:host' forms; the name fallback strips whitespace. Regression tests cover the override, fallback, protocol-relative, and hostile-URL cases, and the provider guide documents host-first detection and that auxiliary side-model calls are not gated.
4fc46a3 to
81c74b3
Compare
What does this PR do?
Adds one strict process-local concurrency gate for Z.AI requests made by the direct agent path and Mixture-of-Agents reference/aggregator calls.
The gate is profile-configurable, interruptible while queued, and held for the full lifetime of streaming calls. It prevents Z.AI fan-out from bypassing the configured cap or leaking another caller's semaphore permit.
Type of change
Changes Made
agent/zai_concurrency.py, backed by a process-wide bounded semaphore.providers.zai:max_concurrentdefaults to2;0disables the gate.acquire_timeout_secondsdefaults to0, meaning wait until a slot or interruption.scheme:hostURL forms all resolving to their real host.How to Test
Focused coverage:
Static and cross-platform checks:
Verification Results
Three independent verification methods passed, with the final branch head at
81c74b3af:The review-specific regression holds the sole Z.AI permit, switches a live agent to MoA, confirms the new client queues without calling the provider, flips
_interrupt_requested, receivesInterruptedError, and proves the foreign permit was not released.Scope and Limitations
config.yamlwhen the module is loaded.zai/glmprovider pointed at a local or third-party endpoint viaGLM_BASE_URLis not throttled. The provider name is used only when no host can be parsed.auxiliary-configured tasks) are not routed through it, so a Z.AI-backed auxiliary configuration can add in-flight requests beyondmax_concurrent.Checklist