Commit Graph
16 Commits
Author SHA1 Message Date
can1357 00fedcf6ac feat(ai): extended codex and stream timeout defaults to 300 seconds
- Increased codex websocket first event timeout default to 300 seconds.
- Increased default stream idle and first event timeout thresholds to 300 seconds.
- Updated stream timeout test expectations to match new 300s global default.
2026-07-30 05:33:06 +02:00
roboomp 946b7d9bd2 fix(ai): preserved disabled first-event sentinel
- Kept zero timeout resolutions distinct from missing first-event policy so the iterator does not fall back to the idle watchdog.
- Added deterministic coverage for an SSE response that opens before local prompt prefill emits its first event.
2026-07-24 15:33:27 +00:00
roboomp a421ea8acd fix(ai): disabled local first-event watchdogs
- Added a per-model first-event watchdog policy and disabled it for local OpenAI-compatible backends while retaining inter-event stall detection.
- Applied the policy to Responses and chat-completions transports with regression coverage for resolver and runtime precedence.

Fixes #6524
2026-07-24 15:19:14 +00:00
can1357 d8d9613a6d test(ai): verified cleanup of first-item watchdog timer
- Implement `drainMicrotasksUntil` helper to manage async race conditions during tests.
- Add fake timer validation to ensure the first-item watchdog is cleared when the upstream source rejects.
- Restore real timers in `afterEach` to prevent test contamination.
2026-06-26 11:43:38 +02:00
can1357 cbecab2be2 fix(ai): prevented OpenAI streams from hanging after terminal completion
- Added a terminal-aware async iterator that enforces a post-completion grace window, then ends iteration and optionally aborts the request.
- Wrapped OpenAI completions streaming with terminal detection of finish-reason and usage payloads so iteration stops once a response is logically complete.
- Stopped OpenAI Responses stream consumption at terminal response events instead of waiting for connection close timeouts.
2026-06-11 16:08:52 +02:00
can1357 9d457f73d9 test: migrated test imports to package subpath exports
- Replaced relative `../src` imports with `@oh-my-pi/pi-ai` and `@oh-my-pi/pi-agent-core` subpaths.
2026-06-08 19:03:55 +02:00
can1357 421ff27eb6 fix(ai): scoped Anthropic fallback state and fixed iterator early-close cleanup
- Scoped Anthropic provider session state by base URL and model so strict-tools/fast-mode fallback state no longer leaks across unrelated endpoints or models, and fast-mode re-arming clears all matching scoped entries.
- Dropped stale strict fallback error messages after successful retries and only enabled adaptive thinking display for models that advertise support, avoiding unsupported-model 400 errors.
- Updated idle stream iteration to close the upstream iterator on non-continuing exits (including consumer early break) and added coverage for upstream closure behavior.
2026-06-08 14:44:13 +02:00
roboomp 062ba5e836 fix(ai): kept openai first-event env honored with per-call idle
Always route OpenAI-family providers through getOpenAIStreamFirstEventTimeoutMs so PI_OPENAI_STREAM_FIRST_EVENT_TIMEOUT_MS wins even when callers pass per-call streamIdleTimeoutMs. The OpenAI helper now floors the first-event budget at the caller-resolved idle (which already encompasses per-call streamIdleTimeoutMs or PI_OPENAI_STREAM_IDLE_TIMEOUT_MS upstream), and explicit env disables ("0") on either knob continue to drop the watchdog.

Fixes #1603
2026-05-31 19:02:53 +00:00
roboomp 239bb9858d fix(ai): honored openai idle timeout for first events
OpenAI-compatible local servers can spend longer than the generic first-event budget processing large prompts before they emit response headers or SSE frames. The OpenAI-specific idle timeout now also acts as the OpenAI-family first-event floor unless an explicit OpenAI first-event timeout is configured.

Added regression coverage for OpenAI Responses request setup so a lower generic first-event watchdog no longer undercuts PI_OPENAI_STREAM_IDLE_TIMEOUT_MS.

Fixes #1603
2026-05-31 18:53:58 +00:00
roboomp 8b19a9c292 fix(ai): widened glm coding-plan stream watchdog
Raised the default OpenAI-compatible stream idle floor for slow GLM-5.x coding-plan endpoints and taught the OpenAI timeout helper to honor provider fallbacks.

Added regression coverage for OpenAI timeout fallback precedence and GLM coding-plan fallback selection.

Fixes #1494
2026-05-29 05:54:22 +00:00
can1357 796c437dc1 feat: overhauled stream timeout and eval session management
- Replaced external watchdog timers with per-request SDK timeouts for first-event budget across OpenAI, Anthropic, and Azure providers.
- Keyed Python shared kernels by (sessionId, cwd) to prevent cross-directory state bleed.
- Deduplicated concurrent cold-start session acquisition for JS and Python executors.
- Moved `isOpenAIResponsesProgressEvent` to shared module and scoped display output routing per run for interleaved async cells.
2026-05-26 16:49:11 +02:00
can1357 5d7a452f11 test(coding-agent/eval): updated eval tests to inject runtime hooks explicitly
- Refactored console-table tests to build explicit RuntimeHooks and pass them to JsRuntime.run.
- Refactored image coercion tests to pass explicit RuntimeHooks into JsRuntime.displayValue instead of constructor hooks.
2026-05-26 15:28:10 +02:00
can1357 207b846046 test(ai/stream-timeouts): added tests for stream timeout behavior and watchdog cleanup
- Added comprehensive test coverage for stream timeout behavior including first-event timeouts, idle timeouts, and watchdog cleanup.
- Added tests for streamSimple per-call timeout options forwarding to OpenAI-family providers.
- Added tests verifying that no-progress status events do not reset first-progress deadline.
- Added tests confirming external watchdog timers are cleared when iteration exits before progress.
2026-05-26 15:27:06 +02:00
can1357 b0258e575a feat(ai): added prompt cache key and per-provider stream watchdog with idle timeout filtering
- Restored per-provider stream watchdog with idle and first-event timeout support, progress-event filtering, and per-provider timeout overrides via `getStreamIdleTimeoutMs()` and `getStreamFirstEventTimeoutMs()`.
- Fixed silent multi-hour hangs on Codex WebSocket and z.ai/GLM-via-OpenRouter subagent runs by filtering keepalive frames from idle watchdog resets.
- Added `isOpenAICompletionsProgressChunk` export and progress-event filtering to multiple providers (Anthropic, OpenAI Responses/Completions, Azure OpenAI, Codex) to prevent keepalive frames from resetting idle timeouts.
- Un-deprecated `StreamOptions.streamIdleTimeoutMs` and wired it into all built-in providers and lazy stream forwarder with environment variable fallback support.
2026-05-26 14:44:13 +02:00
roboomp e3f9b5b773 fix(ai): restored pi-style provider streaming
Removed OMP-owned first-event and idle watchdogs from provider stream consumption while preserving caller abort handling. Updated provider stream tests to assert slow/silent streams wait for provider output or caller abort instead of surfacing watchdog errors.

Fixes #1392
2026-05-26 04:55:00 +00:00
can1357 eef35a1cb3 fix(ai): raised default first-event watchdog for google-gemini-cli streams
- Added optional per-provider fallback parameters to stream timeout helper functions so callers can widen default watchdog values safely.
- Threaded provider-specific lazy stream limits into stream creation and set Google Gemini CLI to a 300000ms first-event fallback by default.
- Added tests covering fallback defaults, env precedence, and global-default behavior for both idle and first-event timeouts.
2026-05-26 05:17:58 +02:00