def test_convert_handles_missing_tool_name_or_args():
  """Test tool calls with missing name or args."""
  events = [
      build_event("user", [{"text": "Call tools"}]),
      # Event where FunctionCall has name=None
      Event(
          author="agent",
          content=types.Content(
              parts=[
                  types.Part(
                      function_call=types.FunctionCall(name=None, args={"a": 1})
                  )
              ]
          ),
      ),
      # Event where FunctionCall has args=None
      Event(
          author="agent",
          content=types.Content(
              parts=[
                  types.Part(
                      function_call=types.FunctionCall(name="tool_B", args=None)
                  )
              ]
          ),
      ),
      # Event where FunctionCall part exists but FunctionCall object is None
      # (should skip)
      Event(
          author="agent",
          content=types.Content(
              parts=[types.Part(function_call=None, text="some text")]
          ),
      ),
      build_event("agent", [{"text": "Done"}]),
  ]
  session = Session(id="s1", app_name="app", user_id="u1", events=events)
  expected = [{
      "query": "Call tools",
      "expected_tool_use": [
          {"tool_name": "", "tool_input": {"a": 1}},  # Defaults name to ""
          {"tool_name": "tool_B", "tool_input": {}},  # Defaults args to {}
      ],
      "expected_intermediate_agent_responses": [{
          "author": "agent",
          "text": "some text",
      }],  # Text part from the event where function_call was None
      "reference": "Done",
  }]
  assert convert_session_to_eval_format(session) == expected
Test tool calls with missing name or args.
tests/unittests/cli/utils/test_evals.py