Skip to content

Fix OpenAI structured chat response handling - #60

Open
yinli-systems wants to merge 3 commits into
i-dot-ai:mainfrom
yinli-systems:fix-openai-structured-chat-response
Open

yinli-systems wants to merge 3 commits into
i-dot-ai:mainfrom
yinli-systems:fix-openai-structured-chat-response

Conversation

@yinli-systems

@yinli-systems yinli-systems commented Jun 27, 2026

Copy link
Copy Markdown

Summary

  • replace the undefined handle_response call in OpenAIModelAdapter.structured_chat with the existing response-handling pattern used by chat
  • preserve incomplete-response checking for structured completions
  • add a focused unit test using a fake Azure client, without live credentials
  • explicitly verify the completeness check receives the first choice and original response

Fixes #36.

Validation

Validated after merging the current upstream main:

uv run --python 3.12 \
  --with pytest --with pytest-asyncio \
  --with pydantic --with pydantic-settings --with python-dotenv \
  --with i-dot-ai-utilities --with openai --with google-genai \
  pytest tests/test_azure_openai_adapter.py -q

uv run --python 3.12 --with ruff \
  ruff check common/llm/adapters/azure_openai.py tests/test_azure_openai_adapter.py

uv run --python 3.12 --with ruff \
  ruff format --check common/llm/adapters/azure_openai.py tests/test_azure_openai_adapter.py

uv run --python 3.12 \
  --with pydantic --with pydantic-settings --with python-dotenv \
  --with i-dot-ai-utilities --with openai --with google-genai \
  python -m py_compile common/llm/adapters/azure_openai.py tests/test_azure_openai_adapter.py

Results: target test passed; Ruff lint and format checks passed; Python compilation passed.

Fault-injecting the original self.handle_response(response) call made the focused test fail with the expected AttributeError, confirming the test directly covers the reported runtime bug. Restoring the fix returned the suite to green.

AI assistance

AI assistance was used to merge current upstream changes, strengthen the response-completeness assertion, run fault-injection validation, and refine this PR description. The resulting changes and validation evidence were reviewed before submission.

@yinli-systems
yinli-systems requested a review from a team as a code owner June 27, 2026 11:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

OpenAIModelAdapter.structured_chat calls undefined handle_response method

1 participant