Fix inspect_history crash on None content and add native FC tool_calls display#18
Draft
isaacbmiller wants to merge 1 commit intomainfrom
Draft
Fix inspect_history crash on None content and add native FC tool_calls display#18isaacbmiller wants to merge 1 commit intomainfrom
isaacbmiller wants to merge 1 commit intomainfrom
Conversation
68b6b44 to
3a2b897
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes three issues in
inspect_history/pretty_print_historywhen displaying conversations that use native function calling:Crash on
Nonecontent — Native FC assistant messages can havecontent=None(when the model only returns tool calls with no text). The old code assumed content was always a string or list and crashed withAttributeError: 'NoneType' object has no attribute 'strip'.Missing tool_calls on assistant messages — When an assistant message in the conversation history includes
tool_calls(the standard OpenAI format for native FC), they were silently dropped. Now they're displayed using the same format as response tool_calls.Missing tool_call_id on tool messages — Tool role messages carry a
tool_call_idthat links them to the assistant's tool call. This is now shown in the message label.Before (on main)
Assistant messages with
content=Nonecrash:When content is present, tool_calls on assistant messages in history are silently dropped — you only see the text, not which tool was called.
After (this PR)
Tests
Added
tests/utils/test_inspect_history.pywith 4 test cases:test_none_content_does_not_crash— assistant message withcontent=None+ tool_callstest_tool_calls_displayed_on_assistant_message— assistant message with content + tool_callstest_tool_call_id_shown_on_tool_message— tool role message with tool_call_idtest_regular_messages_still_work— regression test for normal messagesAI Use
Generated with factory