Skip to content

Harden assistant activation and add integration coverage#9792

Draft
Saby-Bishops wants to merge 1 commit intomasterfrom
codex/enhance-assistant-helpers-and-validation
Draft

Harden assistant activation and add integration coverage#9792
Saby-Bishops wants to merge 1 commit intomasterfrom
codex/enhance-assistant-helpers-and-validation

Conversation

@Saby-Bishops
Copy link
Copy Markdown
Member

Motivation

  • Make assistant usage explicit and safe by validating the configured assistant flag and provider compatibility before calling OpenAI assistant endpoints.
  • Stabilize runtime behavior of assistant runs by adding error normalization, retry/timeout guards and terminal-status handling to reduce flakiness and unclear errors.
  • Provide automated coverage for both streaming and non-streaming assistant flows to catch regressions early.
  • Expose and persist a frontend toggle so administrators can enable/disable the assistant endpoint and ensure ownership metadata is preserved when saving config.

Description

  • Add validateAssistantCompatibility that rejects assistant mode unless assistant.enabled is true and the provider is openai, and wire it into aiChatStream/aiChatNonStream (modified chatapi/src/utils/chat-helpers.utils.ts).
  • Harden assistant API calls by adding normalizeAssistantError, wrapping assistant calls in try/catch, implementing terminal run status handling, retry limit and timeout in waitForRunCompletion, and normalizing streaming errors (modified chatapi/src/utils/chat-assistant.utils.ts).
  • Persist assistant state in backend config initialization by adding assistant.enabled to provider config and typing (chatapi/src/config/ai-providers.config.ts, chatapi/src/models/chat.model.ts).
  • Add integration tests exercising assistant non-streaming, streaming, and provider validation and a runnable script test:integration (new chatapi/src/tests/assistant.integration.test.ts and chatapi/package.json).
  • Expose a frontend toggle and persist it: add assistantEnabled form control and UI slide toggle, include assistant.enabled in saved configuration and defaults, and only set data.assistant for chat submissions when the toggle is on and provider is OpenAI (modified src/app/manager-dashboard/manager-aiservices.component.ts, src/app/manager-dashboard/manager-aiservices.component.html, src/app/configuration/configuration.component.ts, and src/app/chat/chat-window/chat-window.component.ts).
  • Add a frontend unit test verifying toggle initialization and that save preserves ownership metadata and the new assistant.enabled flag (src/app/manager-dashboard/manager-aiservices.component.spec.ts).

Testing

  • Ran npm --prefix chatapi run build to compile the chatapi TypeScript bundle and it succeeded.
  • Ran npm --prefix chatapi run lint (ESLint) and it passed after adding test-file eslint disables.
  • Ran npm --prefix chatapi run test:integration which executed the new assistant integration scenarios and reported assistant integration tests passed.
  • Attempted the Angular unit test target npm test -- --watch=false --browsers=ChromeHeadless --include=src/app/manager-dashboard/manager-aiservices.component.spec.ts, which failed in this environment because the Angular CLI (ng) is not installed, so browser-based unit runner could not run here.

Codex Task

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant