Skip to content

fix(model): coerce None OpenAI content before String publish - #39

Open
Bartok9 wants to merge 1 commit into
Auromix:ros2-humblefrom
Bartok9:aerial/null-safe-feedback-text
Open

fix(model): coerce None OpenAI content before String publish#39
Bartok9 wants to merge 1 commit into
Auromix:ros2-humblefrom
Bartok9:aerial/null-safe-feedback-text

Conversation

@Bartok9

@Bartok9 Bartok9 commented Jul 23, 2026

Copy link
Copy Markdown

Summary

OpenAI function-call responses often set message.content to None. Feeding that into std_msgs/msg/String.data (or logging paths that assume a string) is unsafe.

This change:

  • Adds normalize_openai_text() pure helper
  • Coerces content at the response boundary
  • Hardens publish_string so publishers never receive None
  • Keeps function-call detection based on a non-None function_call field

Motivation

Defensive fix for a real crash path when the model chooses a tool/function call over plain text feedback.

Verification

python3 llm_model/test/test_normalize_openai_text.py -v
# 5 tests OK offline

AI-assisted scope; human-reviewed before open.

Claim: bartok
Operator: bartok
Campaign: aerial-drone

Function-call choices often set message content to None; assigning that
to std_msgs/String.data is unsafe. Normalize to a string at the response
boundary and inside publish_string. Offline unit tests included.

Signed-off-by: Bartok9 <danielrpike9@gmail.com>
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.

1 participant