Skip to content

Fix inspect_history crash on None content and add native FC tool_calls display#18

Draft
isaacbmiller wants to merge 1 commit intomainfrom
fix/inspect-history-native-fc
Draft

Fix inspect_history crash on None content and add native FC tool_calls display#18
isaacbmiller wants to merge 1 commit intomainfrom
fix/inspect-history-native-fc

Conversation

@isaacbmiller
Copy link
Copy Markdown

@isaacbmiller isaacbmiller commented Apr 16, 2026

Summary

Fixes three issues in inspect_history / pretty_print_history when displaying conversations that use native function calling:

  1. Crash on None content — Native FC assistant messages can have content=None (when the model only returns tool calls with no text). The old code assumed content was always a string or list and crashed with AttributeError: 'NoneType' object has no attribute 'strip'.

  2. 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.

  3. Missing tool_call_id on tool messages — Tool role messages carry a tool_call_id that links them to the assistant's tool call. This is now shown in the message label.

Before (on main)

Assistant messages with content=None crash:

AttributeError: 'NoneType' object has no attribute 'strip'

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)



[2025-01-15T10:30:00]

System message:

You are a helpful assistant.


User message:

What is the weather in Tokyo?


Assistant message:

Let me check the weather for you.
Tool calls:

get_weather: {"city": "Tokyo"}



Tool message: (tool_call_id=call_abc123)

Tokyo: 22°C, partly cloudy


Response:

The weather in Tokyo is 22°C and partly cloudy.

Tests

Added tests/utils/test_inspect_history.py with 4 test cases:

  • test_none_content_does_not_crash — assistant message with content=None + tool_calls
  • test_tool_calls_displayed_on_assistant_message — assistant message with content + tool_calls
  • test_tool_call_id_shown_on_tool_message — tool role message with tool_call_id
  • test_regular_messages_still_work — regression test for normal messages

AI Use

Generated with factory

@isaacbmiller isaacbmiller force-pushed the fix/inspect-history-native-fc branch from 68b6b44 to 3a2b897 Compare April 16, 2026 22:16
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